question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running `sc.compare_two_sorters` when one sorting contains units with a single spike throws error

See original GitHub issue

Seems like sorting.get_unit_spike_train returns just an int rather than a list when the unit has only one spike. The sortings are done with kilosort3 and loaded with se.read_kilosort.

@rly @alejoe91

Error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-5cce6323a10a> in <module>
      2                               sorting2=sorting_di,
      3                               sorting1_name='Raw',
----> 4                               sorting2_name='DI')

~/.local/lib/python3.7/site-packages/spikeinterface/comparison/paircomparisons.py in compare_two_sorters(*args, **kwargs)
    148 
    149 def compare_two_sorters(*args, **kwargs):
--> 150     return SymmetricSortingComparison(*args, **kwargs)
    151 
    152 

~/.local/lib/python3.7/site-packages/spikeinterface/comparison/paircomparisons.py in __init__(self, sorting1, sorting2, sorting1_name, sorting2_name, delta_time, sampling_frequency, match_score, chance_score, n_jobs, verbose)
    116                                           delta_time=delta_time,
    117                                           match_score=match_score, chance_score=chance_score,
--> 118                                           n_jobs=n_jobs, verbose=verbose)
    119 
    120     def get_matching(self):

~/.local/lib/python3.7/site-packages/spikeinterface/comparison/paircomparisons.py in __init__(self, sorting1, sorting2, sorting1_name, sorting2_name, delta_time, match_score, chance_score, n_jobs, verbose)
     34 
     35 
---> 36         self._do_agreement()
     37         self._do_matching()
     38 

~/.local/lib/python3.7/site-packages/spikeinterface/comparison/paircomparisons.py in _do_agreement(self)
     59         # common to GroundTruthComparison and SymmetricSortingComparison
     60         # spike count for each spike train
---> 61         self.event_counts1 = do_count_event(self.sorting1)
     62         self.event_counts2 = do_count_event(self.sorting2)
     63 

~/.local/lib/python3.7/site-packages/spikeinterface/comparison/comparisontools.py in do_count_event(sorting)
     78     """
     79     unit_ids = sorting.get_unit_ids()
---> 80     ev_counts = np.array([len(sorting.get_unit_spike_train(u)) for u in unit_ids], dtype='int64')
     81     event_counts = pd.Series(ev_counts, index=unit_ids)
     82     return event_counts

~/.local/lib/python3.7/site-packages/spikeinterface/comparison/comparisontools.py in <listcomp>(.0)
     78     """
     79     unit_ids = sorting.get_unit_ids()
---> 80     ev_counts = np.array([len(sorting.get_unit_spike_train(u)) for u in unit_ids], dtype='int64')
     81     event_counts = pd.Series(ev_counts, index=unit_ids)
     82     return event_counts

TypeError: len() of unsized object

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
khl02007commented, Apr 5, 2022

@alejoe91 sure I will try to submit a PR soon

0reactions
alejoe91commented, May 5, 2022

@alejoe91 yes it is. sorry for being slow on this issue. how do you think this should be fixed? seems like we should make kilosort extractor return only the units that have nonzero number of spikes?

I think we should make all sorters do that! We have a new function sorting.remove_empty_units() that selects only the units with nspikes>0. For spiketrains with 1 spike, the issue should be solved with https://github.com/SpikeInterface/spikeinterface/pull/617

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spike sorting comparison methods - SpikeInterface
SpikeInterface has a comparison module that can be used for three distinct use cases: compare a spike sorting output with a ground-truth dataset ......
Read more >
spikeinterface Sep 11, PDF Free Download - DocPlayer.net
Given the importance of spike sorting, much attention has been directed ... se.exdirrecordingextractor(exdir_file) throws the error, ----> 1 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found