From b5fc0e5985f3c3b5101099ed57ae519acd062b1a Mon Sep 17 00:00:00 2001 From: Darshan Mandge <8694327+darshanmandge@users.noreply.github.com> Date: Tue, 2 Apr 2024 16:25:32 +0200 Subject: [PATCH] prevent filename being None in Cell (#175) * prevent filename None * tox fix * rename local filename variable to filepath * change variable name and update exception --------- Co-authored-by: Darshan Mandge --- bluepyefe/cell.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/bluepyefe/cell.py b/bluepyefe/cell.py index ca159d5..cd60b48 100644 --- a/bluepyefe/cell.py +++ b/bluepyefe/cell.py @@ -60,22 +60,28 @@ def reader(self, config_data, recording_reader=None): used will be chosen automatically based on the extension of the file. """ - - if "v_file" in config_data: - filename = config_data["v_file"] - # if both present: use filepath. e.g. for some nwb that 'contain' igor files + # if both present: use filepath. + # e.g. for some nwb that 'contain' igor files + filepath = None if "filepath" in config_data: - filename = config_data["filepath"] + filepath = config_data["filepath"] + if "v_file" in config_data and filepath is None: + filepath = config_data["v_file"] + + if filepath is None: + raise Exception( + "No 'filepath' or 'v_file' provided in the metadata for the recording." + ) if recording_reader: return recording_reader(config_data) - if ".abf" in filename: + if ".abf" in filepath: return axon_reader(config_data) - if ".ibw" in filename or ".bwav" in filename: + if ".ibw" in filepath or ".bwav" in filepath: return igor_reader(config_data) - if ".nwb" in filename: + if ".nwb" in filepath: return nwb_reader(config_data) - if ".txt" in filename: + if ".txt" in filepath: return csv_lccr_reader(config_data) raise Exception(