# Problem extracting x,y position from montage to use with plot\_topomap

**URL:** <https://mne.discourse.group/t/problem-extracting-x-y-position-from-montage-to-use-with-plot-topomap/5849>\
**Category:** Support & Discussions\
**Tags:** visualization\
**Created:** [November 1, 2022, 2:45pm UTC](https://mne.discourse.group/t/problem-extracting-x-y-position-from-montage-to-use-with-plot-topomap/5849 "2022-11-01T14:45:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GWeindel](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/gweindel/32/2031_2.png) [@GWeindel](https://mne.discourse.group/u/GWeindel)\
**Post date:** [November 1, 2022, 2:45pm UTC](https://mne.discourse.group/t/problem-extracting-x-y-position-from-montage-to-use-with-plot-topomap/5849/1 "2022-11-01T14:45:23Z")

</div>

Hi all,

For what I hope to be a new addition to the MNE ecosystem ([GitHub - GWeindel/hsmm\_mvpy: Repository for the hsmm-mvpy package](https://github.com/GWeindel/hsmm_mvpy)) I am looking to extract and use x,y position of EEG electrodes and feed them to `plot_topomap()`. I want users to be able to specify positions without having to read raw data and apply a montage on it (e.g. if someone has channel locations from another source than MNE).  
It works nicely with EEGLAB channel output but when I try using only x,y positions from an mne.montage I fail to reproduce the result from `plot_topomap()` when using the raw.info with the same montage

I guess this is my misunderstanding of the way topomap and montages work and not a bug so I only post an example of how I do it but can provide a minimal working example if needed

```python
raw = mne.io.read_raw_brainvision("MD3-%s.vhdr"%subj_num, preload =False)
raw.set_montage('easycap-M1')#Standard 1020 electrode montage
montage = raw.info.get_montage().get_positions()['ch_pos']
positions = np.array([montage[x][:2] for x in eeg_data['electrodes'].values])#Extract x and y positions of each electrode

```

When plotting, feeding `raw.info` to `plot_topomap()` gives the expected result:

 ![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/1/16b75e5ebfa69b3e1afd6fccd40ced00e9baf3db.png)

but feeding `positions` does not

 ![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/c/c022e808924e0be2b016d7e439ae8ffab3f14ec8.png)

What am I missing?

Best,  
Gabriel

- MNE version: 1.0.3
- operating system: Ubuntu 20.04

---

<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:** [November 3, 2022, 2:45pm UTC](https://mne.discourse.group/t/problem-extracting-x-y-position-from-montage-to-use-with-plot-topomap/5849/2 "2022-11-03T14:45:33Z")

</div>

`.get_positions()` gives you X, Y, Z in _real world_ coordinates (either digitized directly from the cap on the subject’s head, or idealized spherical-head positions for template montages). These are measured in meters. For plotting topomaps, internally MNE-Python does something more complicated than just discarding the z coordinate. The heavy lifting is done in [this private function](https://github.com/mne-tools/mne-python/blob/7655632d8e85164a36b8f322ed52e9262a7e2ebb/mne/channels/layout.py#L685). Let us know if that’s not enough to get you sorted.

---

<div class="post-metadata">

**Author:** ![GWeindel](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/gweindel/32/2031_2.png) [@GWeindel](https://mne.discourse.group/u/GWeindel)\
**Post date:** [November 3, 2022, 3:05pm UTC](https://mne.discourse.group/t/problem-extracting-x-y-position-from-montage-to-use-with-plot-topomap/5849/3 "2022-11-03T15:05:56Z")

</div>

Oh thanks that looks indeed like what I need! I will play with the function and keep you posted

---

<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:** [November 3, 2022, 3:49pm UTC](https://mne.discourse.group/t/problem-extracting-x-y-position-from-montage-to-use-with-plot-topomap/5849/4 "2022-11-03T15:49:22Z")

</div>

great! although I must include the standard warning that the API of private functions is not guaranteed to be stable, and using our private functions in your packages / analysis scripts is discouraged. Ideally either you find a way to get what you need through the public API, or if that is impossible, you propose (in a new GitHub issue) why we should make that one public. (be as convincing as you can, as expanding our public API is a maintenance burden so we don’t do it automatically at every request).
