How to create a DIG montage for an iEEG dataset?

Dear community,

I am following the iEEG electrode localisation tutorial. However, I am finding a problem when I try to translate the electrodes from native space to the standard space.
That is, when calling:

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

I get the following error:
‘NoneType’ object has no attribute ‘apply_trans’

It seems that I am not getting a correct montage class, as “apply_trans” is not an option in the variable.

I believe that this happens because raw.info[‘dig’] is empty. Thus, I would like to know can I create the dig structure for the iEEG data? I could not identify that information in the tutorial.

Based on previously performed manual CT-T1 corregistration, I can find the electrode channels localization in raw.info[‘chs’].

Should I use the function mne.channels.make_dig_montage() and export the channels localisation from raw.info to the ch_pos=None argument? Then, nasion, lpa and rpa are native space coordinates extracted from the T1? Finally, should I select a specific coord_frame reference?

Thanks for your help!,

I am using OSX Monterrey, 12.3.1 in Jupyter Lab with the following libs (an others not listed)
mne 1.1.1

Ok,

I have solved the problem.

I created the DIG montage using the native space nasion, lpa and rpa coordinates and transforming them to meters:

div = 1000
nas = (4.02/div, 81.26/div, -6.73/div) 
lpa = (74.22/div, -23.21/div, -56.93/div) 
rpa = (-77.89/div, -15.74/div, -33.50/div)

Then I select the iEEG channels that correspond to active electrodes in my dataset:

idx = mne.pick_channels_regexp(raw.ch_names, '^FBR|^HM|^HL|^IAS|^IL|^HAR|^PIR|^IPR|^IAR|^CAR|^CAL|^IASR') 
# selecting 

def get_list(thelist, items):
    elements = [e for i, e in enumerate(thelist) if i in items]
    return elements

# selecting channels from info dict
locs = get_list(ras.info['chs'], idx) 

# creating a dict with chan name and its position
pos_chanels = {}
for i in range(len(locs)):
    pos_chanels[locs[i]['ch_name']] = tuple(locs[i]['loc'][0:3])
    #print(locs[i]['loc'][0:3])

Then I pick only those chanels that I have localised in my dataset

chans = get_list(raw.ch_names, idx)  # sel chan names
raw.pick_channels(ch_names = chans)

And finally I prepared the DIG montage

montage = mne.channels.make_dig_montage(ch_pos = pos_chanels, nasion=nas, lpa=lpa, rpa=rpa, hsp=None, hpi=None, coord_frame = "head")
raw.set_montage(montage)

And this is it. Probably there is a more elegant way to do this, I would be glad to hear about it. Anyways, I hope this could help other people facing the same problem.

Best!

2 Likes