nbara / python-meegkit

🔧🧠 MEEGkit: MEG & EEG processing toolkit in Python
https://nbara.github.io/python-meegkit/
BSD 3-Clause "New" or "Revised" License
182 stars 50 forks source link

dss_line_iter error #59

Closed cocomahe closed 2 years ago

cocomahe commented 2 years ago

Hi, thanks for your handy package! firstly i am new to eeg processing and programming, hence sorry if its a stupid question i just cant get solved.

i use the dss_line_iter function to get rid of line noise artefact but get thrown following error:

UnboundLocalError: local variable 'mean_psd' referenced before assignment in the following: File "/home/analysis/anaconda3/lib/python3.9/site-packages/meegkit/dss.py", line 316, in dss_line_iter mean_psd_wospot = mean_psd.copy()

the dss_line function without iter works fine.

Thanks for help!

nbara commented 2 years ago

Hi @cocomahe, thanks for reporting. I will have a look this week.

nbara commented 2 years ago

What is the shape of the data you input to dss_line_iter() ?

def dss_line_iter(data, fline, sfreq, win_sz=10, spot_sz=2.5,
                  nfft=512, show=False, prefix="dss_iter", n_iter_max=100):
    """Remove power line artifact iteratively.

    Parameters
    ----------
    data : data, shape=(n_samples, n_chans, n_trials)
        Input data.

It is probably not the expected shape or number of dimensions.

cocomahe commented 2 years ago

Hi, thanks for quick response! In deed it works with an adjusted shape. I was confused as the single channel data works with dss_line() but not with dss_line_iter(). However all channel data work fine with both, which makes so much sense^^ Thanks!

nbara commented 2 years ago

No worries, I'll try to throw a more helpful error message to avoid the confusion in the future