Repository navigation
Closed
Labels
questionGeneral question regarding SI
Description
Hi Spikeinterface,
There seems to be an issue in the spikeinterface set_probes function in the core packages.
I am trying to set a probes to a recording but I get this error :
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[1], [line 50](vscode-notebook-cell:?execution_count=1&line=50)
[48](vscode-notebook-cell:?execution_count=1&line=48) recording_b = recording.remove_channels(remove_channel_ids=missing_numbers)
[49](vscode-notebook-cell:?execution_count=1&line=49) #probe.set_device_channel_indices(recording_b.get_channel_ids())
---> [50](vscode-notebook-cell:?execution_count=1&line=50) recording_clean = recording_b.set_probe(probe)
[51](vscode-notebook-cell:?execution_count=1&line=51) #recording = recording.remove_channels(remove_channel_ids=bad_channel['index_pixels'])
[52](vscode-notebook-cell:?execution_count=1&line=52) # setting the channel location
[53](vscode-notebook-cell:?execution_count=1&line=53) #recording.set_channel_locations(positions) to check...
[54](vscode-notebook-cell:?execution_count=1&line=54) rec_dict = dict(filt=recording_clean)
File [~/.conda/envs/CHIME_kayvan/lib/python3.9/site-packages/spikeinterface/core/baserecordingsnippets.py:96](https://vscode-remote+ssh-002dremote-002bvis-005fnode2.vscode-resource.vscode-cdn.net/camp/home/combadk/working/combadk/ScriptKC/CHIME_script/~/.conda/envs/CHIME_kayvan/lib/python3.9/site-packages/spikeinterface/core/baserecordingsnippets.py:96), in BaseRecordingSnippets.set_probe(self, probe, group_mode, in_place)
[94](https://vscode-remote+ssh-002dremote-002bvis-005fnode2.vscode-resource.vscode-cdn.net/camp/home/combadk/working/combadk/ScriptKC/CHIME_script/~/.conda/envs/CHIME_kayvan/lib/python3.9/site-packages/spikeinterface/core/baserecordingsnippets.py:94) probegroup = ProbeGroup()
[95](https://vscode-remote+ssh-002dremote-002bvis-005fnode2.vscode-resource.vscode-cdn.net/camp/home/combadk/working/combadk/ScriptKC/CHIME_script/~/.conda/envs/CHIME_kayvan/lib/python3.9/site-packages/spikeinterface/core/baserecordingsnippets.py:95) probegroup.add_probe(probe)
---> [96](https://vscode-remote+ssh-002dremote-002bvis-005fnode2.vscode-resource.vscode-cdn.net/camp/home/combadk/working/combadk/ScriptKC/CHIME_script/~/.conda/envs/CHIME_kayvan/lib/python3.9/site-packages/spikeinterface/core/baserecordingsnippets.py:96) return self.set_probes(probegroup, group_mode=group_mode, in_place=in_place)
File [~/.conda/envs/CHIME_kayvan/lib/python3.9/site-packages/spikeinterface/core/baserecordingsnippets.py:170](https://vscode-remote+ssh-002dremote-002bvis-005fnode2.vscode-resource.vscode-cdn.net/camp/home/combadk/working/combadk/ScriptKC/CHIME_script/~/.conda/envs/CHIME_kayvan/lib/python3.9/site-packages/spikeinterface/core/baserecordingsnippets.py:170), in BaseRecordingSnippets.set_probes(self, probe_or_probegroup, group_mode, in_place)
[163](https://vscode-remote+ssh-002dremote-002bvis-005fnode2.vscode-resource.vscode-cdn.net/camp/home/combadk/working/combadk/ScriptKC/CHIME_script/~/.conda/envs/CHIME_kayvan/lib/python3.9/site-packages/spikeinterface/core/baserecordingsnippets.py:163) if number_of_device_channel_indices >= self.get_num_channels():
[164](https://vscode-remote+ssh-002dremote-002bvis-005fnode2.vscode-resource.vscode-cdn.net/camp/home/combadk/working/combadk/ScriptKC/CHIME_script/~/.conda/envs/CHIME_kayvan/lib/python3.9/site-packages/spikeinterface/core/baserecordingsnippets.py:164) error_msg = (
[165](https://vscode-remote+ssh-002dremote-002bvis-005fnode2.vscode-resource.vscode-cdn.net/camp/home/combadk/working/combadk/ScriptKC/CHIME_script/~/.conda/envs/CHIME_kayvan/lib/python3.9/site-packages/spikeinterface/core/baserecordingsnippets.py:165) f"The given Probe have 'device_channel_indices' that do not match channel count \n"
[166](https://vscode-remote+ssh-002dremote-002bvis-005fnode2.vscode-resource.vscode-cdn.net/camp/home/combadk/working/combadk/ScriptKC/CHIME_script/~/.conda/envs/CHIME_kayvan/lib/python3.9/site-packages/spikeinterface/core/baserecordingsnippets.py:166) f"{number_of_device_channel_indices} vs {self.get_num_channels()} \n"
[167](https://vscode-remote+ssh-002dremote-002bvis-005fnode2.vscode-resource.vscode-cdn.net/camp/home/combadk/working/combadk/ScriptKC/CHIME_script/~/.conda/envs/CHIME_kayvan/lib/python3.9/site-packages/spikeinterface/core/baserecordingsnippets.py:167) f"device_channel_indices are the following: {device_channel_indices} \n"
[168](https://vscode-remote+ssh-002dremote-002bvis-005fnode2.vscode-resource.vscode-cdn.net/camp/home/combadk/working/combadk/ScriptKC/CHIME_script/~/.conda/envs/CHIME_kayvan/lib/python3.9/site-packages/spikeinterface/core/baserecordingsnippets.py:168) f"recording channels are the following: {self.get_channel_ids()} \n"
[169](https://vscode-remote+ssh-002dremote-002bvis-005fnode2.vscode-resource.vscode-cdn.net/camp/home/combadk/working/combadk/ScriptKC/CHIME_script/~/.conda/envs/CHIME_kayvan/lib/python3.9/site-packages/spikeinterface/core/baserecordingsnippets.py:169) )
--> [170](https://vscode-remote+ssh-002dremote-002bvis-005fnode2.vscode-resource.vscode-cdn.net/camp/home/combadk/working/combadk/ScriptKC/CHIME_script/~/.conda/envs/CHIME_kayvan/lib/python3.9/site-packages/spikeinterface/core/baserecordingsnippets.py:170) raise ValueError(error_msg)
...
ValueError: The given Probe have 'device_channel_indices' that do not match channel count
110 vs 52
device_channel_indices are the following: [ 1 2 4 5 6 7 9 10 11 13 18 19 20 24 28 35 37 38 39 40 41 44 47 49 50 52 54 58 59 63 68 70 72 79 81 83 84 86 87 88 89 90 91 92 94 97 100 104 106 107 108 110]
recording channels are the following: [ 1 2 4 5 6 7 9 10 11 13 18 19 20 24 28 35 37 38 39 40 41 44 47 49 50 52 54 58 59 63 68 70 72 79 81 83 84 86 87 88 89 90 91 92 94 97 100 104 106 107 108 110]
When I had a look at the code, it seems to check the max of the device_channel_indices against the number of channel in the recording should it be comparing size?
number_of_device_channel_indices = np.max(list(device_channel_indices) + [0])
if number_of_device_channel_indices >= self.get_num_channels():
error_msg = (
f"The given Probe have 'device_channel_indices' that do not match channel count \n"
f"{number_of_device_channel_indices} vs {self.get_num_channels()} \n"
f"device_channel_indices are the following: {device_channel_indices} \n"
f"recording channels are the following: {self.get_channel_ids()} \n"
)
raise ValueError(error_msg)
Metadata
Metadata
Assignees
Labels
questionGeneral question regarding SI
Activity
alejoe91 commentedon Jan 24, 2024
Hi @Kayv-cmb
The
device_channel_indicesis an index, so it's maximum value cannot exceednum_channels - 1How are you setting the
device_channel_indices? Can you paste your script?Kayv-cmb commentedon Jan 24, 2024
I am setting it like this, but basically I have a lot of preprocessing before actually creating a recording and which end up of
with having a positions array (x,y,z) for the probe with channel indices like this
array([ 74, 99, 25, 58, 72, 107, 91, 59, 63, 35, 90, 44, 42, 108, 97, 41, 87, 66, 19, 84, 37, 43, 88, 81, 104, 110, 57, 93, 106, 89, 24, 48, 2, 5, 52, 111, 28, 61, 102, 9, 68, 4, 11, 70, 40, 6, 75, 47, 79, 86, 94, 13, 49, 100, 92, 20, 7, 10, 1, 39, 18, 38, 50, 54, 83])Kayv-cmb commentedon Jan 24, 2024
and when I compare this
I have exactly the same channel inside both and the same number of channel but the match check give different output
Kayv-cmb commentedon Jan 25, 2024
I changed my way of doing it so that it would not trigger this error so I will close