Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/probeinterface/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def write_BIDS_probe(folder: str | Path, probe_or_probegroup: Probe | ProbeGroup

channel_indices = []
for probe in probes:
if probe.device_channel_indices:
if probe.device_channel_indices is not None:
channel_indices.extend(probe.device_channel_indices)
else:
channel_indices.extend([-1] * probe.get_contact_count())
Expand Down
17 changes: 17 additions & 0 deletions tests/test_io/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ def test_BIDS_format(tmp_path):
assert all(probe_orig.contact_plane_axes[i][dim] == probe_read.contact_plane_axes[t][i][dim])


def test_BIDS_format_with_device_channel_indices(tmp_path):
folder_path = tmp_path / "test_BIDS_wired"
folder_path.mkdir()

probe = generate_dummy_probe()
probe.annotate(type="laminar")
channel_indices = np.arange(probe.get_contact_count())[::-1]
probe.set_device_channel_indices(channel_indices)

write_BIDS_probe(folder_path, probe)
probegroup_read = read_BIDS_probe(folder_path)

probe_read = probegroup_read.probes[0]
t = np.array([list(probe_read.contact_ids).index(cid) for cid in probe.contact_ids])
np.testing.assert_array_equal(probe_read.device_channel_indices[t], channel_indices)


def test_BIDS_format_empty(tmp_path):
folder_path = tmp_path / "test_BIDS_minimal"
folder_path.mkdir()
Expand Down
Loading