# Difference between wPLI from FieldTrip and MNE - Python

**URL:** <https://mne.discourse.group/t/difference-between-wpli-from-fieldtrip-and-mne-python/4792>\
**Category:** Support & Discussions\
**Tags:** eeg, connectivity, matlab\
**Created:** [April 26, 2022, 4:47pm UTC](https://mne.discourse.group/t/difference-between-wpli-from-fieldtrip-and-mne-python/4792 "2022-04-26T16:47:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![igor-casatti](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/igor-casatti/32/1396_2.png) [@igor-casatti](https://mne.discourse.group/u/igor-casatti)\
**Post date:** [April 26, 2022, 4:47pm UTC](https://mne.discourse.group/t/difference-between-wpli-from-fieldtrip-and-mne-python/4792/1 "2022-04-26T16:47:13Z")

</div>

Hello,

I am currently working with the calculation of wPLI on EEG data and I saw that the MNE implementation of the wPLI is a little bit different by the one from MATLAB FieldTrip package. It seems that MNE uses the equation 8 from Vinck et al., 2011, while the FieldTrip uses the same formula, but without the abs() operator on the numerator.

I am calculating the values using MNE - Python, while a colleague is using FieldTrip, and our results are quite different. Does someone know if the different formulation can cause different results for the same set of patients?

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [April 30, 2022, 8:17am UTC](https://mne.discourse.group/t/difference-between-wpli-from-fieldtrip-and-mne-python/4792/2 "2022-04-30T08:17:07Z")

</div>

Hello @igor-casatti and welcome to the forum!

I’m not familiar at all with wLPI – maybe @agramfort has an idea…?

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![agramfort](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@agramfort](https://mne.discourse.group/u/agramfort)\
**Post date:** [May 3, 2022, 6:51am UTC](https://mne.discourse.group/t/difference-between-wpli-from-fieldtrip-and-mne-python/4792/3 "2022-05-03T06:51:25Z")

</div>

Hi

Can you point to the lines in mne and fieldtrip source codes that are different? I would also add Robert Oostenveld about this. He is likely to be the one who wrote the WPLI code in fieldtrip.

Alex

---

<div class="post-metadata">

**Author:** ![igor-casatti](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/igor-casatti/32/1396_2.png) [@igor-casatti](https://mne.discourse.group/u/igor-casatti)\
**Post date:** [May 3, 2022, 12:33pm UTC](https://mne.discourse.group/t/difference-between-wpli-from-fieldtrip-and-mne-python/4792/4 "2022-05-03T12:33:38Z")

</div>

Hi,

In the line 119 of the FieldTrip script:

> <https://github.com/fieldtrip/fieldtrip/blob/8bebf82310b247519bdefce336ab1e815a2d6852/connectivity/ft_connectivity_wpli.m#L112-L124>

And in the lines 428 - 451 of the MNE code:

> <https://github.com/mne-tools/mne-connectivity/blob/2d47ae7d281c2ff2fe17f2d55f2e3d7dd0d0a4c5/mne_connectivity/spectral/epochs.py#L428-L451>

Thanks for the reply.

Igor

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [May 3, 2022, 12:50pm UTC](https://mne.discourse.group/t/difference-between-wpli-from-fieldtrip-and-mne-python/4792/5 "2022-05-03T12:50:28Z")

</div>

Hello Igor, I took the liberty to slightly edit your posting such that the relevant bits of code would show up in the forum directly.

---

<div class="post-metadata">

**Author:** ![agramfort](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@agramfort](https://mne.discourse.group/u/agramfort)\
**Post date:** [May 5, 2022, 7:04am UTC](https://mne.discourse.group/t/difference-between-wpli-from-fieldtrip-and-mne-python/4792/6 "2022-05-05T07:04:59Z")

</div>

hi @igor-casatti

I just looked at the code. The two implementation are doing the same except that MNE applies an abs at the end following es (8). It’s true that one could argue that it’s still possible to compute the abs afterwards but the paper has it. So in fieldtrip just compute the abs manually and the results should match.

Alex
