Skip to content

Commit fdf725d

Browse files
committed
ADD: check if no probes found. If so, return None or raise Exception.
1 parent 790bff2 commit fdf725d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/probeinterface/io.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ def write_imro(file: str | Path, probe: Probe):
12641264
f.write("".join(ret))
12651265

12661266

1267-
def read_spikegadgets(file: str | Path) -> ProbeGroup:
1267+
def read_spikegadgets(file: str | Path, raise_error: bool = True) -> ProbeGroup:
12681268
"""
12691269
Find active channels of the given Neuropixels probe from a SpikeGadgets .rec file.
12701270
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:
13001300
probe_configs = [device for device in hconf if device.attrib["name"] == "NeuroPixels1"]
13011301
n_probes = len(probe_configs)
13021302

1303+
if n_probes == 0:
1304+
if raise_error:
1305+
raise Exception("No Neuropixels 1.0 probes found")
1306+
return None
1307+
13031308
# Container to store Probe objects
13041309
probe_group = ProbeGroup()
13051310

tests/test_io/test_spikegadgets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_parse_meta():
1919

2020

2121
def test_neuropixels_1_reader():
22-
probe_group = read_spikegadgets(data_path / test_file)
22+
probe_group = read_spikegadgets(data_path / test_file, raise_error=False)
2323
assert len(probe_group.probes) == 2
2424
for probe in probe_group.probes:
2525
assert "1.0" in probe.model_name

0 commit comments

Comments
 (0)