I am trying to measure event-related potentials.
Preliminary experiments have shown that there is too much AC noise, so I am thinking of removing it.
What code should I write to remove it?
It is about the line noise. I wrote AC noise because I think it is caused by AC power supply.
I am wondering how to write the code to remove this in MNEPython.
Sorry for being a beginner.
What do you mean by PSD?
Sorry for the lack of explanation.
Thank you in advance.
PSD = Power Spectral Density. Let’s start by confirming that your data is contaminated by powerline noise, 50 Hz in Europe, 60 Hz in the US (and I don’t know elsewhere).
As you can see, there is no powerline noise. You do not have a peak at 50 Hz or 60 Hz.
Also, the dataset seems to be bandpass filtered between 1 and 20 Hz. The peak at 20 Hz looks weird to me.
Could you do the same plot on the raw data before BP filter?
I have no idea what can cause noise at 20 Hz. If someone know, I’m very curious.
Anyway, you can apply a notch for 20 Hz and the harmonics. This way, you will also be able to increase your BP upper limit to more than 20 Hz if you want:
import numpy as np
raw = [...] # load data
raw.notch_filter(np.arange(20, 120, 20))
That’s what a filter does, it looks OK. I prefer to avoid using notch filters, but I don’t see another solution in your case.
Alternatively, you should figure out where this noise is coming from, remove the source, and record clean data.
One thing to check is if the sampling frequency was somehow mis-specified, so that interference at 50 Hz was showing up as if it were 20 Hz. I don’t know how this would have happened though so it’s a wild guess.
Another possibility is that it’s a coming from equipment in an adjacent lab in the same building. I’ve seen this once, it was coming through on an audio recording in a sound-attenuated booth. It was a timing signal for some custom physics equipment, and it was exactly 1kHz. (at 20 Hz this is almost surely not a timing signal but may still be caused by nearby equipment)