Skip to content
Merged
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
20 changes: 13 additions & 7 deletions src/spikeinterface/extractors/neoextractors/openephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,19 @@ def __init__(
# Ensure device channel index corresponds to channel_ids
probe_channel_names = probe.contact_annotations.get("channel_name", None)
if probe_channel_names is not None and not np.array_equal(probe_channel_names, self.channel_ids):
device_channel_indices = []
probe_channel_names = list(probe_channel_names)
device_channel_indices = np.zeros(len(self.channel_ids), dtype=int)
for i, ch in enumerate(self.channel_ids):
index_in_probe = probe_channel_names.index(ch)
device_channel_indices[index_in_probe] = i
probe.set_device_channel_indices(device_channel_indices)
if set(probe_channel_names) == set(self.channel_ids):
device_channel_indices = []
probe_channel_names = list(probe_channel_names)
device_channel_indices = np.zeros(len(self.channel_ids), dtype=int)
for i, ch in enumerate(self.channel_ids):
index_in_probe = probe_channel_names.index(ch)
device_channel_indices[index_in_probe] = i
probe.set_device_channel_indices(device_channel_indices)
else:
warnings.warn(
"Channel names in the probe do not match the channel ids from Neo. "
"Cannot set device channel indices, but this might lead to incorrect probe geometries"
Comment on lines +363 to +365
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I don't understand this fix. This now creates a probe with no device_channel_indices, which then can't be attached to any recordings?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wait, so probeinterface will set device_channel_indices just basically using a range. So the probes that hit this warning so still have device_channel_indices?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, exactly! So in this case it will work as before

)

if probe.shank_ids is not None:
self.set_probe(probe, in_place=True, group_mode="by_shank")
Expand Down
3 changes: 3 additions & 0 deletions src/spikeinterface/extractors/tests/test_neoextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ class OpenEphysBinaryRecordingTest(RecordingCommonTestSuite, unittest.TestCase):
("openephysbinary/v0.5.x_two_nodes", {"stream_id": "0"}),
("openephysbinary/v0.5.x_two_nodes", {"stream_id": "1"}),
("openephysbinary/v0.6.x_neuropixels_multiexp_multistream", {"stream_id": "0", "block_index": 0}),
# TODO: block_indices 1/2 of v0.6.x_neuropixels_multiexp_multistream have a mismatch in the channel names between
# the settings files (starting with CH0) and structure.oebin (starting at CH1).
# Currently, the extractor will skip remapping to match order in oebin and settings file, raising a warning
("openephysbinary/v0.6.x_neuropixels_multiexp_multistream", {"stream_id": "1", "block_index": 1}),
(
"openephysbinary/v0.6.x_neuropixels_multiexp_multistream",
Expand Down