Closed adam2392 closed 1 year ago
@pedro3714 reposting here as a GH issue
Also, if you want to format the code to make it easier to read.
single enclosed brackets ` makes a code line triple enclosed brackets ``` makes a code section
E.g.
code line
code section
...
@adam2392 thank you! How can i edit it?
Hi,
The issue seems to be related to f_vec
not being defined if the input parameters freqs
is None in the function spectral_connectivity_time
f_vec
is not defined outside the if condition if freqs is not None:
at https://github.com/mne-tools/mne-connectivity/blob/58f33c0abc0441315b8bc6b394c432a62c1da692/mne_connectivity/spectral/time.py#L169
And this would raise an error at https://github.com/mne-tools/mne-connectivity/blob/58f33c0abc0441315b8bc6b394c432a62c1da692/mne_connectivity/spectral/time.py#L199
Ah I see, so yea the function will require some bit of refactoring and additional testing.
There is still an issue to be sorted out in #73 where there is a discussion going on as to how to best implement time-resolved spectral connectivity. Unfortunately, I am out of depth there, and cannot be of much help unless someone explains things to me :p.
FYI I also encountered this bug, came here, and see #73 is blocking
Hi @szerfas1 yes, unfortunately I do not have enough time/expertise to handle this specific related line of work with time-resolved spectral connectivity.
Hoping a community member is interested in doing some OSS work and being a contributor to the MNE ecosystem :)
@adam2392 ...Perhaps the implementation in HyPyP may help? To compute connectivity, they obtain the complex signal from a time-resolved spectral computation (e.g., Time-freq with multi-tapers , or Hilbert), and use those to compute what is needed depending on the connectivity metric (e.g., real part, imaginary part, cross-spectral density -complex conjugate multiplication, etc). This is implemented in compute_sync
"Hello everyone,
I’m currently using MNE connectivity to perform a functional connectivity analysis in a single epoch. With this said, I’ve read some threads where concerns were raised about using spectral_connectivity/spectral_connectivity_epochs on a single epoch.In such case we are advised to perform a time spectral connectivity analysis on the epoch. As my goal is to obtain connectivity in the following structure-(n_nodes,n_nodes,n_freqs), I tried to use the follwing functions: spectral_connectivity_time with mode=“multitaper”, SpectralConnectivity and EpochSpectralConnectivity. The code snippets are provided below and contain also the errors. At the snippets we only try to analyze theta and alpha freqs and the df_V[“data_ref”][0] represent a session of neurofeedback training in visual modality. Notice that this df_V[“data_ref”][0] is composed by 30 epochs so we are using the index 0 to access to the first epoch.
Thank you all, Best Regards
MNE version: 0.24.1 -MNE connectivity version: 0.4.dev0 operating system: Windows 10 Option 1: spectral_connectivity_time
This raises an error on spectral connectivity time- UnboundLocalError: local variable ‘f_vec’ referenced before assignment. Notice that i tried using freqs instead of foi but i gaves me also errors.
Option 2: SpectralConnectivity function. In this case the error seems to be the parameters of the input array as it asks for a list/ [ np.ndarray ] with the following structure [epochs], n_estimated_nodes, [freqs], [times]). As my array has only 3 dimension (with the third being times), it gives me an error like the one below. It seems that he is considering the data as beeing on the frequency domain.
This last error seems to apply also to the function- EpochSpectralConnectivity
Originally posted by @pedro3714 in https://github.com/mne-tools/mne-connectivity/issues/73#issuecomment-1075391829