Skip to content

Commit

Permalink
fix(ephys): raise error if no files found in EphysSessionInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
ttngu207 authored Feb 8, 2024
1 parent 93ac4c9 commit c7853d7
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions element_array_ephys/ephys_organoids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c7853d7

Please sign in to comment.