spikeinterface icon indicating copy to clipboard operation
spikeinterface copied to clipboard

How to eliminate potential AC noises?

Open David-H-Chang opened this issue 1 year ago • 11 comments

Hello everyone! I found my last NPX recording got polluted with some potential AC noises possibly due to poor GND and REF. Here are some of the noises after sorting with KS4, which is spikes approximately appeared at at 50Hz pulses. Is there any preprocess filters could eliminate such noises. I tried using notch_filter centered 50, 100 and 150Hz before default bandpass_filter, it just did not work. 0ecc14c3bf12ebd352303efe0510714 image

David-H-Chang avatar Nov 06 '24 11:11 David-H-Chang

Hi @DaohanZhang

Can you plot a spectrum of the traces? If the noise is localized, you can play with the q factor of the notch filter to broaden/narrow the notch band to try to remove most of the noise

alejoe91 avatar Nov 06 '24 11:11 alejoe91

It's a little bit weird... I have put most of the details on slack. image

David-H-Chang avatar Nov 06 '24 12:11 David-H-Chang

It would be helpful to look at the spectra though (couldn't find them on slack)

alejoe91 avatar Nov 06 '24 14:11 alejoe91

Here comes the spectra! First I plot the traces and there are periodic patterns: image After that, I plot the spectra of some of the elecs: image image image image image image image image image image image image

David-H-Chang avatar Nov 11 '24 14:11 David-H-Chang

Thanks, can you also plot the power spectrum density? It makes it easier to check for very localized noise sources. From the spectrograms, they seem quite distributed so a notch filter won't help much here...

alejoe91 avatar Nov 11 '24 14:11 alejoe91

image image image image image image image image image image These are PSDs

David-H-Chang avatar Nov 12 '24 15:11 David-H-Chang

@DaohanZhang

Can you try a notch filter where you have the peak (~5000Hz) and see if it improves the situation?

alejoe91 avatar Nov 21 '24 10:11 alejoe91

Any word on trying Alessio's tip @DaohanZhang ?

zm711 avatar Dec 04 '24 14:12 zm711

Some collaborators have had good results from https://github.com/MariusKlug/zapline-plus although it is Matlab and I haven't tried it personally

cwindolf avatar Dec 20 '24 16:12 cwindolf

@David-H-Chang @cwindolf, I have tried to clean the AC noise with zapline plus but did not get much luck. With the default parameters to remove 50 Hz noise, it was either not able to remove the noise at all or remove too much. There is another package called cleanline, but I doubt it will work. My gut feeling is that these two tools were optimised for EEG recording where the sampling rate is usually around 250 Hz to 500 Hz. During the analysis, zapline kept warning that the sampling rate of my dataset, 30k Hz, is too high. Below is an example of applying zapline to my dataset. Please feel free to let me know if you have any thought or how to tweak the parameters for spike sorting. Before zapline plus Image After zapline plus Image

chiyu1203 avatar May 29 '25 13:05 chiyu1203

You might try out the spikeinterface preprocessing function highpass_spatial_filter(). It has been used by the international brain lab to resolve certain presentations of line noise, and maybe your data will be similar enough to theirs that it could help.

Also, my coauthors' code is here: https://github.com/williamunoz/InterpolationAfterDREDge/, and there is some zapline-related code there, but I can't find a specific script for AP data. If you're working with LFP data then there is a script in there you could try.

cwindolf avatar May 29 '25 15:05 cwindolf