[Mne_analysis] How to get coherence between stc files?

Maria Hakonen maria.hakonen at gmail.com
Sat Jun 17 15:07:03 EDT 2017
Search archives:

Hi,

Many thanks for your answers! This clarified the matter for me.

However, instead of calculating coherence in sensor space, I would like to
calculate coherence in source space (i.e. I would need to get coherence
between each vertex from the first dataset and their counterparts from the
second dataset). Therefore, I have applied inverse operator for each epoch
of condition 1 and condition 2:

stcs1 = apply_inverse_epochs(epochs1, inverse_operator1, lambda2, method,
                            pick_ori="normal")
stcs2 = apply_inverse_epochs(epochs2, inverse_operator2, lambda2, method,
                            pick_ori="normal")

This gives me a list of 160 stcs that are as follows:
stcs1[0]
Out[25]: <SourceEstimate  |  20482 vertices, subject : ah, tmin :
-99.9936018905 (ms), tmax : 2899.81445482 (ms), tstep : 0.833280015754
(ms), data size : 20482 x 3601>

Then, I could combine these two list of stcs and give the resulting list as
an argument to mne.connectivity.spectral_connectivity:
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 would need to estimate coherence between each vertex from the
first dataset and each vertex in the second dataset. As far as I
understand, “indices” can only determine the vertices between which to
compute coherence within a dataset but not between two datasets.

The documentation says:

"By default, the connectivity between all signals is computed (only
connections corresponding to the lower-triangular part of the connectivity
matrix). If one is only interested in the connectivity between some
signals, the “indices” parameter can be used. For example, to compute the
connectivity between the signal with index 0 and signals “2, 3, 4” (a total
of 3 connections) one can use the following:

indices = (np.array([0, 0, 0]),    # row indices
           np.array([2, 3, 4]))    # col indices

con_flat = spectral_connectivity(data, method='coh',
                                 indices=indices, ...)"

Could you please let me know if there is any way in mne to calculate
coherence between two datasets in source space?

Best,
Maria


2017-06-16 18:32 GMT+03:00 Eric Larson <larson.eric.d at gmail.com>:

> data=np.concatenate((epochs_1.get_data(),epochs_2.get_data()),axis=0)
>>>
>>> data.shape
>>>
>>> Out[28]: (320, 308, 3721)
>>>
>>
> Following the nomenclature from the connectivity docs
> <https://mne-tools.github.io/stable/generated/mne.connectivity.spectral_connectivity.html#mne.connectivity.spectral_connectivity>,
> your input data need to be formatted as (n_epochs, n_signals, n_times).
> Keep in mind that the n_signals dimension is usually the spatial one, like
> source space vertices, or in your case, channels. So the way you have this
> set up, you have 308 spatial channels / signals, each with 320 epochs /
> repeats.
>
> I am not sure how the parameter “indices” should be set in my case.
>>>
>>
> Indices should be into the (typically) spatial dimension, i.e. the
> n_signals dimension.
>
> I would like to calculate the coherence between each data point in the
>>> file 1 and the corresponding data points in the file 2.
>>>
>>
> "data point" is a bit ambiguous -- I assume you mean you want to estimate
> the connectivity between *each channel* from the first dataset and *each
> channel* in the second dataset....
>
> Since I have 320 epochs after concatenation, I tried:
>>>
>>> indices=(np.arange(1,160),np.arange(161,320)) (i.e. 160 epochs in each
>>> file).
>>>
>>
> ... which means this probably isn't set up to do what you want.
>
> What you might want is this:
>
> data=np.concatenate((epochs_1.get_data(),epochs_2.get_data()),axis=1)
> data.shape
> (160, 616, 3721)
>
>> This way, you have 616 signals of interest (308 signals / channels from
> one condition, 308 from signals / channels from another), each with 160
> epochs / repeats.
>
> Hopefully from there you can come up with how to get connectivity you
> want. For example, if you want each channel only with its corresponding
> channel from the other condition (308 estimates), this would be something
> like:
>
> (np.arange(308), np.arange(308) + 308)
>
>> If you wanted all channels from condition 1 with all channels from
> condition 2 (94864 estimates), this would be something like:
>
> (np.repeat(np.arange(308), 308), np.tile(np.arange(308) + 308, 308))
>
>> And 308 is a somewhat rare number of data channels -- you might want to
> check to make sure you have only data channels picked as Jaakko suggests.
>
> HTH,
> Eric
>
>
> _______________________________________________
> 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/20170617/b89efa94/attachment.html 


More information about the Mne_analysis mailing list