rb643 / resting_state_eeg

8 stars 5 forks source link

Bug in `spectral_connectivity` #5

Closed janfreyberg closed 7 years ago

janfreyberg commented 7 years ago

Looks like the MNE python function isn't quite ironed out 😞

See the error:

/Library/anaconda/envs/py36/lib/python3.6/site-packages/mne/connectivity/spectral.py in spectral_connectivity(data, method, indices, sfreq, mode, fmin, fmax, fskip, faverage, tmin, tmax, mt_bandwidth, mt_adaptive, mt_low_bias, cwt_frequencies, cwt_n_cycles, block_size, n_jobs, verbose)
    877     # compute final connectivity scores
    878     con = list()
--> 879     for method, n_args in zip(con_methods, n_comp_args):
    880         # future estimators will need to be handled here
    881         if n_args == 3:

UnboundLocalError: local variable 'con_methods' referenced before assignment
rb643 commented 7 years ago

That's frustrating! Do you need we might have missed a step in the pre-processing that is needed before you can run this?

rb643 commented 7 years ago

I mean it still has to go to the time-frequency domain before we can do wpli analyses, so does the connectivity function also include that step or do we need to do that first?

janfreyberg commented 7 years ago

I opened an issue there yesterday and someone already spotted what was wrong: https://github.com/mne-tools/mne-python/issues/4364#issuecomment-312287284

So we need to have n_jobs be smaller than the number of epochs. How many segments do you want to cut the recording into? And do you want to only work on the eyes open data, or also the eyes closed?

rb643 commented 7 years ago

Nice! Should have spotted that as it was the first thing I overlooked with the fieldtrip pipeline.. Normally I would actually only use the eye-closed segments as that limits the interference from eye-blinks :) Would be nice to see if that also decreases the number of excluded components actually.

There doesn't seem to be a golden rule on the length of the segments, but so far I have been using 4 second segment. There is only one paper that already did something similar and I think they used 2 seconds, but I think that somewhat limits the precision for lower frequencies as you only get a handful of datapoint for delta with such short segments..