SpikeInterface / SpikeInterface/spikeinterface

Kilosort 2.5 Index in position 1 exceeds array bounds. Index must not exceed 32.

Open
#4,118 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug in sorter
Dominant language
Python
Stars
847
Forks
280
Avg merge
3d 9h
Merged PRs (30d)
29

Description

I have a similar problem to #3204. Unlike the issue, I am currently using 32 channels.

recording = se.BinaryRecordingExtractor(file_paths=[path], sampling_frequency=30000, num_channels=32, dtype='int16')
probe = generate_linear_probe(num_elec=32, ypitch=100.0, contact_shapes="circle", contact_shape_params={"radius":5})
probe.set_device_channel_indices(np.arange(recording.get_num_channels()))
assert recording.get_num_channels() == 32
assert recording.get_channel_locations().shape == (32, 2)
recording = recording.set_probe(probe, in_place=False)

sorting_KS2_5 = ss.run_sorter(sorter_name="kilosort2_5", recording=recording, remove_existing_folder=True, 
    folder=dirname, verbose=True, do_correction=False, preclust_threshold=6, freq_min=200.)

I double checked that the number of channels (i.e., recording.get_num_channels()) is 32. However, I am facing an error that "----------------------------------------Index in position 1 exceeds array bounds. Index must not exceed 32.\u001b[?1l\u001b>"

spikeinterface_log.json shows:

{
    "sorter_name": "kilosort2_5",
    "sorter_version": "git-f2e570c61b6e",
    "datetime": "2025-08-25T20:20:52.738731",
    "runtime_trace": [
        "\u001b[?1h\u001b=",
        "< M A T L A B (R) >",
        "Copyright 1984-2024 The MathWorks, Inc.",
        "R2024a (24.1.0.2537033) 64-bit (glnxa64)",
        "February 21, 2024",
        "",
        "",
        "To get started, type doc.",
        "For product information, visit www.mathworks.com.",
        "",
        "\u001b[?1h\u001b=Time   0s. Computing whitening matrix..",
        "Getting channel whitening matrix...",
        "Channel-whitening matrix computed.",
        "Time   8s. Loading raw data and applying filters...",
        "Time 199s. Finished preprocessing 8493 batches.",
        "Drift correction DISABLED",
        "pitch is 100 um",
        "----------------------------------------Index in position 1 exceeds array bounds. Index must not exceed 32.\u001b[?1l\u001b>"
    ],
    "error": true,
    "error_trace": [
        "Traceback (most recent call last):",
        "  File \"/om2/user/jdhwang/anaconda3/envs/kilosort/lib/python3.9/site-packages/spikeinterface/sorters/basesorter.py\", line 270, in run_from_folder",
        "    SorterClass._run_from_folder(sorter_output_folder, sorter_params, verbose)",
        "  File \"/om2/user/jdhwang/anaconda3/envs/kilosort/lib/python3.9/site-packages/spikeinterface/sorters/external/kilosortbase.py\", line 217, in _run_from_folder",
        "    raise Exception(f\"{cls.sorter_name} returned a non-zero exit code\")",
        "  Exception: kilosort2_5 returned a non-zero exit code"
    ],
    "run_time": null
}

For your information, I am using spikeinterface version 0.103.0

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the shown ss.run_sorter("kilosort2_5", ...) configuration and inspect sorter_output_folder/spikeinterface_log.json. Trace the handoff through spikeinterface/sorters/basesorter.py and spikeinterface/sorters/external/kilosortbase.py, then verify that a 32-channel recording completes without the MATLAB array-bounds error.

Written by the indexing model from the issue text.

Assessment

Tech stack
matlab, python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.