diff --git a/src/probeinterface/io.py b/src/probeinterface/io.py index ef79f45..0646c75 100644 --- a/src/probeinterface/io.py +++ b/src/probeinterface/io.py @@ -1264,7 +1264,7 @@ def write_imro(file: str | Path, probe: Probe): f.write("".join(ret)) -def read_spikegadgets(file: str | Path) -> ProbeGroup: +def read_spikegadgets(file: str | Path, raise_error: bool = True) -> ProbeGroup: """ Find active channels of the given Neuropixels probe from a SpikeGadgets .rec file. SpikeGadgets headstages support up to three Neuropixels 1.0 probes (as of March 28, 2024), @@ -1300,6 +1300,11 @@ def read_spikegadgets(file: str | Path) -> ProbeGroup: probe_configs = [device for device in hconf if device.attrib["name"] == "NeuroPixels1"] n_probes = len(probe_configs) + if n_probes == 0: + if raise_error: + raise Exception("No Neuropixels 1.0 probes found") + return None + # Container to store Probe objects probe_group = ProbeGroup() diff --git a/tests/test_io/test_spikegadgets.py b/tests/test_io/test_spikegadgets.py index 5cb1814..7415db9 100644 --- a/tests/test_io/test_spikegadgets.py +++ b/tests/test_io/test_spikegadgets.py @@ -19,7 +19,7 @@ def test_parse_meta(): def test_neuropixels_1_reader(): - probe_group = read_spikegadgets(data_path / test_file) + probe_group = read_spikegadgets(data_path / test_file, raise_error=False) assert len(probe_group.probes) == 2 for probe in probe_group.probes: assert "1.0" in probe.model_name