# Unable to transform montage following iEEG electrode localization with GUI

**URL:** <https://mne.discourse.group/t/unable-to-transform-montage-following-ieeg-electrode-localization-with-gui/5647>\
**Category:** Support & Discussions\
**Created:** [September 27, 2022, 6:06pm UTC](https://mne.discourse.group/t/unable-to-transform-montage-following-ieeg-electrode-localization-with-gui/5647 "2022-09-27T18:06:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![CM2020](https://avatars.discourse-cdn.com/v4/letter/c/cdc98d/32.png) [@CM2020](https://mne.discourse.group/u/CM2020)\
**Post date:** [September 27, 2022, 6:06pm UTC](https://mne.discourse.group/t/unable-to-transform-montage-following-ieeg-electrode-localization-with-gui/5647/1 "2022-09-27T18:06:20Z")

</div>

- MNE version: e.g. 1.0.3
- operating system: e.g. macOS 10.15.7

I am following [this tutorial](https://mne.tools/dev/auto_tutorials/clinical/10_ieeg_localize.html) for locating intracranial electrode contacts with MNE-python in Jupyter Notebook.

I am able to open the GUI using the following code and mark each of my electrode contacts:

```python
mne.gui.locate_ieeg(raw.info, subj_trans, CT_aligned,
                    subject='X',
                    subjects_dir=subject_dir)

```

Upon closing the GUI, I receive the following output message: “Saving channel positions to `info`”. There are no error messages produced.

However, upon running the following code to generate the montage, I receive an error that the montage is ‘NoneType.’

```python
montage= raw.get_montage 
montage.apply_trans(subj_trans)

```

Using the call (raw.\_get\_channel\_positions()) to I can bring the xyz coordinates of each of my electrodes. I am not sure why get\_montage() results in an empty object as I am not receiving an error messages.

Any help is greatly appreciated!! Thank you 🙂

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [September 27, 2022, 7:44pm UTC](https://mne.discourse.group/t/unable-to-transform-montage-following-ieeg-electrode-localization-with-gui/5647/2 "2022-09-27T19:44:00Z")

</div>

Hello @CM2020 and welcome to the forum!

> [@CM2020](#):
>
> ```python
> montage= raw.get_montage 
> 
> ```

This line seems incorrect; you forgot the parentheses to actually invoke the method. It should be:

```python
montage = raw.get_montage()

```

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![CM2020](https://avatars.discourse-cdn.com/v4/letter/c/cdc98d/32.png) [@CM2020](https://mne.discourse.group/u/CM2020)\
**Post date:** [September 27, 2022, 7:57pm UTC](https://mne.discourse.group/t/unable-to-transform-montage-following-ieeg-electrode-localization-with-gui/5647/3 "2022-09-27T19:57:52Z")

</div>

Hello! @richard Thank you for your time and reply. Even after implementing that change, the montage remains empty unfortunately.

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [September 28, 2022, 5:51am UTC](https://mne.discourse.group/t/unable-to-transform-montage-following-ieeg-electrode-localization-with-gui/5647/4 "2022-09-28T05:51:39Z")

</div>

Bummer! I’m afraid I cannot help then, as I’ve never used the iEEG GUI. Maybe @adam2392 or @alexrockhill can help?

---

<div class="post-metadata">

**Author:** ![adam2392](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/adam2392/32/35_2.png) [@adam2392](https://mne.discourse.group/u/adam2392)\
**Post date:** [October 5, 2022, 10:45pm UTC](https://mne.discourse.group/t/unable-to-transform-montage-following-ieeg-electrode-localization-with-gui/5647/5 "2022-10-05T22:45:03Z")

</div>

I’m assuming your `info['dig']` is empty.

[https://github.com/mne-tools/mne-python/blob/4aed3f7257d04e51b4cd84ddf56e5ef755acdd84/mne/io/meas\_info.py#L153-L163](https://github.com/mne-tools/mne-python/blob/4aed3f7257d04e51b4cd84ddf56e5ef755acdd84/mne/io/meas_info.py#L153-L163)

---

<div class="post-metadata">

**Author:** ![CM2020](https://avatars.discourse-cdn.com/v4/letter/c/cdc98d/32.png) [@CM2020](https://mne.discourse.group/u/CM2020)\
**Post date:** [November 20, 2022, 10:52am UTC](https://mne.discourse.group/t/unable-to-transform-montage-following-ieeg-electrode-localization-with-gui/5647/6 "2022-11-20T10:52:07Z")

</div>

Thanks @Richard and @adam2392 for your replies. Greatly appreciate your time and support on this. Apologies for the delayed reply.

@adam2392 - yes, `info['dig']` is empty as well. I found a work-around that allows me to proceed with the pipeline by manually creating the montage instead of using the `montage = raw.get_montage()` call. Here is the code I use:

```python
names = raw.ch_names
locations = raw._get_channel_positions()

x = dict(zip(names, locations)) # creates a dictionary with channel names and locations - this gets passed to the make_dig_montage function later

fiducials = mne.coreg.get_mni_fiducials('subject','/Users/cm2020/Desktop/subject_recon')

LPA = fiducials[0]
LPA = (list(LPA.values()))[2]
Nasion = fiducials[1]
Nasion = (list(Nasion.values()))[2]
RPA = fiducials[2]
RPA = (list(RPA.values()))[2]

montage = mne.channels.make_dig_montage(ch_pos=x,nasion=Nasion, lpa=LPA, rpa=RPA, coord_frame='head')

# head --> mri transformation
montage.apply_trans(subj_trans)

# now let's load our Talairach transform and apply it (mri --> mni_tal transformation)
mri_mni_t = mne.read_talxfm('subject','/Users/cm2020/Desktop/subject_recon')
montage.apply_trans(mri_mni_t) # mri to mni_tal (MNI Taliarach)

```

If possible, can you confirm if there are any potential issues with this method? Still unsure why the montage is empty. Thanks so much!

---

<div class="post-metadata">

**Author:** ![adam2392](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/adam2392/32/35_2.png) [@adam2392](https://mne.discourse.group/u/adam2392)\
**Post date:** [January 12, 2023, 9:18pm UTC](https://mne.discourse.group/t/unable-to-transform-montage-following-ieeg-electrode-localization-with-gui/5647/7 "2023-01-12T21:18:26Z")

</div>

This tentatively looks okay to me…

@alexrockhill might know more about these details

---

<div class="post-metadata">

**Author:** ![alexrockhill](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/alexrockhill/32/31_2.png) [@alexrockhill](https://mne.discourse.group/u/alexrockhill)\
**Post date:** [January 17, 2023, 7:52am UTC](https://mne.discourse.group/t/unable-to-transform-montage-following-ieeg-electrode-localization-with-gui/5647/8 "2023-01-17T07:52:13Z")

</div>

I noticed this recently as well, something has broken/changed about the way `get_montage` works very recently. My workaround was

```python
ch_pos = {ch['ch_name']: ch['loc'][:3] for ch in raw.info['chs']}
montage = mne.channels.make_dig_montage(ch_pos, coord_frame='head')

```

but looks like yours is equivalent.

It has to do with `info['dig']` not being set. I can make a PR soon.

---

<div class="post-metadata">

**Author:** ![alexrockhill](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/alexrockhill/32/31_2.png) [@alexrockhill](https://mne.discourse.group/u/alexrockhill)\
**Post date:** [January 17, 2023, 6:01pm UTC](https://mne.discourse.group/t/unable-to-transform-montage-following-ieeg-electrode-localization-with-gui/5647/9 "2023-01-17T18:01:31Z")

</div>

Cross referencing the PR to fix this [[BUG, MRG] Fix how montage is set in ieeg locate gui by alexrockhill · Pull Request #11421 · mne-tools/mne-python · GitHub](https://github.com/mne-tools/mne-python/pull/11421)
