# How to create a DIG montage for an iEEG dataset?

**URL:** <https://mne.discourse.group/t/how-to-create-a-dig-montage-for-an-ieeg-dataset/5851>\
**Category:** Support & Discussions\
**Created:** [November 1, 2022, 6:59pm UTC](https://mne.discourse.group/t/how-to-create-a-dig-montage-for-an-ieeg-dataset/5851 "2022-11-01T18:59:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alepebel](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/alepebel/32/1508_2.png) [@alepebel](https://mne.discourse.group/u/alepebel)\
**Post date:** [November 1, 2022, 6:59pm UTC](https://mne.discourse.group/t/how-to-create-a-dig-montage-for-an-ieeg-dataset/5851/1 "2022-11-01T18:59:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alepebel](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/alepebel/32/1508_2.png) [@alepebel](https://mne.discourse.group/u/alepebel)\
**Post date:** [November 2, 2022, 3:14pm UTC](https://mne.discourse.group/t/how-to-create-a-dig-montage-for-an-ieeg-dataset/5851/2 "2022-11-02T15:14:07Z")

</div>

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:

```python
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:

```python
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

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

```

And finally I prepared the DIG montage

```python
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!
