# need help to plot EEG topomaps with mne

**URL:** <https://mne.discourse.group/t/need-help-to-plot-eeg-topomaps-with-mne/1033>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [June 18, 2016, 6:56pm UTC](https://mne.discourse.group/t/need-help-to-plot-eeg-topomaps-with-mne/1033 "2016-06-18T18:56:50Z")\
**Posts on this page:** 4\
**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 18, 2016, 6:56pm UTC](https://mne.discourse.group/t/need-help-to-plot-eeg-topomaps-with-mne/1033/1 "2016-06-18T18:56:50Z")

</div>

I'm new to mne, and would like to compute some topographic voltage maps

I have two specific questions:  
(i) The plot\_topomap function plots 2D maps. Is there a way to plot 3D  
maps?  
(ii) My data\_ is a 19 (electrodes) x 300 (datapoints) numpy array. Sampling  
rate was 250 Hz, and the 300 datapoints correspond to a -200 1000 ms epoch  
(0 being the stimulus-locking event).  
-Is there a simple way to plot topographies at say, 300 ms after stimulus  
onset, or topographies over the average of a given time window (300-500ms  
after stimulus onset)?  
-I need to provide the (x,y) coordinates for each EEG channel. My channels  
are:  
electrodes =  
['F3','F4','C3','C4','P3','P4','PO3','PO4','O1','O2','OL','OR','T3','T4','T5','T6','Fz','Cz','Pz']  
These electrodes are standard international 10/20 System sites, except OL  
(halfway between 01 and T5) and OL (halfway between 02 and T6). Given these  
locations, which coordinate array should I provide to the plot\_topomap  
function ?

Thanks for your help!  
Mathieu  
-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20160618/9afcb379/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20160618/9afcb379/attachment.html)

---

<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 20, 2016, 7:00am UTC](https://mne.discourse.group/t/need-help-to-plot-eeg-topomaps-with-mne/1033/2 "2016-06-20T07:00:16Z")

</div>

Hi Mathieu,  
currently there is no way to project to 3d.

For the second point you could use a montage when reading the data. The  
readers for EEG data have a montage parameter that you could use to set the  
channel locations (see for example  
[http://mne-tools.github.io/dev/generated/mne.io.read\_raw\_edf.html#mne.io.read\_raw\_edf](http://mne-tools.github.io/dev/generated/mne.io.read_raw_edf.html#mne.io.read_raw_edf)  
and  
[http://mne-tools.github.io/dev/generated/mne.channels.read\_montage.html#mne.channels.read\_montage](http://mne-tools.github.io/dev/generated/mne.channels.read_montage.html#mne.channels.read_montage)).  
In your case, since you have some custom locations, one option would be to  
manually add entries for 'OL' and 'OR' to the standard\_1020.elc file, if  
you know their locations.

-Jaakko

---

<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 20, 2016, 8:13am UTC](https://mne.discourse.group/t/need-help-to-plot-eeg-topomaps-with-mne/1033/3 "2016-06-20T08:13:43Z")

</div>

Hi Mathieu,

to complete Jaakko's answer, you can plot 3D EEG projection using mne.viz  
import.evoked\_field. For example:

```auto
import os.path as op
import mne
from mne.forward import make_field_map
from mne.viz import plot_evoked_field

# get data
data_path = mne.datasets.sample.data_path()
subjects_dir = data_path + '/subjects'
trans_fname = op.join(data_path, 'MEG', 'sample',
'sample_audvis_raw-trans.fif')
fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif')
evoked = mne.read_evokeds(fname, baseline=(None, 0), proj=True)[0]

# select eeg channels only
evoked.pick_types(eeg=True, meg=False)

# plot field maps
maps = make_field_map(evoked, trans=trans_fname, subjects_dir=subjects_dir,
                      subject='sample', n_jobs=-1, meg_surf='head')
plot_evoked_field(evoked, maps, time=.1)

```

Hope that helps,

Jean-R?mi

---

<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 21, 2016, 5:49am UTC](https://mne.discourse.group/t/need-help-to-plot-eeg-topomaps-with-mne/1033/4 "2016-06-21T05:49:32Z")

</div>

Hi Mathieu,

it's generally best to follow up your questions on the mailing list so that  
others can checkout the archives.

To make an Evoked object you should be able to do:

from mne import EvokedArray, create\_info  
sampling\_freq = 128  
info = create\_info(n\_channels, sampling\_freq, 'eeg')  
evoked = EvokedArray(your\_data\_array, info=info, tmin=0.)

Then you can make a montage and attach it to the evoked object:

from mne.channels import Montage  
kind = 2 # means eeg channels  
montage = Montage(position\_xyz, info, kind=2, range(n\_channels))  
evoked.set\_montage(montage)

You can then use the plotting function that I described in the previous  
email to plot in 3D. Note that MNE has a wider spectrum of functions for 2D  
plottings (have a look at evoked.plot(), plot\_topo(), plot\_topomap(),  
plot\_\*() methods). Tu use them you'll need to make a 2D layout  
(mne.channels.make\_eeg\_layout).

Hope that helps,

JR

PS: yes I am 😉

Hi Jean-R?mi (Are you French?)

> Thanks for your help.  
> I've some difficulties with the mne.read\_evokeds function. At the moment,  
> I have a grand average data 19(channels) x 300 (datapoints) numpy array and  
> a custom montage instance from the mne.channels.Montage map (see attached).  
> How could I proceed to (i) generate a read\_evokeds() object, and (ii)  
> plot a 3D map in a specific time window...
> 
> Best,  
> Mathieu
> 
> Hi Mathieu,
> 
> to complete Jaakko's answer, you can plot 3D EEG projection using mne.viz  
> import.evoked\_field. For example:
> 
> ```python
> import os.path as op
> import mne
> from mne.forward import make_field_map
> from mne.viz import plot_evoked_field
> 
> # get data
> data_path = mne.datasets.sample.data_path()
> subjects_dir = data_path + '/subjects'
> trans_fname = op.join(data_path, 'MEG', 'sample',
> 'sample_audvis_raw-trans.fif')
> fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif')
> evoked = mne.read_evokeds(fname, baseline=(None, 0), proj=True)[0]
> 
> # select eeg channels only
> evoked.pick_types(eeg=True, meg=False)
> 
> # plot field maps
> maps = make_field_map(evoked, trans=trans_fname, subjects_dir=subjects_dir,
> subject='sample', n_jobs=-1, meg_surf='head')
> plot_evoked_field(evoked, maps, time=.1)
> 
> ```
> 
> Hope that helps,
> 
> Jean-R?mi
> 
> > Hi Mathieu,  
> > currently there is no way to project to 3d.
> > 
> > For the second point you could use a montage when reading the data. The  
> > readers for EEG data have a montage parameter that you could use to set the  
> > channel locations (see for example  
> > [mne.io.read\_raw\_edf — MNE 1.7.0.dev17+g20174f448 documentation](http://mne-tools.github.io/dev/generated/mne.io.read_raw_edf.html#mne.io.read_raw_edf)  
> > and  
> > [http://mne-tools.github.io/dev/generated/mne.channels.read\_montage.html#mne.channels.read\_montage](http://mne-tools.github.io/dev/generated/mne.channels.read_montage.html#mne.channels.read_montage)).  
> > In your case, since you have some custom locations, one option would be to  
> > manually add entries for 'OL' and 'OR' to the standard\_1020.elc file, if  
> > you know their locations.
> > 
> > -Jaakko
> > 
> > > I'm new to mne, and would like to compute some topographic voltage maps  
> > > from my EEG grand-averaged data.
> > > 
> > > I have two specific questions:  
> > > (i) The plot\_topomap function plots 2D maps. Is there a way to plot 3D  
> > > maps?  
> > > (ii) My data\_ is a 19 (electrodes) x 300 (datapoints) numpy array.  
> > > Sampling rate was 250 Hz, and the 300 datapoints correspond to a -200 1000  
> > > ms epoch (0 being the stimulus-locking event).  
> > > -Is there a simple way to plot topographies at say, 300 ms after  
> > > stimulus onset, or topographies over the average of a given time window  
> > > (300-500ms after stimulus onset)?  
> > > -I need to provide the (x,y) coordinates for each EEG channel. My  
> > > channels are:  
> > > electrodes =  
> > > ['F3','F4','C3','C4','P3','P4','PO3','PO4','O1','O2','OL','OR','T3','T4','T5','T6','Fz','Cz','Pz']  
> > > These electrodes are standard international 10/20 System sites, except  
> > > OL (halfway between 01 and T5) and OL (halfway between 02 and T6). Given  
> > > these locations, which coordinate array should I provide to the  
> > > plot\_topomap function ?
> > > 
> > > Thanks for your help!  
> > > Mathieu
> > > 
> > > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > > Mne\_analysis mailing list  
> > > Mne\_analysis at nmr.mgh.harvard.edu  
> > > [Mne\_analysis Info Page](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  
> > > [MyComplianceReport.com: Compliance and Ethics Reporting](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.
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > Mne\_analysis mailing list  
> > Mne\_analysis at nmr.mgh.harvard.edu  
> > [Mne\_analysis Info Page](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  
> > [MyComplianceReport.com: Compliance and Ethics Reporting](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/20160621/9c0ad99b/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20160621/9c0ad99b/attachment.html)
