SpikeInterface / SpikeInterface/spikeinterface

Artefacts are provided but label 0 has no value!

Open
#3,955 0 comments 0 reactions 1 assignee View on GitHub

@yger is already working on this.

Since May 27, 2025.

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

Description

Hi,

I'm doing preprocessing. I removed the artifacts and wanted to use kilosort4 to do spikesorting.

rec_removed = spre.remove_artifacts(recording=recording_cmr, list_triggers=laser_on_times, mode='median') sorting_KS4 = ss.run_sorter('kilosort4', recording=rec_removed) sorting_analyzer = si.create_sorting_analyzer(sorting_KS4, recording=rec_removed) sorting_analyzer.compute(['random+_spikes','templates','quality_metrics']) sexp.export_to_phy(sorting_analyzer, output_folder=f"{npx_path}/phy")

However, after the cell ran for an hour, an error occurred. I don't know how to fix it.

Thank you!


SpikeSortingError                         Traceback (most recent call last)
Cell In[7], line 1
----> 1 sorting_KS4 = ss.run_sorter('kilosort4', recording=rec_removed)
      2 sorting_analyzer = si.create_sorting_analyzer(sorting_KS4, recording=rec_removed)
      3 sorting_analyzer.compute(['random+_spikes','templates','quality_metrics'])

File c:\Users\username\anaconda3\envs\si_env\Lib\site-packages\spikeinterface\sorters\runsorter.py:198, in run_sorter(sorter_name, recording, folder, remove_existing_folder, delete_output_folder, verbose, raise_error, docker_image, singularity_image, delete_container_files, with_output, output_folder, **sorter_params)
    187             raise RuntimeError(
    188                 "The python `spython` package must be installed to "
    189                 "run singularity. Install with `pip install spython`"
    190             )
    192     return run_sorter_container(
    193         container_image=container_image,
    194         mode=mode,
    195         **common_kwargs,
    196     )
--> 198 return run_sorter_local(**common_kwargs)

File c:\Users\username\anaconda3\envs\si_env\Lib\site-packages\spikeinterface\sorters\runsorter.py:260, in run_sorter_local(sorter_name, recording, folder, remove_existing_folder, delete_output_folder, verbose, raise_error, with_output, output_folder, **sorter_params)
    258 SorterClass.setup_recording(recording, folder, verbose=verbose)
    259 # This NEEDS to happen in the docker because of dependencies
--> 260 SorterClass.run_from_folder(folder, raise_error, verbose)
    261 if with_output:
    262     sorting = SorterClass.get_result_from_folder(folder, register_recording=True, sorting_info=True)

File c:\Users\username\anaconda3\envs\si_env\Lib\site-packages\spikeinterface\sorters\basesorter.py:310, in BaseSorter.run_from_folder(cls, output_folder, raise_error, verbose)
    307         print(f"{sorter_name} run time {run_time:0.2f}s")
    309 if has_error and raise_error:
--> 310     raise SpikeSortingError(
    311         f"Spike sorting error trace:\n{error_log_to_display}\n"
    312         f"Spike sorting failed. You can inspect the runtime trace in {output_folder}/spikeinterface_log.json."
    313     )
    315 return run_time

SpikeSortingError: Spike sorting error trace:
Traceback (most recent call last):
  File "c:\Users\username\anaconda3\envs\si_env\Lib\site-packages\spikeinterface\sorters\basesorter.py", line 270, in run_from_folder
    SorterClass._run_from_folder(sorter_output_folder, sorter_params, verbose)
  File "c:\Users\username\anaconda3\envs\si_env\Lib\site-packages\spikeinterface\sorters\external\kilosort4.py", line 224, in _run_from_folder
    recording = cls.load_recording_from_folder(sorter_output_folder.parent, with_warnings=False)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\username\anaconda3\envs\si_env\Lib\site-packages\spikeinterface\sorters\basesorter.py", line 221, in load_recording_from_folder
    recording = load(json_file, base_folder=output_folder)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\username\anaconda3\envs\si_env\Lib\site-packages\spikeinterface\core\loading.py", line 100, in load
    return _load_object_from_dict(d, object_type, base_folder=base_folder)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\username\anaconda3\envs\si_env\Lib\site-packages\spikeinterface\core\loading.py", line 175, in _load_object_from_dict
    return BaseExtractor.from_dict(d, base_folder=base_folder)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\username\anaconda3\envs\si_env\Lib\site-packages\spikeinterface\core\base.py", line 567, in from_dict
    extractor = _load_extractor_from_dict(dictionary)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\username\anaconda3\envs\si_env\Lib\site-packages\spikeinterface\core\base.py", line 1123, in _load_extractor_from_dict
    extractor = extractor_class(**new_kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\username\anaconda3\envs\si_env\Lib\site-packages\spikeinterface\preprocessing\remove_artifacts.py", line 166, in __init__
    assert l in artifacts.keys(), f"Artefacts are provided but label {l} has no value!"
           ^^^^^^^^^^^^^^^^^^^^^
AssertionError: Artefacts are provided but label 0 has no value!

Spike sorting failed. You can inspect the runtime trace in c:\Users\username\Desktop\Code\Functions\kilosort4_output/spikeinterface_log.json.

spikeinterface_log.json

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.