I am using mne version 3.10.10 on Windows 10
I am performing an EEG connectivity studi on resting state EEG, but i am not an expert.
When developing my code for the preprocessing and feature extraction, I got following error code when using the code below. MNE was successful in computing the first connectivity matrix but when starting the second one it gives this weird error and i really donβt know what is happening.
I always get this error if i run the command spectral_connectivity_epochs more than once!
Can someone help me?
Lots of thanks from a Thesis Student!
ps: label_ts β labeled time series data per epoch with respect to a parcellation of the brain (Freesurfer aparc 69 parcelation)
conn = []
indices = ([0, 0, 0, 0, 0], [1, 2, 3, 4, 5])
for method in ['pli', 'wpli', 'dpli']:
conn.append(
spectral_connectivity_epochs(
label_ts,
method = method,
sfreq = sfreq,
indices = indices,
faverage = True,
n_jobs = 1
).get_data()[:,0]
)
conn
THE ERROR message!!!
computing connectivity for epoch 166 [done] [Connectivity computation done]
Connectivity computation...
--------------------------------------------------------------------------- UnboundLocalError Traceback (most recent call last)
Cell In[50], line 5
indices = ([0, 0, 0, 0, 0], [1, 2, 3, 4, 5])
for method in ['pli', 'wpli', 'dpli']:
conn.append( ---->
spectral_connectivity_epochs(
label_ts,
method = method,
sfreq = sfreq,
indices = indices,
faverage = True,
n_jobs = 1
).get_data()[:,0]
)
conn
File :12, in spectral_connectivity_epochs(data, names, method, indices, sfreq, mode, fmin, fmax, fskip, faverage, tmin, tmax, mt_bandwidth, mt_adaptive, mt_low_bias, cwt_freqs, cwt_n_cycles, block_size, n_jobs, verbose)
File [c:\Users\arons\anaconda_New3\envs\mne\lib\site-packages\mne_connectivity\spectral\epochs.py:1126](file:///C:/Users/arons/anaconda_New3/envs/mne/lib/site-packages/mne_connectivity/spectral/epochs.py:1126), in spectral_connectivity_epochs(data, names, method, indices, sfreq, mode, fmin, fmax, fskip, faverage, tmin, tmax, mt_bandwidth, mt_adaptive, mt_low_bias, cwt_freqs, cwt_n_cycles, block_size, n_jobs, verbose)
1124 # compute final connectivity scores
1125 con = list() ->
1126 for conn_method, n_args in zip(con_methods, n_comp_args):
1127 # future estimators will need to be handled here
1128 if n_args == 3:
1129 # compute all scores at once
1130 conn_method.compute_con(slice(0, n_cons), n_epochs)
UnboundLocalError: local variable 'con_methods' referenced before assignment