# Laplacian or local average reference in mne

**URL:** <https://mne.discourse.group/t/laplacian-or-local-average-reference-in-mne/3415>\
**Category:** Support & Discussions\
**Tags:** eeg, visualization\
**Created:** [July 16, 2021, 11:52pm UTC](https://mne.discourse.group/t/laplacian-or-local-average-reference-in-mne/3415 "2021-07-16T23:52:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![PauloKanda](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/paulokanda/32/642_2.png) [@PauloKanda](https://mne.discourse.group/u/PauloKanda)\
**Post date:** [July 16, 2021, 11:52pm UTC](https://mne.discourse.group/t/laplacian-or-local-average-reference-in-mne/3415/1 "2021-07-16T23:52:12Z")

</div>

Dear Colleagues,

I’m configuring a GUI using tkinter. Is that possible to configure laplacian (local average reference) in mne EEG. It is good dealing at focal epilepsy or other focal lesions, for instance, focal vascular, cortical focal displasias, etc. It really “cleans” garbage from signal.

If not:

I was wandering if is possible, for example, to create a ‘lar’ virtual reference for, lets say, F7, by doing—\> (Fp1+F3+T3) /3, and keeping channels Fp1 F3 T3 still plotting. Should I use instead —\> (Fp1+F3 +F7+T3) / 3, to get a reference for F7. I could do the same for  
all channels. By the way would it be correct, could I call it lar reference?

Or,  
Do you know any algorithm tha I could adapt to mne EEg to build Lar

Among other fonts I’ve read 'The Surface Laplacian Technique in EEG: Theory and Methods(1)  
but couldn’t figure it out.

(1) [https://arxiv.org/pdf/1406.0458.pdf](https://arxiv.org/pdf/1406.0458.pdf)

best,

Paulo Kanda  
University of Sao Paulo  
Brazil

---

<div class="post-metadata">

**Author:** ![cbrnr](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/cbrnr/32/1409_2.png) [@cbrnr](https://mne.discourse.group/u/cbrnr)\
**Post date:** [July 18, 2021, 8:02am UTC](https://mne.discourse.group/t/laplacian-or-local-average-reference-in-mne/3415/2 "2021-07-18T08:02:49Z")

</div>

MNE currently only supports average or single/multi-electrode references ([`mne.set_eeg_reference()`](https://mne.tools/stable/generated/mne.set_eeg_reference.html#mne.set_eeg_reference)) and bipolar references ([`mne.set_bipolar_reference()`](https://mne.tools/stable/generated/mne.set_bipolar_reference.html#mne.set_bipolar_reference)). Local average reference (aka Laplacian) would need to take channel neighborhoods into account, including the desired number of neighboring electrodes.

---

<div class="post-metadata">

**Author:** ![PauloKanda](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/paulokanda/32/642_2.png) [@PauloKanda](https://mne.discourse.group/u/PauloKanda)\
**Post date:** [August 11, 2021, 2:50am UTC](https://mne.discourse.group/t/laplacian-or-local-average-reference-in-mne/3415/3 "2021-08-11T02:50:12Z")

</div>

Any chance to have it in the future?

best  
Kanda

---

<div class="post-metadata">

**Author:** ![cbrnr](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/cbrnr/32/1409_2.png) [@cbrnr](https://mne.discourse.group/u/cbrnr)\
**Post date:** [August 11, 2021, 6:44am UTC](https://mne.discourse.group/t/laplacian-or-local-average-reference-in-mne/3415/4 "2021-08-11T06:44:44Z")

</div>

I don’t think that anyone is currently working on it – maybe you can try and make a pull request?

---

<div class="post-metadata">

**Author:** ![PauloKanda](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/paulokanda/32/642_2.png) [@PauloKanda](https://mne.discourse.group/u/PauloKanda)\
**Post date:** [August 11, 2021, 12:25pm UTC](https://mne.discourse.group/t/laplacian-or-local-average-reference-in-mne/3415/5 "2021-08-11T12:25:54Z")

</div>

I’d like to try, but Im a physician not a mathematician. Laplacian reference is importan to clinicians. It helps to focus localized generators as epileptic foci. If anyone know where can I gather info to build it, would be of help . I work with 20 electrodes, for instance, reference for T3 is just the mean of (F7+ C3+ T5) microvolts/3 ? I cant believe it could be so ease. ‘‘what’s the catch’’ in buinding of this so important reference? best. PKanda

---

<div class="post-metadata">

**Author:** ![cbrnr](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/cbrnr/32/1409_2.png) [@cbrnr](https://mne.discourse.group/u/cbrnr)\
**Post date:** [August 11, 2021, 2:27pm UTC](https://mne.discourse.group/t/laplacian-or-local-average-reference-in-mne/3415/6 "2021-08-11T14:27:45Z")

</div>

Coming up with something sufficiently generic to integrate in MNE-Python is probably a decent amount of work. However, you could relatively quickly hack something that works just for your use case. It is probably easiest if you work directly with the NumPy array holding the EEG data (`raw.get_data()`) . That way, you could create a new `RawArray` from scratch by computing the Laplace derivations for each channel manually, exactly as you suggested.

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [August 11, 2021, 4:58pm UTC](https://mne.discourse.group/t/laplacian-or-local-average-reference-in-mne/3415/7 "2021-08-11T16:58:16Z")

</div>

I’ve added this as a feature request to our GitHub repository: [support Laplacian referencing for EEG · Issue #9659 · mne-tools/mne-python · GitHub](https://github.com/mne-tools/mne-python/issues/9659)

@PauloKanda if you have any additional info to add (additional papers showing the benefits of local average referencing, any parameters that you will need to be able to control case-by-case, etc) please add them there.

---

<div class="post-metadata">

**Author:** ![mmagnuski](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mmagnuski/32/153_2.png) [@mmagnuski](https://mne.discourse.group/u/mmagnuski)\
**Post date:** [September 28, 2021, 4:59pm UTC](https://mne.discourse.group/t/laplacian-or-local-average-reference-in-mne/3415/8 "2021-09-28T16:59:46Z")

</div>

Just for the completeness of this thread, I add a summary of the GitHub issue linked above (now closed).  
The terms “Laplacian” and “Current Source Density” (CSD) are often used interchangeably in the EEG literature (see for example: [https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4610715/](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4610715/)).  
CSD is available in mne, [see this example to see how it can be done](https://mne.tools/dev/auto_examples/preprocessing/eeg_csd.html).

---

<div class="post-metadata">

**Author:** ![PauloKanda](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/paulokanda/32/642_2.png) [@PauloKanda](https://mne.discourse.group/u/PauloKanda)\
**Post date:** [September 28, 2021, 8:01pm UTC](https://mne.discourse.group/t/laplacian-or-local-average-reference-in-mne/3415/9 "2021-09-28T20:01:19Z")

</div>

Dear Mr MMagnusk

Very interesting and helpful

thanks again

Paulo Kanda
