spikeinterface: group_mode="by_shank" does not propagate to .mat probe file generated for Kilosort4

I understand that Kilosort4 has added direct support for the processing of multi-shank data. My reading of the Kilosort4 documentation indicates that proper processing of a multi-shank probe requires electrodes belonging to each shank to have a correctly assigned value for the “kcoords” parameter (see this page: https://kilosort.readthedocs.io/en/latest/tutorials/make_probe.html).

When I run Kilosort4 from its own GUI (no SpikeInterface involved) using a multi-shank probe map (.mat format), the output file channel_shanks.npy correctly assigns each channel to its proper shank_id. However, when I run Kilosort4 through SpikeInterface’s run_sorter command, channel_shanks.npy is uniformly populated by 0’s. I think this means that shankIDs are not getting correctly assigned to the kcoords parameter in the .mat probe map generated in kilosortbase.py.

For reference, here is the script I am using to run Kilosort4.

def BIN_1024ch_SI_4S1024_try2():
    recording = si.read_binary(bin1024_file, 
        sampling_frequency=40_000, 
        dtype=np.int16, 
        num_channels=1024, 
        time_axis=0, 
        gain_to_uV=0.18317874024609845,
        offset_to_uV=0, 
        is_filtered=False)
        
    prb1024 = get_probe(manufacturer="plexon", probe_name="4S1024")
    prb1024.set_device_channel_indices(channel_indices=prb1024.contact_ids)
    recording = recording.set_probe(prb1024, group_mode="by_shank")
    sorting = si.run_sorter(
        sorter_name = "kilosort4",
        recording = recording,
        verbose = True,
        folder = output_folder / dataset_name,
        remove_existing_folder = False,
        save_preprocessed_copy = True,
    )

Notice that when I assign the probe to the recording object, I set group_mode to “by_shank”. Further, if you look at the probeinterface probe definition here, you will see that it includes shank_ids starting on line 19,570.

Is there a way to fix this?

PS–sorry for the bad code formatting. Can’t get GitHub to behave.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

That makes sense from our perspective. Thanks Alessio. My only concern with giving the option is whether users will know when it matters or not and get confused thinking that by saying to write it that it is actually doing something (when I’m pretty sure for some versions the kcoords stop being used).