Skip to content

Commit

Permalink
Merge pull request #1248 from alejoe91/oe-optional-events
Browse files Browse the repository at this point in the history
Allow folders without events/continuous streams to be loaded
  • Loading branch information
apdavison authored Jul 27, 2023
2 parents 06d9d08 + 28697b6 commit 20c0fec
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions neo/rawio/openephysbinaryrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,16 @@ def _parse_header(self):
check_folder_consistency(folder_structure, possible_experiments)
self.folder_structure = folder_structure

# all streams are consistent across blocks and segments
sig_stream_names = sorted(list(all_streams[0][0]['continuous'].keys()))
event_stream_names = sorted(list(all_streams[0][0]['events'].keys()))
# all streams are consistent across blocks and segments.
# also checks that 'continuous' and 'events' folder are present
if 'continuous' in all_streams[0][0]:
sig_stream_names = sorted(list(all_streams[0][0]['continuous'].keys()))
else:
sig_stream_names = []
if 'events' in all_streams[0][0]:
event_stream_names = sorted(list(all_streams[0][0]['events'].keys()))
else:
event_stream_names = []

# first loop to reassign stream by "stream_index" instead of "stream_name"
self._sig_streams = {}
Expand Down Expand Up @@ -563,7 +570,13 @@ def explore_folder(dirname, experiment_names=None):
# nested dictionary: block_index > seg_index > data_type > stream_name
all_streams = {}
nb_segment_per_block = {}
recording_node = folder_structure[list(folder_structure.keys())[0]]
record_node_names = list(folder_structure.keys())
if len(record_node_names) == 0:
raise ValueError(
f"{dirname} is not a valid Open Ephys binary folder. No 'structure.oebin' "
f"files were found in sub-folders."
)
recording_node = folder_structure[record_node_names[0]]

# nb_block needs to be consistent across record nodes. Use the first one
nb_block = len(recording_node['experiments'])
Expand Down Expand Up @@ -609,7 +622,8 @@ def check_folder_consistency(folder_structure, possible_experiment_names=None):
("Inconsistent experiments across recording nodes!")

# check that "continuous" streams are the same across multiple segments (recordings)
experiments = folder_structure[list(folder_structure.keys())[0]]['experiments']
record_node_names = list(folder_structure.keys())
experiments = folder_structure[record_node_names[0]]['experiments']
for exp_id, experiment in experiments.items():
segment_stream_names = None
if len(experiment['recordings']) > 1:
Expand Down

0 comments on commit 20c0fec

Please sign in to comment.