SpikeInterface / spikeinterface

A Python-based module for creating flexible and robust spike sorting pipelines.
https://spikeinterface.readthedocs.io
MIT License
493 stars 188 forks source link

unable to detect channels outside of brain with `detect_bad_channels` #2929

Open a-zmz opened 3 months ago

a-zmz commented 3 months ago

Hi,

I tried to remove bad channels of my neuropixels 1.0 data, and the detect_bad_channels function could not detect any channels outside of brain no matter parameters...

key questions:

ps. running spikeinterface v0.101.0 on linux fedora 39

Thanks!

zm711 commented 3 months ago

@a-zmz,

we are at a hackathon right now for spikeinterface. We will try to get to this soon! Ping us again Monday if we haven't responded before then, please!

a-zmz commented 2 months ago

hello again guys, any update on this?

JoeZiminski commented 2 months ago

Thanks @a-zmz, this is interesting, Can I confirm, when you supply the raw data the bad channel detection works well, but if you bandpass filter the data, then it does not work?

This actually may not be so suprising, the data must be filtered for bad channel detection to work. If raw data is passed, it will be filtered internally in the function. Both this internal filtering (and the filtering applied in the IBL pipeline from which this is ported) are highpass filters. It may be that the bandpass filter is removing high frequencies that would indicate these are noisy channels in the ibl function. Out of interst, could you see if, when the detection is working, these channels are labelled as noisy (2) or out of brain (3)?

I think if it is working without bandpass filtering, I would detect bad channels on the 'raw' data (technically, on the highpass filtered data under the hood) and then do bandpass filtering. This is a point for #2996, in general it is probably not idea to perform detect bad channels after bandpass filtering? @oliche may be able to comment better.

a-zmz commented 2 months ago

hello @JoeZiminski, yea i realised the highpass filtering in the bad channel detection function. When passing raw to the function, i got those channels are labelled as noisy. And yea from now I would do the bad channel detection before bandpass filtering. Thanks very much!

re question about detecting out_of_brain channels if I have 48 channels shifted up:

alejoe91 commented 2 months ago

The depths of the channels are used already, so top and bottom refer to the physical locations, not the channel indices ;)

a-zmz commented 2 months ago

oh right i see, then i should just use top if channels outside are further away from the shank tip? But like i tried different options with the location, none of the channels were detected as out_of_brain, is there something else i could try?

alejoe91 commented 2 months ago

yes top is correct. You can try to play around with the outside_channel_threshold parameter. @oliche any other suggestions?