LorenFrankLab / spyglass

Neuroscience data analysis framework for reproducible research built by Loren Frank Lab at UCSF
https://lorenfranklab.github.io/spyglass/
MIT License
94 stars 43 forks source link

waveform extractor issue with keyword 'sparse' #1127

Closed rpswenson closed 2 months ago

rpswenson commented 2 months ago

Describe the bug waveform extractor gets multiple values for keyword 'sparse' when populating MetricCuration

To Reproduce

m_key = {'metric_curation_id': '3dc95e6f-b642-402c-a307-e196b1d614b6', 
         'sorting_id': '25ce23bd-cbb5-462c-ba1b-2306b61c229f', 'curation_id': 0, 'waveform_param_name': 'default_whitened_20000spikes_20jobs_v3', 
         'metric_param_name': 'peak_offset_num_spikes_20000spikes_v2', 'metric_curation_param_name': 'noise0.03_isi0.0025_offset2'}
sgs.MetricCuration.populate(m_key)

Error stack

Cell In[53], line 4
      1 m_key = {'metric_curation_id': '3dc95e6f-b642-402c-a307-e196b1d614b6', 
      2          'sorting_id': '25ce23bd-cbb5-462c-ba1b-2306b61c229f', 'curation_id': 0, 'waveform_param_name': 'default_whitened_20000spikes_20jobs_v3', 
      3          'metric_param_name': 'peak_offset_num_spikes_20000spikes_v2', 'metric_curation_param_name': 'noise0.03_isi0.0025_offset2'}
----> 4 sgs.MetricCuration.populate(m_key)

File ~/spyglass/src/spyglass/utils/dj_mixin.py:615, in SpyglassMixin.populate(self, *restrictions, **kwargs)
    613 else:  # No transaction protection, use bare make
    614     for key in keys:
--> 615         self.make(key)
    616     if upstream_hash != self._hash_upstream(keys):
    617         (self & keys).delete(safemode=False)

File ~/spyglass/src/spyglass/spikesorting/v1/metric_curation.py:266, in MetricCuration.make(self, key)
    263 os.makedirs(waveforms_dir, exist_ok=True)
    265 logger.info("Extracting waveforms...")
--> 266 waveforms = si.extract_waveforms(
    267     recording=recording,
    268     sorting=sorting,
    269     sparse=waveform_params.get("sparse", False),
    270     folder=waveforms_dir,
    271     overwrite=True,
    272     **waveform_params,
    273 )
    274 # compute metrics
    275 logger.info("Computing metrics...")

TypeError: spikeinterface.core.waveform_extractor.extract_waveforms() got multiple values for keyword argument 'sparse'

Expected behavior I assume waveform extractor should get 1 value for sparse

samuelbray32 commented 2 months ago

Yup this is a bug. This line gets a value (with False default) for sparse, but doesn't remove it from waveform_params so it gets put in again here