magland / sortingview

Web app for viewing results of ephys spike sorting
Apache License 2.0
25 stars 8 forks source link

labbox recording extractor incompatibility with spikeinterface>0.90: whitening #153

Closed khl02007 closed 2 years ago

khl02007 commented 3 years ago

in the new spikeinterface, recordings need a get_num_segments but LabboxEphysRecordingExtractor doesn't have it so whitening throws error

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_665132/2974607477.py in <module>
----> 1 nd.common.SpikeSorting.populate([(nd.common.SpikeSortingSelection & {'nwb_file_name' : 'beans20190718_.nwb',
      2                                                               'sort_interval_name': 'beans_02_r1_10s'}).proj()])

~/miniconda3/envs/nwb_datajoint/lib/python3.8/site-packages/datajoint/autopopulate.py in populate(self, suppress_errors, return_exception_objects, reserve_jobs, order, limit, max_calls, display_progress, *restrictions)
    151                     self.__class__._allow_insert = True
    152                     try:
--> 153                         make(dict(key))
    154                     except (KeyboardInterrupt, SystemExit, Exception) as error:
    155                         try:

~/repos/nwb_datajoint/src/nwb_datajoint/common/common_spikesorting.py in make(self, key)
    897             filter_params = (SpikeSortingFilterParameters & key).fetch1('filter_parameter_dict')
    898             # TODO: turn SpikeSortingFilterParameters to SpikeSortingPreprocessingParameters and include seed, chunk size etc
--> 899             recording = st.preprocessing.whiten(recording, seed=0)
    900 
    901         print(f'\nRunning spike sorting on {key}...')

~/miniconda3/envs/nwb_datajoint/lib/python3.8/site-packages/spikeinterface/toolkit/preprocessing/whiten.py in whiten(*args, **kwargs)
     59 # function for API
     60 def whiten(*args, **kwargs):
---> 61     return WhitenRecording(*args, **kwargs)
     62 
     63 

~/miniconda3/envs/nwb_datajoint/lib/python3.8/site-packages/spikeinterface/toolkit/preprocessing/whiten.py in __init__(self, recording, **random_chunk_kwargs)
     23 
     24     def __init__(self, recording, **random_chunk_kwargs):
---> 25         random_data = get_random_data_chunks(recording, **random_chunk_kwargs)
     26 
     27         # compute whitening matrix

~/miniconda3/envs/nwb_datajoint/lib/python3.8/site-packages/spikeinterface/toolkit/utils.py in get_random_data_chunks(recording, num_chunks_per_segment, chunk_size, seed)
     15 
     16     chunk_list = []
---> 17     for segment_index in range(recording.get_num_segments()):
     18         length = recording.get_num_frames(segment_index)
     19         random_starts = np.random.RandomState(seed=seed).randint(0,

AttributeError: 'LabboxEphysRecordingExtractor' object has no attribute 'get_num_segments'
magland commented 3 years ago

We will need to wrap LabboxEphysRecordingExtractor in a new spikeinterface recording. Let's find a time to work on this.

On Monday, October 4, 2021, Kyu Hyun Lee @.***> wrote:

in the new spikeinterface, recordings need a get_num_segments but LabboxEphysRecordingExtractor doesn't have it so whitening throws error


AttributeError Traceback (most recent call last) /tmp/ipykernel_665132/2974607477.py in ----> 1 nd.common.SpikeSorting.populate([(nd.common.SpikeSortingSelection & {'nwb_filename' : 'beans20190718.nwb', 2 'sort_interval_name': 'beans_02_r1_10s'}).proj()])

~/miniconda3/envs/nwb_datajoint/lib/python3.8/site-packages/datajoint/autopopulate.py in populate(self, suppress_errors, return_exception_objects, reserve_jobs, order, limit, max_calls, display_progress, *restrictions) 151 self.class._allow_insert = True 152 try: --> 153 make(dict(key)) 154 except (KeyboardInterrupt, SystemExit, Exception) as error: 155 try:

~/repos/nwb_datajoint/src/nwb_datajoint/common/common_spikesorting.py in make(self, key) 897 filter_params = (SpikeSortingFilterParameters & key).fetch1('filter_parameter_dict') 898 # TODO: turn SpikeSortingFilterParameters to SpikeSortingPreprocessingParameters and include seed, chunk size etc --> 899 recording = st.preprocessing.whiten(recording, seed=0) 900 901 print(f'\nRunning spike sorting on {key}...')

~/miniconda3/envs/nwb_datajoint/lib/python3.8/site-packages/spikeinterface/toolkit/preprocessing/whiten.py in whiten(*args, kwargs) 59 # function for API 60 def whiten(*args, *kwargs): ---> 61 return WhitenRecording(args, kwargs) 62 63

~/miniconda3/envs/nwb_datajoint/lib/python3.8/site-packages/spikeinterface/toolkit/preprocessing/whiten.py in init(self, recording, random_chunk_kwargs) 23 24 def init(self, recording, random_chunk_kwargs): ---> 25 random_data = get_random_data_chunks(recording, **random_chunk_kwargs) 26 27 # compute whitening matrix

~/miniconda3/envs/nwb_datajoint/lib/python3.8/site-packages/spikeinterface/toolkit/utils.py in get_random_data_chunks(recording, num_chunks_per_segment, chunk_size, seed) 15 16 chunk_list = [] ---> 17 for segment_index in range(recording.get_num_segments()): 18 length = recording.get_num_frames(segment_index) 19 random_starts = np.random.RandomState(seed=seed).randint(0,

AttributeError: 'LabboxEphysRecordingExtractor' object has no attribute 'get_num_segments'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/magland/sortingview/issues/153, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4CIQAB7HKHMZERALJ7H23UFE5LVANCNFSM5FIQVUHA .

-- Sent from my phone

magland commented 3 years ago

See: https://github.com/magland/sortingview/pull/156