Unable to transform montage following iEEG electrode localization with GUI

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

I am following this tutorial 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:

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.’

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 :slight_smile:

Hello @CM2020 and welcome to the forum!

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

montage = raw.get_montage()

Best wishes,
Richard

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

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

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

https://github.com/mne-tools/mne-python/blob/4aed3f7257d04e51b4cd84ddf56e5ef755acdd84/mne/io/meas_info.py#L153-L163

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:

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!