# Plotting MNI coordinates on inflated brain surface with add\_foci

**URL:** <https://mne.discourse.group/t/plotting-mni-coordinates-on-inflated-brain-surface-with-add-foci/7119>\
**Category:** Support & Discussions\
**Tags:** ﻿source-localization, meg, visualization\
**Created:** [June 20, 2023, 9:32pm UTC](https://mne.discourse.group/t/plotting-mni-coordinates-on-inflated-brain-surface-with-add-foci/7119 "2023-06-20T21:32:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MateGy](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@MateGy](https://mne.discourse.group/u/MateGy)\
**Post date:** [June 20, 2023, 9:32pm UTC](https://mne.discourse.group/t/plotting-mni-coordinates-on-inflated-brain-surface-with-add-foci/7119/1 "2023-06-20T21:32:30Z")

</div>

- MNE version:1.1.1
- operating system: Windows 10

Hi MNE community,  
I was wondering how to convert MNI coordinates into ‘stereotaxic space’, whatever that might be, that **add\_foci()** uses to plot spheres on the brain surface in **mne.viz.Brain**. I have a point in MNI coordinates, and I would like to be able to viusalize it on the mne.viz.Brain brain.  
Thanks!

---

<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:** [June 26, 2023, 4:20pm UTC](https://mne.discourse.group/t/plotting-mni-coordinates-on-inflated-brain-surface-with-add-foci/7119/2 "2023-06-26T16:20:40Z")

</div>

“stereotaxic space” here refers to XYZ coordinates, but does not specify the coordinate system.

[this tutorial section](https://mne.tools/stable/auto_tutorials/forward/50_background_freesurfer_mne.html#freesurfer-s-mni-affine-transformation) demonstrates converting from “whatever the space is that works for `add_foci`” into MNI coordinates, so you can go the other direction by inverting that transform using `scipy.linalg.inv` or `scipy.linalg.pinv` and applying the resulting transform to your MNI point(s). There’s an example of inverting/appling transforms in [this other tutorial section](https://mne.tools/stable/auto_tutorials/forward/20_source_alignment.html#visualizing-the-transformations).

As for what coordinate system `add_foci` is expecting, I think (?) it will always expect “MRI surface RAS” (explained in [this tutorial section](https://mne.tools/stable/auto_tutorials/forward/20_source_alignment.html#coordinate-frame-definitions))

---

<div class="post-metadata">

**Author:** ![MateGy](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@MateGy](https://mne.discourse.group/u/MateGy)\
**Post date:** [June 26, 2023, 10:35pm UTC](https://mne.discourse.group/t/plotting-mni-coordinates-on-inflated-brain-surface-with-add-foci/7119/3 "2023-06-26T22:35:19Z")

</div>

Thank you so much for your response. I’m sorry, my original post was not detailed enough. I am aware of most of what you have said, however, whatever it is that add\_foci is expecting does not seem to be MRI surface RAS, and since I only know how to go from MRI surface RAS to MNI, I cannot plot MNI coordinates on the brain. Here is a short code snippet to illustrate:

```python
vertex_of_interest = 129079
surf = subjects_dir + '\\' + sub + '\\' + "surf" + '\\' + hemifield + '.white'

# Get vertex location in MRI surface RAS coordinates (option 1)
# read surface locations in MRI surface RAS space
rr = mne.read_surface(surf)[0]
vert_in_mri = rr[vertex_of_interest,:]

# Get vertex location in MNI coordinates
vert_in_mni = mne.vertex_to_mni(mne_vert,this_hemi,sub,subjects_dir=subjects_dir)

# Just to double check:
# Get vertex location in MRI surface RAS coordinates (option 2)
xfm = mne.read_talxfm(sub, subjects_dir)
xfm["trans"][:3, 3] *= 1000.0 # m->mm
mni_to_mri_trans = mne.transforms.invert_transform(xfm)
vert_in_mri2 = mne.transforms.apply_trans(mni_to_mri_trans['trans'], vert_in_mni)   
# vert_in_mri and vert_in_mri2 are identical 

# Plot inflated brain
brain = mne.viz.Brain(sub, hemifield, "inflated", subjects_dir=subjects_dir, background="w")
brain.add_annotation('parc2018yeo17_200')
brain.add_label(labelname[:-3], color='k', subdir = 'parc2018yeo17_200')
brain.add_foci(vertex_of_interest,coords_as_verts=True, hemi=hemifield, color='b')
brain.add_foci(vert_in_mri,hemi=hemifield, color='r')
brain.add_foci(vert_in_mni,hemi=hemifield, color='y')

```

The blue dot is in the expected location, but the other two are way off AND they are not similar to each other either.

 ![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/5/5ca6791fd362bb1df0f6e1fe755c87c858999375.jpeg)

I can also get the coordinates directly that add\_foci seems to be plotting with **brain.geo[hemifield].coords[vertex\_of\_interest,:]**, and they do not match the MRI surface RAS coordinates from above.
