I wrote a function to clean line noise using zapline method from MEEGkit toolbox to use in MNE with RawArray data:
def zapline_clean(raw, fline):
data = raw.get_data() # Convert mne data to numpy darray
sfreq = raw.info['sfreq'] # Extract the sampling freq
#Apply MEEGkit toolbox function
out, _ = dss.dss_line(data, fline, sfreq, nkeep=1) # fline (Line noise freq) = 50 Hz for Europe
cleaned_raw = mne.io.RawArray(out, raw.info) # Convert output to mne RawArray again
return cleaned_raw
To implement this function I use:
cleaned_raw = zapline_clean(raw, 50)
Number 50 is the fline value (50hz line noise in europe)
However, I have a problem when I use this function. This appears in the console: βReducing nfft to 32β and then the Python interpreter crashes. Has anyone tried doing something similar?