SpikeInterface / SpikeInterface/spikeinterface

Extra neo kwarg for BioCAM's event-based compression not passed to SpykingCircus2

Open
#4,006 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Recently, support for BioCAM's event-based compression was added to neo.

It requires the user to decide between filling the gaps in recordings with zeros or artificial noise, specified by fill_gaps_strategy in SI.

When running SpykingCircus2 on compressed data, it looks like this kwarg isn't passed properly to the internal filtering functions.

I'm running the following :

recording = se.read_biocam(data_path,
                           mea_pitch=60,
                           electrode_width=21,
                           fill_gaps_strategy="synthetic_noise",
                           ) 

recording = recording.remove_channels('1')
recording = spre.unsigned_to_signed(recording, bit_depth=12)

sorting = ss.run_sorter(
    sorter_name="spykingcircus2", recording=recording,
    folder=str(output_folder / "sc2_output"),verbose=True, **p,
)

HerdingSpikes2 runs just fine on the same file, so this seems to be sorter-specific.

Here's the full trace :

Error running spykingcircus2                                                                                                                      
Traceback (most recent call last):                                                                                                                
  File "/home/user/Documents/ephy/sc_si.py", line 60, in <module>                                                                                
    sorting = ss.run_sorter(                                                                                                                      
              ^^^^^^^^^^^^^^                                                                                                                      
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/sorters/runsorter.py", line 198, in run_sorter                             
    return run_sorter_local(**common_kwargs)                                                                                                      
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                      
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/sorters/runsorter.py", line 260, in run_sorter_local                       
    SorterClass.run_from_folder(folder, raise_error, verbose)                                                                                     
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/sorters/basesorter.py", line 310, in run_from_folder                       
    raise SpikeSortingError(                                                                                                                      
spikeinterface.sorters.utils.misc.SpikeSortingError: Spike sorting error trace:                                                                   
Traceback (most recent call last):                                                                                                                
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/sorters/basesorter.py", line 270, in run_from_folder                       
    SorterClass._run_from_folder(sorter_output_folder, sorter_params, verbose)                                                                    
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/sorters/internal/spyking_circus2.py", line 172, in _run_from_folder        
    recording_w = whiten(recording_f, **whitening_kwargs)                                                                                         
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                         
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/core/core_tools.py", line 35, in source_class_or_dict_of_sources_classes   
    return source_class(*args, **kwargs)                                                                                                          
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                          
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/preprocessing/whiten.py", line 93, in __init__                             
    W, M = compute_whitening_matrix(                                                                                                              
           ^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                              
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/preprocessing/whiten.py", line 192, in compute_whitening_matrix            
    data, cov, M = compute_covariance_matrix(recording, apply_mean, regularize, regularize_kwargs, random_chunk_kwargs)                           
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                           
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/preprocessing/whiten.py", line 244, in compute_covariance_matrix           
    random_data = get_random_data_chunks(recording, concatenated=True, return_in_uV=False, **random_chunk_kwargs)                                 
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                 
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/core/recording_tools.py", line 608, in get_random_data_chunks              
    traces_chunk = recording.get_traces(                                 
                   ^^^^^^^^^^^^^^^^^^^^^                                 
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/core/baserecording.py", line 339, in get_traces                            
    traces = rs.get_traces(start_frame=start_frame, end_frame=end_frame, channel_indices=channel_indices)                                         
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                         
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/preprocessing/common_reference.py", line 183, in get_traces
    traces = self.parent_recording_segment.get_traces(start_frame, end_frame, slice(None))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/preprocessing/filter.py", line 162, in get_traces
    traces_chunk, left_margin, right_margin = get_chunk_with_margin(
                                              ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/core/recording_tools.py", line 854, in get_chunk_with_margin
    traces_chunk = rec_segment.get_traces(
                   ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/preprocessing/unsigned_to_signed.py", line 54, in get_traces
    traces = self.parent_recording_segment.get_traces(start_frame, end_frame, channel_indices)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/core/channelslice.py", line 101, in get_traces
    traces = self._parent_recording_segment.get_traces(start_frame, end_frame, parent_indices)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/Documents/GitHub/spikeinterface/src/spikeinterface/extractors/neoextractors/neobaseextractor.py", line 367, in get_traces
    raw_traces = self.neo_reader.get_analogsignal_chunk(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/Documents/GitHub/python-neo/neo/rawio/baserawio.py", line 1006, in get_analogsignal_chunk
    raw_chunk = self._get_analogsignal_chunk(block_index, seg_index, i_start, i_stop, stream_index, channel_indexes)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/Documents/GitHub/python-neo/neo/rawio/biocamrawio.py", line 148, in _get_analogsignal_chunk
    raise ValueError(
ValueError: Please set `fill_gaps_strategy` to 'zeros' or 'synthetic_noise'.

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 in spikeinterface/sorters/internal/spyking_circus2.py at the whitening call, then trace the filtering and recording access shown in the traceback through preprocessing/filter.py and neobaseextractor.py. Verify how sorter recording options are propagated to the Neo reader. Done means SpykingCircus2 can read BioCAM compressed data with the requested fill_gaps_strategy and the existing failure is covered by a relevant test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.