# CSD might break montage

**URL:** <https://mne.discourse.group/t/csd-might-break-montage/2233>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [June 24, 2020, 1:21pm UTC](https://mne.discourse.group/t/csd-might-break-montage/2233 "2020-06-24T13:21:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 24, 2020, 1:21pm UTC](https://mne.discourse.group/t/csd-might-break-montage/2233/1 "2020-06-24T13:21:20Z")

</div>

External Email - Use Caution

Hello all,

I am applying CSD to my epoched data and want to compare the  
distributions of the ERPs on the scalp before and after surface laplacian.

epochs\_csd = mne.preprocessing.compute\_current\_source\_density(epochs)

I use : mne.viz.plot\_compare\_evokeds([epochs.average()], picks='eeg',  
axes='topo')  
To plot before CSD, everything works fine but then I use :  
mne.viz.plot\_compare\_evokeds([epochs\_csd.average()], picks='csd',  
axes='topo')  
And then the channel order is preserved but the cartoon head is shrinked  
to the lower left of the figure (see attached) making it impossible to read.

I am assuming that the montage is lost in the csd transform as  
epoch.info prints me :  
\<Info | 11 non-empty values  
&nbsp;&nbsp;bads: []  
&nbsp;&nbsp;ch\_names: Fp1, AF7, AF3, F1, F3, F5, F7, FT7, FC5, FC3, FC1, C1, C3,  
C5, ...  
&nbsp;&nbsp;chs: 64 EEG  
&nbsp;&nbsp;custom\_ref\_applied: True  
&nbsp;&nbsp;dig: 712 items (3 Cardinal, 64 EEG, 645 Extra)  
&nbsp;&nbsp;file\_id: 4 items (dict)  
&nbsp;&nbsp;highpass: 0.0 Hz  
&nbsp;&nbsp;lowpass: 40.0 Hz  
&nbsp;&nbsp;meas\_date: 2019-06-06 11:46:59 UTC  
&nbsp;&nbsp;meas\_id: 4 items (dict)  
&nbsp;&nbsp;nchan: 64  
&nbsp;&nbsp;projs: []  
&nbsp;&nbsp;sfreq: 1000.0 Hz  
\>

and epochs\_csd.info :

\<Info | 11 non-empty values  
&nbsp;&nbsp;bads: []  
&nbsp;&nbsp;ch\_names: Fp1, AF7, AF3, F1, F3, F5, F7, FT7, FC5, FC3, FC1, C1, C3,  
C5, ...  
&nbsp;&nbsp;chs: 64 CSD  
&nbsp;&nbsp;custom\_ref\_applied: True  
&nbsp;&nbsp;dig: 712 items (3 Cardinal, 64 EEG, 645 Extra)  
&nbsp;&nbsp;file\_id: 4 items (dict)  
&nbsp;&nbsp;highpass: 0.0 Hz  
&nbsp;&nbsp;lowpass: 40.0 Hz  
&nbsp;&nbsp;meas\_date: 2019-06-06 11:46:59 UTC  
&nbsp;&nbsp;meas\_id: 4 items (dict)  
&nbsp;&nbsp;nchan: 64  
&nbsp;&nbsp;projs: []  
&nbsp;&nbsp;sfreq: 1000.0 Hz  
\>

Is there a quick workaround ?

Best,  
Gabriel  
-------------- next part --------------  
A non-text attachment was scrubbed...  
Name: topo\_csd.png  
Type: image/png  
Size: 68233 bytes  
Desc: not available  
Url : [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20200624/cf4e1a22/attachment-0001.png](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20200624/cf4e1a22/attachment-0001.png)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 24, 2020, 7:50pm UTC](https://mne.discourse.group/t/csd-might-break-montage/2233/2 "2020-06-24T19:50:35Z")

</div>

External Email - Use Caution

The topomaps in the example don't show this problem, at least for  
plot\_topomap:

[https://mne.tools/dev/auto\_examples/preprocessing/plot\_eeg\_csd.html#sphx-glr-auto-examples-preprocessing-plot-eeg-csd-py](https://mne.tools/dev/auto_examples/preprocessing/plot_eeg_csd.html#sphx-glr-auto-examples-preprocessing-plot-eeg-csd-py)

First, it's worth trying latest  
\<[https://mne.tools/dev/install/advanced.html#using-the-development-version-of-mne-python-latest-master](https://mne.tools/dev/install/advanced.html#using-the-development-version-of-mne-python-latest-master)\>  
`master` branch rather than 0.20.x to see if we have fixed it already.

If that doesn't work, can you see if you can reproduce on the `sample`  
dataset by modifying the example above? If not, there might be something  
about your data in particular -- if you can turn this into some tiny script  
(probably gist \<[https://gist.github.com/](https://gist.github.com/)\>) to demonstrate the problem and  
share your data someone can take a look.

Eric

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 25, 2020, 12:49pm UTC](https://mne.discourse.group/t/csd-might-break-montage/2233/3 "2020-06-25T12:49:26Z")

</div>

External Email - Use Caution

I was on the dev branch after the commit #7863 on CSD on github, but  
even when updating to the master branch with the link you provided I  
still have the same error.

I tried with the example in  
[https://mne.tools/dev/auto\_examples/preprocessing/plot\_eeg\_csd.html#sphx-glr-auto-examples-preprocessing-plot-eeg-csd-py](https://mne.tools/dev/auto_examples/preprocessing/plot_eeg_csd.html#sphx-glr-auto-examples-preprocessing-plot-eeg-csd-py)  
Topomap works (as for my data actually) but when I use  
mne.viz.plot\_compare\_evokeds([evoked\_csd], picks='csd', axes='topo')  
I have the same error. So it seems to be specific to plot\_compare\_evokeds

I posted a gist in case it's spares you or others some time  
[https://gist.github.com/GWeindel/2af99b1a3b07d2d75d8e27cbacdf741e](https://gist.github.com/GWeindel/2af99b1a3b07d2d75d8e27cbacdf741e)

Best,  
Gabriel

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 25, 2020, 1:10pm UTC](https://mne.discourse.group/t/csd-might-break-montage/2233/4 "2020-06-25T13:10:48Z")

</div>

External Email - Use Caution

i had the same problem with evoked.plot\_joint when i tried using the CSD  
routine on epoched data then averaging into an Evoked object -- topography  
wouldn't plot, just got a black circle in the bottom left of the panel  
where a topomap should be. the evoked plot at the bottom plotted fine though

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 25, 2020, 6:34pm UTC](https://mne.discourse.group/t/csd-might-break-montage/2233/5 "2020-06-25T18:34:27Z")

</div>

External Email - Use Caution

This looks to be a genuine bug, which I think I've narrowed down to mne.channels.layout.generate\_2d\_layout. I'll work on a fix. Gabriel, Sammi, if you have GitHub accounts you can subscribe to this issue to track progress: [https://github.com/mne-tools/mne-python/issues/7933](https://github.com/mne-tools/mne-python/issues/7933)

-- dan  
Daniel McCloy  
[https://dan.mccloy.info](https://dan.mccloy.info)  
Research Scientist  
Institute for Learning and Brain Sciences  
University of Washington

??? Original Message ???

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 29, 2020, 12:26pm UTC](https://mne.discourse.group/t/csd-might-break-montage/2233/6 "2020-06-29T12:26:09Z")

</div>

External Email - Use Caution

Hi Dan,

I saw that a fix for this was merged - what's the best way of getting this  
into the version of mne that i'm using at the moment? im running 0.20.5 at  
the moment

sorry to bug about this!  
Sammi

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 29, 2020, 1:04pm UTC](https://mne.discourse.group/t/csd-might-break-montage/2233/7 "2020-06-29T13:04:32Z")

</div>

External Email - Use Caution

hi Sammi,

try :

pip install -U [https://github.com/mne-tools/mne-python/archive/master.zip](https://github.com/mne-tools/mne-python/archive/master.zip)

Alex

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 30, 2020, 11:59am UTC](https://mne.discourse.group/t/csd-might-break-montage/2233/8 "2020-06-30T11:59:58Z")

</div>

External Email - Use Caution

Thanks a lot! Out of interest, is there a (theoretical?) reason that  
interactive topomaps aren't permitted for CSD type channels, only EEG/MEG ?  
can't select a time-period from a joint\_plot to get a topo, but unsure why  
this might not be the case (unless it just hasn't been implemented yet?)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 30, 2020, 12:53pm UTC](https://mne.discourse.group/t/csd-might-break-montage/2233/9 "2020-06-30T12:53:24Z")

</div>

External Email - Use Caution

no particular reason AFAIK

it was never suggested

A

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 30, 2020, 5:06pm UTC](https://mne.discourse.group/t/csd-might-break-montage/2233/10 "2020-06-30T17:06:51Z")

</div>

External Email - Use Caution

Hi Sammi,  
pip install -U [https://github.com/mne-tools/mne-python/archive/master.zip](https://github.com/mne-tools/mne-python/archive/master.zip)  
will get you the latest development version, which includes the fix you want.

-- dan  
Daniel McCloy  
[https://dan.mccloy.info](https://dan.mccloy.info)  
Research Scientist  
Institute for Learning and Brain Sciences  
University of Washington

??? Original Message ???
