How to create a DIG montage for an iEEG dataset?

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