Skip to content

Commit

Permalink
add multi-segment error and test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeZiminski committed Dec 14, 2023
1 parent 7b263fe commit df80034
Show file tree
Hide file tree
Showing 30 changed files with 25,683 additions and 6 deletions.
8 changes: 8 additions & 0 deletions spikewrap/data_classes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ def _validate_inputs(
f"in run name {run_name}. "
)

def assert_if_multi_segment(self):
for ses_name, run_name in self.flat_sessions_and_runs():
if self[ses_name][run_name]["0-raw"].get_num_segments() != 1:
raise ValueError(
"Multi-segment recordings are not currently "
"supported. Please get in contact!"
)

# Rawdata Paths --------------------------------------------------------------

def get_rawdata_top_level_path(self) -> Path:
Expand Down
10 changes: 7 additions & 3 deletions spikewrap/pipeline/load_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,18 @@ def load_data(
# TODO: when extending to OpenEphys, will need to carefully centralise
# as much logic as possible e.g. casting to float64 with astype.
if data_format == "spikeglx":
return _load_spikeglx_data(empty_data_class)
_load_spikeglx_data(empty_data_class)

elif data_format == "spikeinterface":
return _load_spikeinterface(
_load_spikeinterface(
empty_data_class
) # TODO: this return isn't needed as preprocess_data is simply filled.
else:
raise RuntimeError("`data_format` not recognised.")

raise RuntimeError("`data_format` not recognised.")
empty_data_class.assert_if_multi_segment() # TODO: change this stupid obj name!

return empty_data_class # TODO: change this stupid obj name!


# --------------------------------------------------------------------------------------
Expand Down
24 changes: 24 additions & 0 deletions tests/data/toy_multi_segment/generate_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from pathlib import Path

from spikeinterface import generate_ground_truth_recording

print("Starting...")

sessions_and_runs = {"ses-001": ["ses-001_run-001", "ses-001_run-002"]}

sub = "sub-001_type-multiseg"

base_path = Path(__file__).parent.resolve() / "rawdata"

for ses in sessions_and_runs.keys():
for run in sessions_and_runs[ses]:
num_channels = 384
# if seg too small will error
# TODO: issue on SI default durations as list on generate
recording, _ = generate_ground_truth_recording(
durations=[0.1, 0.1, 0.1], num_channels=num_channels, num_units=2
)

output_path = base_path / sub / ses / "ephys" / run

recording.save(folder=output_path, chunk_size=1000000, overwrite=True)
Loading

0 comments on commit df80034

Please sign in to comment.