You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Getting the proper channel mapping from a Spikegadgets .rec file (tetrodes) #472
Hi, I'm trying to (re)write a spike-sorting pipeline for spikegadgets tetrode data via spike interface & probe interface (both are very convenient!! thank you!) It's going pretty well but I am wondering about the channel mapping.
My setup is 128 channels organised in 32 tetrodes.
On the one hand, spike interface can read my example recording (directly from the .rec file with read_spikegadgets !) and the recording has a channel_name property that in my case contains the following:
array(['trode19chan0', 'trode5chan32', 'trode9chan64', 'trode15chan96',
'trode20chan1', 'trode30chan33', 'trode10chan65', 'trode24chan97',
'trode19chan2', 'trode5chan34', 'trode9chan66', 'trode15chan98', ...]
I can use this to create a dictionnary between tetrode numbers (1-> 32) and channel numbers (0 -> 127), I can then feed this to spike / probe interface to give it the relevant 4 channel numbers for each tetrode, with something like:
tetrode_group = ProbeGroup()
for trode_name in tetrode_list:
tetrode = generate_tetrode()
these_chan = TT_dict[trode_name]
tetrode.set_device_channel_indices(these_chan)
tetrode_group.add_probe(tetrode)
this_rec.set_probegroup(tetrode_group, group_mode = 'by_probe')
However, I think something is missing in that approach as the resulting 4 channels of each tetrode do not look like they belong to the same tetrode in Phy or in any data previews. I'm pretty sure there should be an additional mapping step but I'm not sure what exactly is missing, looking at the spike interface or probeinterface doc does not help me much as I couldn't see any SpikeGadgets examples there.
I'm thinking that probably the channel names in the 'channel_name' property of the recording do not actually match the naming scheme used by set_device_channel_indices? But how to get them to match?
Would anyone has any insights, link to relevant documentation that I might have missed or, even better, an example code that handles this mapping? Happy to share my code once it works or if it helps debug!
I also see that the recording has a _main_ids attribute that contains:
these (channel?) numbers seem to be the same as the numbers after 'chan' in 'channel_name':
and they are ordered in the same way. Does this mean there is an additional mapping to take into account which is something like
0 -> 0
1 -> 32
2 -> 64
3 -> 96
4 -> 1
etc.?
but what do the first and the 2nd number mean here? are any of these the famous 'channel indices'?
I also feel like set_device_channel_indices is very important to all this but I couldn't find its documentation. In the function definition it just says:
Manually set the device channel indices.
If some channels are not connected or not recorded then channel should be set to "-1"
Parameters
channel_indices : array[int] | list[int]
The device channel indices to set
which doesn't explain what is meant by those channel indices.
Looking at the doc for "handle channel indices" it says
the physical contact channel index is rarely the channel index on the device.
In my case (tetrodes) I don't really care about the physical contact number, but I want to know which 4 channels are part of which tetrode, provided that the tetrode number is the same as the one I was using in my recording.
I'm not sure what to do next to figure this out computationally so unless someone has a better idea, I'll try to plot the signals from all channels in spike interface and see if I can somehow match that so the signals as seen in my recording program (Trodes)...
The main_ids and channel_name are in the order of your data. So the first one is the first row in your raw data array that is saved on your computer. So my first instinct is that all the mapping complexity is already dealt with here, and device channel indices should just be range(0, 128).
The way I would proceed is to give each channel in your recording "group" property based on "trode". So something like
Then use the split_by method to split your recording by trode_number. Then attach a probe to each subgrouped recording. The device channel indicies should look after themselves without you dong anything.
I would then use the plot_traces function to visualise each group, and see if I can find correlated spikes to confirm the grouping is correct. There's good notes about visualising traces in the recent Open Software Summer School notes here: https://neuroinformatics.dev/course_ephys_osss/preprocessing-steps-coding.html
Thanks Chris!! This is super useful! In the meantime I had managed to figure how to get the correct channels, with this other issue helping, and that seems to be what you say - device_channel_indices are indices and not channel numbers (yes, I realise now that it was in the name), and the mapping is indeed in channel_name.
Then I was unsure how to get the correct Tetrode number. Using the 'group' number as tetrode number didn't seem to work as it is an index and not the actual tetrode number... But your suggestion of creating a new trode_number key specifically for this should fix that!
I'll try this out hopefully tomorrow and I'll let you know. Thanks again!
Activity
elduvelle commentedon Oct 17, 2026
Hi again, still trying to figure this out..
I also see that the recording has a
_main_idsattribute that contains:these (channel?) numbers seem to be the same as the numbers after 'chan' in 'channel_name':
and they are ordered in the same way. Does this mean there is an additional mapping to take into account which is something like
0 -> 0
1 -> 32
2 -> 64
3 -> 96
4 -> 1
etc.?
but what do the first and the 2nd number mean here? are any of these the famous 'channel indices'?
I also feel like
set_device_channel_indicesis very important to all this but I couldn't find its documentation. In the function definition it just says:which doesn't explain what is meant by those channel indices.
Looking at the doc for "handle channel indices" it says
In my case (tetrodes) I don't really care about the physical contact number, but I want to know which 4 channels are part of which tetrode, provided that the tetrode number is the same as the one I was using in my recording.
I'm not sure what to do next to figure this out computationally so unless someone has a better idea, I'll try to plot the signals from all channels in spike interface and see if I can somehow match that so the signals as seen in my recording program (Trodes)...
chrishalcrow commentedon Oct 19, 2026
Hello,
Yeah, the most documentation there is is in https://probeinterface.readthedocs.io/en/stable/examples/ex_05_device_channel_indices.html which you've already found.
The main_ids and channel_name are in the order of your data. So the first one is the first row in your raw data array that is saved on your computer. So my first instinct is that all the mapping complexity is already dealt with here, and device channel indices should just be range(0, 128).
The way I would proceed is to give each channel in your recording "group" property based on "trode". So something like
Then use the
split_bymethod to split your recording bytrode_number. Then attach a probe to each subgrouped recording. The device channel indicies should look after themselves without you dong anything.I would then use the
plot_tracesfunction to visualise each group, and see if I can find correlated spikes to confirm the grouping is correct. There's good notes about visualising traces in the recent Open Software Summer School notes here: https://neuroinformatics.dev/course_ephys_osss/preprocessing-steps-coding.htmlLet us know if that works!
elduvelle commentedon Oct 19, 2026
Thanks Chris!! This is super useful! In the meantime I had managed to figure how to get the correct channels, with this other issue helping, and that seems to be what you say - device_channel_indices are indices and not channel numbers (yes, I realise now that it was in the name), and the mapping is indeed in
channel_name.Then I was unsure how to get the correct Tetrode number. Using the 'group' number as tetrode number didn't seem to work as it is an index and not the actual tetrode number... But your suggestion of creating a new
trode_numberkey specifically for this should fix that!I'll try this out hopefully tomorrow and I'll let you know. Thanks again!