How to eliminate potential AC noises?
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.
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
It's a little bit weird... I have put most of the details on slack.
It would be helpful to look at the spectra though (couldn't find them on slack)
Here comes the spectra!
First I plot the traces and there are periodic patterns:
After that, I plot the spectra of some of the elecs:
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...
These are PSDs
@DaohanZhang
Can you try a notch filter where you have the peak (~5000Hz) and see if it improves the situation?
Any word on trying Alessio's tip @DaohanZhang ?
Some collaborators have had good results from https://github.com/MariusKlug/zapline-plus although it is Matlab and I haven't tried it personally
@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
After zapline plus
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.