From c7853d758a5e401a2914344da4889228250e7538 Mon Sep 17 00:00:00 2001 From: Thinh Nguyen Date: Thu, 8 Feb 2024 12:42:39 -0600 Subject: [PATCH] fix(ephys): raise error if no files found in EphysSessionInfo --- element_array_ephys/ephys_organoids.py | 33 +++++++++++++------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/element_array_ephys/ephys_organoids.py b/element_array_ephys/ephys_organoids.py index 8e49eaf0..e6a06ab4 100644 --- a/element_array_ephys/ephys_organoids.py +++ b/element_array_ephys/ephys_organoids.py @@ -194,27 +194,28 @@ def make(self, key): EphysRawFile & f"file_time BETWEEN '{key['start_time']}' AND '{key['end_time']}'" ) + if not query: + raise FileNotFoundError(f"No EphysRawFile found BETWEEN '{key['start_time']}' AND '{key['end_time']}'") - if query: - first_file = (query).fetch("file_path", order_by="file_time", limit=1)[0] + first_file = query.fetch("file_path", order_by="file_time", limit=1)[0] - first_file = find_full_path(get_ephys_root_data_dir(), first_file) + first_file = find_full_path(get_ephys_root_data_dir(), first_file) - # Read file header - with open(first_file, "rb") as f: - header = intanrhdreader.read_header(f) - del header["spike_triggers"], header["aux_input_channels"] + # Read file header + with open(first_file, "rb") as f: + header = intanrhdreader.read_header(f) + del header["spike_triggers"], header["aux_input_channels"] - logger.info(f"Populating ephys.EphysSessionInfo for <{key}>") + logger.info(f"Populating ephys.EphysSessionInfo for <{key}>") - self.insert( - [ - { - **key, - "session_info": header, - } - ] - ) + self.insert( + [ + { + **key, + "session_info": header, + } + ] + ) @schema