-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question on dss_line() usage #47
Comments
Hi @adswa ! Yeah clearly something is wrong here. Have you tried increasing the number of components to remove What are those huge peaks around 300 hz ? Those are no 60hz harmonics. If that doesn't work, I'd be interested to have a look at the data myself (if you don't mind sharing a file, or a part of it). |
I have, and it doesn't really change things. I do run into
They come from head position indicator coils for motion correction to reconstruct the subjects head position. From skimming through the code, I thought the low pass filter that I think happens within Line 188 in a0c0561
would result in them being ignored; I could try again with low-pass filtered data to see if that makes a difference.
Sure, thanks much for taking a look! The data is quite large, so I've cropped a 500s snippet (which still is quite a chunk). You can download it here: https://we.tl/t-9mLnVNLHDQ (the link will be invalid after a short while)
I quickly tried using only one type of channels (mag), but didn't have much success either: |
I'll have a look. There's at least a couple of reasons I can think of. Btw, just a quick comment,
|
Thanks a lot for the tip! |
I can confirm that that was part of the problem. The other problem seems to be that your 60hz peak is not really at 60hz. Using 61Hz works well I think. Here's the code I used: import mne
import matplotlib.pyplot as plt
from meegkit.dss import dss_line
raw = mne.io.read_raw('./examples/sub-xxx_task-memento_proc-sss_meg.fif', preload=True)
# First problem : be careful how you pick your data from Raw objects
print(f'raw._data shape: {raw._data.shape}')
data = raw.get_data(picks=['meg'])
print(f'raw.get_data() shape: {data.shape}')
raw.crop(60, 260) # we don't need that much signal
# Only take MEG channels (same as raw.get_data(picks=['meg']))
meg_ch_idx = mne.pick_types(raw.info, meg=True)
data = raw.get_data(picks=meg_ch_idx)
# Second problem: the peak seems to be closer to 61 hz
clean, artifact = dss_line(data.T, fline=61, sfreq=1000, nremove=10)
# Plot before/after
f, ax = plt.subplots(2, 2)
raw.plot_psd(ax=ax[0, :], show=False, fmin=1, fmax=150)
raw._data[meg_ch_idx] = clean.T # put clean data back in raw
raw.plot_psd(ax=ax[1, :], show=True, fmin=1, fmax=150) |
Oh, wow... I should have checked 🤦 - thanks so much for taking a look and helping out, really appreciated! |
Sure, happy to help! |
Hi, its awesome that there is an implementation of the ZAPline algorithm in Python! I'm trying to use it, but I somehow fail to remove the noise components with it. I'm convinced that I must be doing something obvious wrong - any idea what it may be?
I'm using Elekta MEG data (322 MEG channels, after Signal Space Separation) that show an artifact at 60Hz stemming from a presentation display.
Here is its PSD:
Here's the code I am running:
Putting the data back into the MNE Raw Object and visualizing the psd plot shows an almost identical profile, with the 60Hz component being pretty much unaffected.
Any idea what I might be doing wrong here?
Thanks much in advance!
The text was updated successfully, but these errors were encountered: