SpikeInterface / SpikeInterface/spikeinterface

mda extractors failed when sorting concatenated files

Open
#2,532 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi I want to sort my concatenate .mda files which loaded using concatenate_recordings. I used mountainsort 5 and load the sorter using run_sorter My concatenated recording is like the following

ConcatenateSegmentRecording: 128 channels - 30.0kHz - 1 segments - 78,947,056 samples
2,631.57s (43.86 minutes) - int16 dtype - -1264390144.00 B
C:\Users\xiela\anaconda3\Lib\site-packages\spikeinterface\core\baserecording.py:222: RuntimeWarning: overflow encountered in scalar multiply
memory_bytes = num_samples * num_channels * dtype_size_bytes

After running the sorter, there is an error from the mdaextractor.py

File ~\anaconda3\Lib\site-packages\spikeinterface\sorters\basesorter.py:289 in run_from_folder
raise SpikeSortingError(

SpikeSortingError: Spike sorting error trace:
Traceback (most recent call last):
File "C:\Users\xiela\anaconda3\Lib\site-packages\spikeinterface\sorters\basesorter.py", line 254, in run_from_folder
SorterClass._run_from_folder(sorter_output_folder, sorter_params, verbose)
File "C:\Users\xiela\anaconda3\Lib\site-packages\spikeinterface\sorters\external\mountainsort5.py", line 176, in _run_from_folder
sorting = ms5.sorting_scheme2(recording=recording, sorting_parameters=scheme2_sorting_parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xiela\anaconda3\Lib\site-packages\mountainsort5\schemes\sorting_scheme2.py", line 74, in sorting_scheme2
training_recording = get_sampled_recording_for_training(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xiela\anaconda3\Lib\site-packages\mountainsort5\core\get_sampled_recording_for_training.py", line 44, in get_sampled_recording_for_training
traces_list.append(recording.get_traces(start_frame=start_frame, end_frame=end_frame))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xiela\anaconda3\Lib\site-packages\spikeinterface\core\baserecording.py", line 282, in get_traces
traces = rs.get_traces(start_frame=start_frame, end_frame=end_frame, channel_indices=channel_indices)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xiela\anaconda3\Lib\site-packages\spikeinterface\preprocessing\whiten.py", line 107, in get_traces
traces = self.parent_recording_segment.get_traces(start_frame, end_frame, slice(None))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xiela\anaconda3\Lib\site-packages\spikeinterface\preprocessing\common_reference.py", line 146, in get_traces
all_traces = self.parent_recording_segment.get_traces(start_frame, end_frame, slice(None))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xiela\anaconda3\Lib\site-packages\spikeinterface\preprocessing\filter.py", line 130, in get_traces
traces_chunk, left_margin, right_margin = get_chunk_with_margin(
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xiela\anaconda3\Lib\site-packages\spikeinterface\core\recording_tools.py", line 232, in get_chunk_with_margin
traces_chunk = rec_segment.get_traces(
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xiela\anaconda3\Lib\site-packages\spikeinterface\core\segmentutils.py", line 187, in get_traces
traces = rec_seg.get_traces(start_frame - seg_start, end_frame - seg_start, channel_indices)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xiela\anaconda3\Lib\site-packages\spikeinterface\extractors\mdaextractors.py", line 174, in get_traces
recordings = recordings[channel_indices, :].T
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

Spike sorting failed. You can inspect the runtime trace in E:\EBL data\tracking_me\Processed_01-Mar-2024_221810\sorting/spikeinterface_log.json.

I used the same workflow with other binary format of data and works fine. Probably the issue relates to the mdaextractor which need some modifications? Thank you so much for your help.

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

Start by reproducing the failure with concatenate_recordings and run_sorter, then inspect spikeinterface/extractors/mdaextractors.py alongside the get_traces calls in baserecording.py and segmentutils.py. Determine why the MDA extractor returns None for the traced channel access and add a regression test covering the concatenated recording workflow; done means the workflow no longer raises this TypeError.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.