spikedetekt bug for sparsely spiking channels

70 views
Skip to first unread message

Michael Trumpis

unread,
Feb 21, 2017, 11:38:58 AM2/21/17
to phy-users
Hi all,

I'm getting this exception in the "Computing features" step of a "klusta --detect-only ..." run:

AttributeError: 'NoneType' object has no attribute 'dtype'

It appears that this problem is a result of a channel group with sparse threshold-crossings.

The relevant part of the traceback is pasted at the end here, and it goes back to the last few steps in run_serial().  I poked into pdb a bit and the problem seems to lie in extracting *subsets* of channel-group spikes on which to train a PCA transform.  Here, _iter_spikes() keeps only a fraction of the threshold-crossings, which has led to at least one of my channel groups being missed entirely. I.e., w_subset[channel] == None, and subsequently pcs[channel] == None.

Next, in step_extract() *all* threshold-crossings are considered and projected. However, there is no projection where pcs[channel] == None and the PCA.transform() inadvertently returns None.  (The implicit return is invoked, since "if pcs is not None" evaluates False.)  That brings me to the AttributeError.

It seems to me that I could either skip fewer samples before learning projections, or I could just leave out the sparsely spiking channel groups.  In the latter case, can I simply skip "storing" samples from the bad group in step_extract()?  BTW lower the strong threshold also avoids the exception, but that's lame.

Many thanks,
Mike


  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/klusta/launch.py", line 65, in detect
    out = sd.run_serial(traces, interval_samples=interval_samples)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/klusta/traces/spikedetekt.py", line 709, in run_serial
    self.step_extract(n_samples=n_samples, pcs=pcs, thresholds=thresholds)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/klusta/traces/spikedetekt.py", line 656, in step_extract
    out['features'] = self.features(out['waveforms'], pcs[group])
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/klusta/traces/spikedetekt.py", line 451, in features
    assert out.dtype == np.float32
AttributeError: 'NoneType' object has no attribute 'dtype'

Cyrille Rossant

unread,
Feb 22, 2017, 3:42:40 AM2/22/17
to Michael Trumpis, phy-users
Hi
thanks for the bug report! It seems like there would be an easy fix for this particular case, would you consider proposing a pull request on the klusta repo on GitHub?
Thank you
Cyrille

--
You received this message because you are subscribed to the Google Groups "phy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phy-users+unsubscribe@googlegroups.com.
To post to this group, send email to phy-...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/phy-users/5a1445bf-3a49-4d0e-a2ff-57619847784e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Trumpis

unread,
Feb 22, 2017, 8:58:07 AM2/22/17
to phy-users
Yes, simply skipping the computation of features and storing results works for my purposes.  This is what the resulting kwik file looks like: channel 15 has no spikes field

In [6]: c15 = f.get_node('/channel_groups/15')

In [7]: c15
Out[7]:
/channel_groups/15 (Group) ''
  children := ['channels' (Group)]

In [8]: c15.channels
Out[8]:
/channel_groups/15/channels (Group) ''
  children := ['15' (Group)]

In [9]: c16 = f.get_node('/channel_groups/16')

In [10]: c16
Out[10]:
/channel_groups/16 (Group) ''
  children := ['channels' (Group), 'spikes' (Group)]

In [11]: c16.spikes
Out[11]:
/channel_groups/16/spikes (Group) ''
  children := ['recording' (Array), 'time_fractional' (Array), 'time_samples' (Array)]



Again from my perspective, this result is fine, but I don't know what it might break downstream.  I am running "detect-only" in klusta because (so far) I don't have any reason to think that spike sorting is appropriate for my dataset.

I will post the pull request now.

cheers
Mike
To unsubscribe from this group and stop receiving emails from it, send an email to phy-users+...@googlegroups.com.

Dun Mao

unread,
May 10, 2018, 12:39:52 PM5/10/18
to phy-users
Hello,

I've encountered the same problem. Has there been a fix except lowering the strong thresholds?

Thanks,
Dun
To unsubscribe from this group and stop receiving emails from it, send an email to phy-users+...@googlegroups.com.

Michael Trumpis

unread,
May 18, 2018, 3:03:45 PM5/18/18
to phy-users
The partial fix is about one line of code (see this pull-request https://github.com/kwikteam/klusta/pull/34/files).

I say partial because there was some intricate down-stream breakage when trying to open the resulting datasets in KlustaViewa. On the other hand, I found that "phy kwik-gui" worked correctly (just ignored the channel or shank, I think).
 
I guess this PR never landed on master, but you can merge it to your code in any case to get unstuck.

You received this message because you are subscribed to a topic in the Google Groups "phy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phy-users/qVpvbvJ6OTA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phy-users+unsubscribe@googlegroups.com.

To post to this group, send email to phy-...@googlegroups.com.

Dun Mao

unread,
May 18, 2018, 3:35:35 PM5/18/18
to phy-users
Thank you, Michael!
To unsubscribe from this group and all its topics, send an email to phy-users+...@googlegroups.com.

To post to this group, send email to phy-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages