[Mne_analysis] Mne_analysis Digest, Vol 113, Issue 24
Stout, Jeffrey
jstout at mcw.edu
Thu Jun 15 11:04:42 EDT 2017
We are just getting started with using this connectivity measure (wpli), so thanks for all of the help and information. I believe that a lot of the analysis code was from the MNE website, so it should be fairly familiar (I have the pseudo code and code snippet below). I have attached an image that shows what our lowest negative values (for ~30subjects) are with the wpli_debiased connectivity matrix and the percentage of connections that are negative . If the values should vary from -1 to 1, I would assume the percentage of negatives to be closer to 50% of the connections (since for every lead roi there would be a lag roi as well), but across subjects we are seeing about a 0-10% of the connections are negative. Attached are two example connectivity matrices (from Desikan-Killiany parcels) with the wpli_debiased measure as well as our code for the analysis. I will also upload the numpy matrices to the github site.
Psuedo Code:
Raw data is loaded from a resting state tSSS processed fif dataset
Make inverse operator
Make events of 1 second
Epoch data
Create dSPM (cov was created from emptyroom data - since no prestim period in resting data)
Load Labels >> Reorder labels to be L then R (vs. LRLRLR..)
Extract Labels
Create Connectivity using 3 measures (coh, pli, wpli)
Save out each conn measure as a numpy array.
________________________________________________________________
Below is some of the code:
inverse_operator = mne.minimum_norm.make_inverse_operator(raw.info, fwd, cov,
loose=0.2)
events = mne.make_fixed_length_events(raw, 1, start = 0, stop = None,
duration = 1.0, first_samp=True)
epochs = mne.Epochs(raw, events , event_id = 1, tmin=-0.2, tmax = 1.0,
baseline=(-0.2,0), preload=True)
# Compute inverse solution and for each epoch. By using "return_generator=True"
# stcs will be a generator object instead of a list.
snr = 1.0 # use lower SNR for single epochs
lambda2 = 1.0 / snr ** 2
method = "dSPM" # use dSPM method (could also be MNE or sLORETA)
stcs = apply_inverse_epochs(epochs, inverse_operator, lambda2, method,
pick_ori="normal", return_generator=True)
# Get labels for FreeSurfer 'aparc' cortical parcellation with 34 labels/hemi
labels_orig = mne.read_labels_from_annot(fs_subj, parc='aparc',
subjects_dir=SUBJECTS_DIR)
labels=copy.copy(labels_orig)
labels[0:34]=labels_orig[0:len(labels_orig):2]
labels[34:68]=labels_orig[1:len(labels_orig):2]
label_colors = [label.color for label in labels]
# Average the source estimates within each label using sign-flips to reduce
# signal cancellations, also here we return a generator
src = inverse_operator['src']
label_ts = mne.extract_label_time_course(stcs, labels, src, mode='mean_flip')#, #### Removed Generator
# return_generator=True)
for band in freq_bands:
fmin = band[0]
fmax = band[1]
sfreq = raw.info['sfreq'] # the sampling frequency
con_methods = ['coh', 'pli', 'wpli2_debiased']
con, freqs, times, n_epochs, n_tapers = spectral_connectivity(
label_ts, method=con_methods, mode='multitaper', sfreq=sfreq, fmin=fmin,
fmax=fmax, faverage=True, mt_adaptive=True, n_jobs=20)
# con is a 3D array, get the connectivity for the first (and only) freq. band
# for each method
con_res = dict()
for method, c in zip(con_methods, con):
con_res[method] = c[:, :, 0]
.....
-----Original Message-----
From: mne_analysis-bounces at nmr.mgh.harvard.edu [mailto:mne_analysis-bounces at nmr.mgh.harvard.edu] On Behalf Of mne_analysis-request at nmr.mgh.harvard.edu
Sent: Thursday, June 15, 2017 1:50 AM
To: mne_analysis at nmr.mgh.harvard.edu
Subject: Mne_analysis Digest, Vol 113, Issue 24
Send Mne_analysis mailing list submissions to
mne_analysis at nmr.mgh.harvard.edu
To subscribe or unsubscribe via the World Wide Web, visit
https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.nmr.mgh.harvard.edu_mailman_listinfo_mne-5Fanalysis&d=DwICAg&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=-re9rx1mJRcK9z2vjZt6NQ&m=7VahXgbBtmrJEZ1kWoXP9zV6saOVY0YKtYTQOSU_fNA&s=xWKxE7VmR9BB2m5x1hRx5VHkopCWumlRAKAX6-k59SI&e=
or, via email, send a message with subject or body 'help' to
mne_analysis-request at nmr.mgh.harvard.edu
You can reach the person managing the list at
mne_analysis-owner at nmr.mgh.harvard.edu
When replying, please edit your Subject line so it is more specific than "Re: Contents of Mne_analysis digest..."
Today's Topics:
1. Re: Negative Weighted Phase Lag Index Values (Cushing, Cody)
2. Re: Negative Weighted Phase Lag Index Values (Eric Larson)
3. Re: Negative Weighted Phase Lag Index Values (Andrea Brovelli)
----------------------------------------------------------------------
Message: 1
Date: Wed, 14 Jun 2017 20:40:41 +0000
From: "Cushing, Cody" <CCUSHING1 at mgh.harvard.edu>
Subject: Re: [Mne_analysis] Negative Weighted Phase Lag Index Values
To: Discussion and support forum for the users of MNE Software
<mne_analysis at nmr.mgh.harvard.edu>
Message-ID:
<D55DBCE8FA87E7468AC8A021B674DE9425E1DA52 at PHSX10MB22.partners.org>
Content-Type: text/plain; charset="gb2312"
Hey all,
Hopefully this helps rather than compounds your problem, but this also occurs when computing the debiased squared wpli, where there should undoubtedly be no negative values (unless the debiasing does something strange that I'm not aware of), just FYI. Generally, any negative values are small just as Jeff sees. However, out of a group of 57 subjects that I ran this on, I got a minimum value of -0.3954, which isn't all that small. I only mention this in case it is some shared routine between the wpli and wpli2_debiased that is generating these negative values. Hopefully the data you get from Jeff is enough to figure out what's going on, but I can supply more if need be.
Cheers,
Cody
________________________________
From: mne_analysis-bounces at nmr.mgh.harvard.edu [mne_analysis-bounces at nmr.mgh.harvard.edu] on behalf of Eric Larson [larson.eric.d at gmail.com]
Sent: Wednesday, June 14, 2017 3:49 PM
To: Discussion and support forum for the users of MNE Software
Subject: Re: [Mne_analysis] Negative Weighted Phase Lag Index Values
Jeff,
When you get a chance, could you try to share some data (as small as possible) and a small code snippet (using coherence-computing routines) that show this problem to the related MNE issue I opened<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_mne-2Dtools_mne-2Dpython_issues_4319&d=DwICAg&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=-re9rx1mJRcK9z2vjZt6NQ&m=7VahXgbBtmrJEZ1kWoXP9zV6saOVY0YKtYTQOSU_fNA&s=4TLRgs0Engoo7ipwrvo4E-QUM_XvLD9MMpdWG6LeJ8Q&e= >?
Eric
On Wed, Jun 14, 2017 at 3:22 PM, Eric Larson <larson.eric.d at gmail.com<mailto:larson.eric.d at gmail.com>> wrote:
Fig1C shows the individual vectors and how they're weighted -- I was looking at Eq.8 which defines WPLI, and the paragraph that followed where they state that 0 ? ? ? 1 holds (due to the absolute value operations in the numerator and denominator). But maybe there is more to it or you don't need to take the absolute value of the expectation in the numerator, in which case it could be -1 ? ? ? 1, is that what you have in mind...?
Eric
On Wed, Jun 14, 2017 at 3:13 PM, Andrea Brovelli <andrea.brovelli at univ-amu.fr<mailto:andrea.brovelli at univ-amu.fr>> wrote:
Dear all,
I don't know the implementation in MNE, but, as far as I know, the WPLI ranges between between -1 and 1 (see Fig. 1C in Vinck, Neuroimage 2011). The same is for the imaginary coherence (Nolte, Clin Neurophysiol 2004).
The strength of phase-synchronization can be indexed by the magnitude (or squared value) of the WPLI.
bye
Andrea
Le 14-Jun-17 ? 7:51 PM, Eric Larson a ?crit :
Yes it looks like WPLI should be bounded by 0 and 1. Can you open an MNE issue so we can look into it further?
Eric
On Wed, Jun 14, 2017 at 1:28 PM, Stout, Jeffrey <jstout at mcw.edu<mailto:jstout at mcw.edu>> wrote:
We are running analyses on resting state MEG data and we are finding negative values in the weighted phase lag index (wpli) measure. We have also run this data using the phase lag index (PLI) measure and do not see any values below zero. I thought that both the PLI and WPLI should be defined from 0 to 1. Although the negative values tend to be small, we are seeing this across many subjects.
wpli=np.load('connmat_wpli2_debiased13_30hz_run1.npy')
np.min(wpli), np.max(wpli)
Out[22]: (-0.0048496421426467845, 0.14954351856205442) <<<<<<<<< WPLI minimum value below Zero
pli=np.load('connmat_pli13_30hz_run1.npy')
np.min(pli), np.max(pli)
Out[24]: (0.0, 0.21375066880684856) <<<<<<<<< PLI minimum value equals zero
Is this a correct finding? Any insight would be helpful.
Thank you,
Jeff Stout
_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu<mailto:Mne_analysis at nmr.mgh.harvard.edu>
https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.nmr.mgh.harvard.edu_mailman_listinfo_mne-5Fanalysis&d=DwICAg&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=-re9rx1mJRcK9z2vjZt6NQ&m=7VahXgbBtmrJEZ1kWoXP9zV6saOVY0YKtYTQOSU_fNA&s=xWKxE7VmR9BB2m5x1hRx5VHkopCWumlRAKAX6-k59SI&e=
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 https://urldefense.proofpoint.com/v2/url?u=http-3A__www.partners.org_complianceline&d=DwICAg&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=-re9rx1mJRcK9z2vjZt6NQ&m=7VahXgbBtmrJEZ1kWoXP9zV6saOVY0YKtYTQOSU_fNA&s=bqkrrMIx5N6ZJuvi9k0ZimNXrMLMdK4XlYS8CdXoEAE&e= . 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.
_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu<mailto:Mne_analysis at nmr.mgh.harvard.edu>
https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.nmr.mgh.harvard.edu_mailman_listinfo_mne-5Fanalysis&d=DwICAg&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=-re9rx1mJRcK9z2vjZt6NQ&m=7VahXgbBtmrJEZ1kWoXP9zV6saOVY0YKtYTQOSU_fNA&s=xWKxE7VmR9BB2m5x1hRx5VHkopCWumlRAKAX6-k59SI&e=
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 https://urldefense.proofpoint.com/v2/url?u=http-3A__www.partners.org_complianceline&d=DwICAg&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=-re9rx1mJRcK9z2vjZt6NQ&m=7VahXgbBtmrJEZ1kWoXP9zV6saOVY0YKtYTQOSU_fNA&s=bqkrrMIx5N6ZJuvi9k0ZimNXrMLMdK4XlYS8CdXoEAE&e= . 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.
_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu<mailto:Mne_analysis at nmr.mgh.harvard.edu>
https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.nmr.mgh.harvard.edu_mailman_listinfo_mne-5Fanalysis&d=DwICAg&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=-re9rx1mJRcK9z2vjZt6NQ&m=7VahXgbBtmrJEZ1kWoXP9zV6saOVY0YKtYTQOSU_fNA&s=xWKxE7VmR9BB2m5x1hRx5VHkopCWumlRAKAX6-k59SI&e=
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 https://urldefense.proofpoint.com/v2/url?u=http-3A__www.partners.org_complianceline&d=DwICAg&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=-re9rx1mJRcK9z2vjZt6NQ&m=7VahXgbBtmrJEZ1kWoXP9zV6saOVY0YKtYTQOSU_fNA&s=bqkrrMIx5N6ZJuvi9k0ZimNXrMLMdK4XlYS8CdXoEAE&e= . 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: https://urldefense.proofpoint.com/v2/url?u=http-3A__mail.nmr.mgh.harvard.edu_pipermail_mne-5Fanalysis_attachments_20170614_2e186bfc_attachment-2D0001.html&d=DwICAg&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=-re9rx1mJRcK9z2vjZt6NQ&m=7VahXgbBtmrJEZ1kWoXP9zV6saOVY0YKtYTQOSU_fNA&s=MtjBrKLz3JK6iNKiHueUoS2Jao9A_9v6PMWJDuk36HI&e=
------------------------------
Message: 2
Date: Wed, 14 Jun 2017 16:48:20 -0400
From: Eric Larson <larson.eric.d at gmail.com>
Subject: Re: [Mne_analysis] Negative Weighted Phase Lag Index Values
To: Discussion and support forum for the users of MNE Software
<mne_analysis at nmr.mgh.harvard.edu>
Message-ID:
<CAGu2niUiAJFh=a9saJitfjKfLtOvMN3isbY-Ke_a2fN2ThJ=uQ at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
>
> this also occurs when computing the debiased squared wpli, where there
> should undoubtedly be no negative values (unless the debiasing does
> something strange that I'm not aware of), just FYI.
>
>From what I recall the debiasing can indeed produce (generally small)
negative values, so that at least I would expect. From Vinck et al., 2011:
If the WPLI exceeds the PLI, then the debiased WPLI-square estimator will
> be negatively biased for small sample sizes.
The WPLI, however, doesn't have this characteristic, and from what I've seen in a brief look at the MNE code, I'm not sure where it could come from (based on where we use abs()). So a minimal example would help us track it down.
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__mail.nmr.mgh.harvard.edu_pipermail_mne-5Fanalysis_attachments_20170614_1c4fad03_attachment-2D0001.html&d=DwICAg&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=-re9rx1mJRcK9z2vjZt6NQ&m=7VahXgbBtmrJEZ1kWoXP9zV6saOVY0YKtYTQOSU_fNA&s=8B956f_OTmHzgQielWHNS2otTnZpNYdfW6c6GVn8wZY&e=
------------------------------
Message: 3
Date: Thu, 15 Jun 2017 08:49:26 +0200
From: Andrea Brovelli <andrea.brovelli at univ-amu.fr>
Subject: Re: [Mne_analysis] Negative Weighted Phase Lag Index Values
To: mne_analysis at nmr.mgh.harvard.edu
Message-ID: <84586f5d-58c8-68a0-5ab9-36af1cbca4d1 at univ-amu.fr>
Content-Type: text/plain; charset="windows-1252"
Suggestion: in Fieldtrip, the WPLI is implemented in its signed version, it is not the eq.8 of Vinck' paper, which is bounded [0, 1].
The estimator is (line 73 in ft_connectivity_wpli.m <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_fieldtrip_fieldtrip_blob_master_connectivity_ft-5Fconnectivity-5Fwpli.m&d=DwICAg&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=-re9rx1mJRcK9z2vjZt6NQ&m=7VahXgbBtmrJEZ1kWoXP9zV6saOVY0YKtYTQOSU_fNA&s=TzonRBt38xKHoOE_VxCceeZLqUspnzs-6rz9PVu3boM&e= >
):
E(Im(X))/E(|Im(X)|)
Maybe the MNE code got inspiration from it.
Andrea
Le 14-Jun-17 ? 10:48 PM, Eric Larson a ?crit :
>
> this also occurs when computing the debiased squared wpli, where
> there should undoubtedly be no negative values (unless the
> debiasing does something strange that I'm not aware of), just FYI.
>
>
> From what I recall the debiasing can indeed produce (generally small)
> negative values, so that at least I would expect. From Vinck et al., 2011:
>
> If the WPLI exceeds the PLI, then the debiased WPLI-square
> estimator will be negatively biased for small sample sizes.
>
>
> The WPLI, however, doesn't have this characteristic, and from what
> I've seen in a brief look at the MNE code, I'm not sure where it could
> come from (based on where we use abs()). So a minimal example would
> help us track it down.
>
> Eric
>
>
>
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.nmr.mgh.harv
> ard.edu_mailman_listinfo_mne-5Fanalysis&d=DwICAg&c=aFamLAsxMIDYjNglYHT
> MV0iqFn3z4pVFYPQkjgspw4Y&r=-re9rx1mJRcK9z2vjZt6NQ&m=7VahXgbBtmrJEZ1kWo
> XP9zV6saOVY0YKtYTQOSU_fNA&s=xWKxE7VmR9BB2m5x1hRx5VHkopCWumlRAKAX6-k59S
> I&e=
>
>
> 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
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.partners.org_c
> omplianceline&d=DwICAg&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=-re9rx1mJRcK9z2vjZt6NQ&m=7VahXgbBtmrJEZ1kWoXP9zV6saOVY0YKtYTQOSU_fNA&s=bqkrrMIx5N6ZJuvi9k0ZimNXrMLMdK4XlYS8CdXoEAE&e= . 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: https://urldefense.proofpoint.com/v2/url?u=http-3A__mail.nmr.mgh.harvard.edu_pipermail_mne-5Fanalysis_attachments_20170615_abb7b803_attachment.html&d=DwICAg&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=-re9rx1mJRcK9z2vjZt6NQ&m=7VahXgbBtmrJEZ1kWoXP9zV6saOVY0YKtYTQOSU_fNA&s=h3nYHhjDS4ouC-0jQQBH9EOzN9zZHpqKfwC778k6PaA&e=
------------------------------
_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.nmr.mgh.harvard.edu_mailman_listinfo_mne-5Fanalysis&d=DwICAg&c=aFamLAsxMIDYjNglYHTMV0iqFn3z4pVFYPQkjgspw4Y&r=-re9rx1mJRcK9z2vjZt6NQ&m=7VahXgbBtmrJEZ1kWoXP9zV6saOVY0YKtYTQOSU_fNA&s=xWKxE7VmR9BB2m5x1hRx5VHkopCWumlRAKAX6-k59SI&e=
End of Mne_analysis Digest, Vol 113, Issue 24
*********************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NegativeConn_Assessment_multiplesubjects.PNG
Type: image/png
Size: 184737 bytes
Desc: NegativeConn_Assessment_multiplesubjects.PNG
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170615/f4ec5410/attachment-0001.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dspm_label_connectivity.py
Type: application/octet-stream
Size: 9562 bytes
Desc: dspm_label_connectivity.py
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170615/f4ec5410/attachment-0003.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dat3.npy
Type: application/octet-stream
Size: 37072 bytes
Desc: dat3.npy
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170615/f4ec5410/attachment-0004.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dat2.npy
Type: application/octet-stream
Size: 37072 bytes
Desc: dat2.npy
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170615/f4ec5410/attachment-0005.obj
More information about the Mne_analysis
mailing list