[Mne_analysis] How to get coherence between stc files?

Eric Larson larson.eric.d at gmail.com
Thu Jun 15 13:37:15 EDT 2017
Search archives:

After this line:

stcs=np.concatenate((stc_1.data,stc_2.data),axis=0)

​
You will have stcs.shape == (40968, n_times).

However, for `spectral_connectivity`, the `data` argument needs to be of
shape (n_epochs, n_signals, n_times), i.e. you need multiple epochs/trials.
Here you appear to only have 1.

HTH,
Eric


On Thu, Jun 15, 2017 at 11:53 AM, Maria Hakonen <maria.hakonen at gmail.com>
wrote:

> Dear mne experts,
>
> In an example “Compute coherence in source space using a MNE inverse
> solution” mne.connectivity.spectral_connectivity is used to compute the
> coherence between a seed in the left auditory cortex and the rest of the
> brain based on single-trial MNE-dSPM inverse solutions. However, I would
> like to use mne.connectivity.spectral_connectivity to compute the
> coherence between two stc files measured in two different conditions.
>
> I have tried to do this as follows:
> stcs=np.concatenate((stc_1.data,stc_2.data),axis=0)
> stcs=stcs.tolist()
> indices=(np.arange(1,20484),np.arange(20485,40968)) (I would like to get
> the coherence between each vertex in stc1 and the corresponding vertices in
> stc2)
> coh, freqs, times, n_epochs, n_tapers = spectral_connectivity(
>     stcs, method='coh', mode='fourier', indices=indices,
>     sfreq=sfreq, fmin=fmin, fmax=fmax, faverage=True, n_jobs=1)
>
> However, I get:
>
> Connectivity computation...
> ------------------------------------------------------------
> ---------------
> AttributeError                            Traceback (most recent call last)
> <ipython-input-40-139613d5f602> in <module>()
>       1 coh, freqs, times, n_epochs, n_tapers = spectral_connectivity(
>       2     stcs, method='coh', mode='fourier', indices=indices,
> ----> 3     sfreq=sfreq, fmin=fmin, fmax=fmax, faverage=True, n_jobs=1)
>
> /share/apps/mne/mne-python/python2.7/lib/python2.7/site-
> packages/mne-0.11.dev0-py2.7.egg/mne/connectivity/spectral.pyc 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)
>
> /share/apps/mne/mne-python/python2.7/lib/python2.7/site-
> packages/mne-0.11.dev0-py2.7.egg/mne/utils.pyc in verbose(function,
> *args, **kwargs)
>     549         finally:
>     550             set_log_level(old_level)
> --> 551     return function(*args, **kwargs)
>     552
>     553
>
> /share/apps/mne/mne-python/python2.7/lib/python2.7/site-
> packages/mne-0.11.dev0-py2.7.egg/mne/connectivity/spectral.pyc 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)
>     772             # get the data size and time scale
>     773             n_signals, n_times_in, times_in = \
> --> 774                 _get_and_verify_data_sizes(first_epoch)
>     775
>     776             if times_in is None:
>
> /share/apps/mne/mne-python/python2.7/lib/python2.7/site-
> packages/mne-0.11.dev0-py2.7.egg/mne/connectivity/spectral.pyc in
> _get_and_verify_data_sizes(data, n_signals, n_times, times)
>     479     n_signals_tot = 0
>     480     for this_data in data:
> --> 481         this_n_signals, this_n_times = this_data.shape
>     482         if n_times is not None:
>     483             if this_n_times != n_times:
>
> AttributeError: 'float' object has no attribute 'shape'
>
> Could someone please let me know what I am doing wrong?
>
> Best,
> Maria
>
>
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>
>
> The information in this e-mail is intended only for the person to whom it
> is
> addressed. If you believe this e-mail was sent to you in error and the
> e-mail
> contains patient information, please contact the Partners Compliance
> HelpLine at
> http://www.partners.org/complianceline . If the e-mail was sent to you in
> error
> but does not contain patient information, please contact the sender and
> properly
> dispose of the e-mail.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170615/a3bb4142/attachment.html 


More information about the Mne_analysis mailing list