# Custom OPM sensor montages

**URL:** <https://mne.discourse.group/t/custom-opm-sensor-montages/3159>\
**Category:** Support & Discussions\
**Created:** [May 20, 2021, 12:40pm UTC](https://mne.discourse.group/t/custom-opm-sensor-montages/3159 "2021-05-20T12:40:30Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbardouille](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/tbardouille/32/527_2.png) [@tbardouille](https://mne.discourse.group/u/tbardouille)\
**Post date:** [May 20, 2021, 12:40pm UTC](https://mne.discourse.group/t/custom-opm-sensor-montages/3159/1 "2021-05-20T12:40:30Z")

</div>

Hi there,

Is there a way to import MEG position and orientation into the raw data in MNE?

Some details: I’m using MNE with a custom OPM system. I can import my data into MNE easily because it is collected in a fif file. However, there is no sensor orientation and location info on the fif because the vendor doesn’t provide that functionality yet.

I have digitized the sensor positions and orientations myself, and now I’d like to import the sensor positions and orientations.

There is some set custom montage functionality in MNE, but it seems to be EEG specific. I couldn’t find similar montage functionality for MEG - I’m guessing because custom MEG montages are a new problem due to OPM.

Your advice would be greatly appreciated.

Thanks,  
Tim.

---

<div class="post-metadata">

**Author:** ![agramfort](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@agramfort](https://mne.discourse.group/u/agramfort)\
**Post date:** [May 20, 2021, 7:30pm UTC](https://mne.discourse.group/t/custom-opm-sensor-montages/3159/2 "2021-05-20T19:30:58Z")

</div>

hi Tim,

have you looked at [https://mne.tools/stable/auto\_examples/datasets/opm\_data.html](https://mne.tools/stable/auto_examples/datasets/opm_data.html) ?

Alex

---

<div class="post-metadata">

**Author:** ![tbardouille](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/tbardouille/32/527_2.png) [@tbardouille](https://mne.discourse.group/u/tbardouille)\
**Post date:** [May 20, 2021, 8:14pm UTC](https://mne.discourse.group/t/custom-opm-sensor-montages/3159/3 "2021-05-20T20:14:23Z")

</div>

Thanks Alex!

Based on your suggestion, I found mne.use\_coil\_def, which I think is there to define the sensor volume. I will need a file like this for the FieldLine OPM sensors. Is there any guidance on the file format that I can use for making my own coil\_def files for Fieldline sensors?

Regarding the sensor locations and orientation (with respect to the head), this seems to be already in the raw .fif file in the opm\_data.html example. It looks like it is in raw.info[‘chs’][i][‘loc’]. Is that correct?

Best,  
Tim.

---

<div class="post-metadata">

**Author:** ![tbardouille](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/tbardouille/32/527_2.png) [@tbardouille](https://mne.discourse.group/u/tbardouille)\
**Post date:** [May 20, 2021, 8:30pm UTC](https://mne.discourse.group/t/custom-opm-sensor-montages/3159/4 "2021-05-20T20:30:45Z")

</div>

Some additional information.

In the MNE example (QuSpin), if I look at raw.info[‘ch’][0], I get the following results  
In [15]: raw.info[‘chs’][0]  
Out[15]:  
{‘scanno’: 1,  
‘logno’: 1111,  
‘kind’: 1 (FIFFV\_MEG\_CH),  
‘range’: 1.0,  
‘cal’: 3.7000000285836165e-10,  
‘coil\_type’: 9999,  
‘loc’: array([ 0.0160798 , 0.03519166, 0.1367435 , -0.013699 , 0.97966099,  
-0.200192 , -0.99316001, 0.0099 , 0.116395 , 0.11601 ,  
0.200417 , 0.97282499]),  
‘unit’: 112 (FIFF\_UNIT\_T),  
‘unit\_mul’: 0 (FIFF\_UNITM\_NONE),  
‘ch\_name’: ‘MEG1111’,  
‘coord\_frame’: 1 (FIFFV\_COORD\_DEVICE)}

For my system (FieldLine), here is what the info looks like. Clearly, the loc data needs to be updated.  
In [20]: rawFL.info[‘chs’][0]  
Out[20]:  
{‘scanno’: 1,  
‘logno’: 1,  
‘kind’: 1 (FIFFV\_MEG\_CH),  
‘range’: 1.0,  
‘cal’: 7.047108980363866e-17,  
‘coil\_type’: 3024 (FIFFV\_COIL\_VV\_MAG\_T3),  
‘loc’: array([-3., 3., 4., 0., 0., 0., 0., 0., 0., 0., 0., 0.]),  
‘unit’: 112 (FIFF\_UNIT\_T),  
‘unit\_mul’: 0 (FIFF\_UNITM\_NONE),  
‘ch\_name’: ‘00:01:28’,  
‘coord\_frame’: 1 (FIFFV\_COORD\_DEVICE)}

Can you advise on the contents of ‘loc’ array, as well as how to make a coil\_def.dat file?

Best,  
Tim.

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [May 20, 2021, 8:49pm UTC](https://mne.discourse.group/t/custom-opm-sensor-montages/3159/5 "2021-05-20T20:49:35Z")

</div>

I think FieldLine coil defs were added last week, maybe updating to latest development version will be enough? see [MRG, ENH: Add FieldLine and Kernel OPMs (#9394) · mne-tools/mne-python@323ab3f · GitHub](https://github.com/mne-tools/mne-python/commit/323ab3fd683d81be55bf328d7c2bc8083c4ec104)

---

<div class="post-metadata">

**Author:** ![tbardouille](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/tbardouille/32/527_2.png) [@tbardouille](https://mne.discourse.group/u/tbardouille)\
**Post date:** [May 20, 2021, 8:53pm UTC](https://mne.discourse.group/t/custom-opm-sensor-montages/3159/6 "2021-05-20T20:53:04Z")

</div>

Thanks Dan. I will update to running the dev version then. This is awesome!

Any advice as to the elements of the ‘loc’ array in raw.info[‘chs’]?

Best,  
Tim.

---

<div class="post-metadata">

**Author:** ![tbardouille](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/tbardouille/32/527_2.png) [@tbardouille](https://mne.discourse.group/u/tbardouille)\
**Post date:** [May 21, 2021, 12:48pm UTC](https://mne.discourse.group/t/custom-opm-sensor-montages/3159/7 "2021-05-21T12:48:23Z")

</div>

Hi Dan and Alex,

I’m still learning about the functionality of MNE python, so thanks for your patience. I’ve gotten closer to the solution of my issue with setting sensor location and orientation wrt the head, but have a couple of follow up questions. Hopefully, this will get me to the finish line.

On the MNE python website, I found the following about the Info class:  
**loc** array, shape (12,)  
_Channel location. For MEG this is the position plus the normal given by a 3x3 rotation matrix. For EEG this is the position followed by reference position (with 6 unused). The values are specified in device coordinates for MEG and in head coordinates for EEG channels, respectively._

In the OPM example Alex recommended above, it has **raw.info[‘chs’][0][‘loc’]** equal to:  
([ 0.0160798 , 0.03519166, 0.1367435 , -0.013699 , 0.97966099,  
-0.200192 , -0.99316001, 0.0099 , 0.116395 , 0.11601 ,  
0.200417 , 0.97282499])

Can you please help me with the following questions?

1. Does that mean that the location is: [0.0160798 , 0.03519166, 0.1367435]
2. Is the location array in metres?
3. Is the rotation matrix correctly reshaped as follows?  
-0.013699 , 0.97966099, -0.200192 ,  
-0.99316001, 0.0099, 0.116395 ,  
0.11601, 0.200417, 0.97282499

Thanks for your help on this.

Tim.

---

<div class="post-metadata">

**Author:** ![agramfort](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@agramfort](https://mne.discourse.group/u/agramfort)\
**Post date:** [May 21, 2021, 1:10pm UTC](https://mne.discourse.group/t/custom-opm-sensor-montages/3159/8 "2021-05-21T13:10:40Z")

</div>

hi Tim,

> I’m still learning about the functionality of MNE python, so thanks for your patience. I’ve gotten closer to the solution of my issue with setting sensor location and orientation wrt the head, but have a couple of follow up questions. Hopefully, this will get me to the finish line.

🚵‍♂️ 😀

> On the MNE python website, I found the following about the Info class:  
> **loc** array, shape (12,)  
> _Channel location. For MEG this is the position plus the normal given by a 3x3 rotation matrix. For EEG this is the position followed by reference position (with 6 unused). The values are specified in device coordinates for MEG and in head coordinates for EEG channels, respectively._
> 
> In the OPM example Alex recommended above, it has **[raw.info](http://raw.info)[‘chs’][0][‘loc’]** equal to:  
> ([ 0.0160798 , 0.03519166, 0.1367435 , -0.013699 , 0.97966099,  
> -0.200192 , -0.99316001, 0.0099 , 0.116395 , 0.11601 ,  
> 0.200417 , 0.97282499])
> 
> Can you please help me with the following questions?
> 
> 1. Does that mean that the location is: [0.0160798 , 0.03519166, 0.1367435]

yes

> 1. Is the location array in metres?

yes

> 1. Is the rotation matrix correctly reshaped as follows?  
> -0.013699 , 0.97966099, -0.200192 ,  
> -0.99316001, 0.0099, 0.116395 ,  
> 0.11601, 0.200417, 0.97282499

I would say yes but if not just transpose.

I would use plot\_alignment anyway once set to see how it looks

Alex

---

<div class="post-metadata">

**Author:** ![tbardouille](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/tbardouille/32/527_2.png) [@tbardouille](https://mne.discourse.group/u/tbardouille)\
**Post date:** [May 25, 2021, 3:07pm UTC](https://mne.discourse.group/t/custom-opm-sensor-montages/3159/9 "2021-05-25T15:07:21Z")

</div>

This is great! Thank you. I should be good from here.

Thanks for all you do for this research community!

Best,  
Tim.

---

<div class="post-metadata">

**Author:** ![prodaking](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/prodaking/32/2305_2.png) [@prodaking](https://mne.discourse.group/u/prodaking)\
**Post date:** [March 2, 2023, 1:51pm UTC](https://mne.discourse.group/t/custom-opm-sensor-montages/3159/10 "2023-03-02T13:51:05Z")

</div>

Hello, if it is a custom OPM sensor, how can I get the rotation matrix representing the normal direction of the sensor? I want to know which vector gets the normal direction of the current sensor after passing through the rotation matrix.

---

<div class="post-metadata">

**Author:** ![yuyu](https://avatars.discourse-cdn.com/v4/letter/y/71e660/32.png) [@yuyu](https://mne.discourse.group/u/yuyu)\
**Post date:** [May 19, 2023, 11:28am UTC](https://mne.discourse.group/t/custom-opm-sensor-montages/3159/11 "2023-05-19T11:28:35Z")

</div>

> [@agramfort](#):
>
> rotation matrix

hello,everyone, Does the qustion has a solution? if the direction of meg sensor is know (n1,n2,n3)，How can we get the rotation matrix (e11,e12,e13;e21,e22,e23;e31,e32,e33)?

---

<div class="post-metadata">

**Author:** ![Jeroen](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Jeroen](https://mne.discourse.group/u/Jeroen)\
**Post date:** [September 5, 2025, 9:49am UTC](https://mne.discourse.group/t/custom-opm-sensor-montages/3159/12 "2025-09-05T09:49:23Z")

</div>

hi all, I know the last message here was quite a while, but I don’t exactly get how the supposed implemented Fieldline Montage has to be defined, while working with Fieldline OPM data in mne. I did not ocme across a possibility to specify the OPM system used for recording the data, or is this information already transformed within the .fif, and we dont need to specify this info in mne anymore?  
thanks for any help!

---

<div class="post-metadata">

**Author:** ![Jeroen](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Jeroen](https://mne.discourse.group/u/Jeroen)\
**Post date:** [September 5, 2025, 1:35pm UTC](https://mne.discourse.group/t/custom-opm-sensor-montages/3159/13 "2025-09-05T13:35:26Z")

</div>

and maybe to specifiy a bit further: we are using a custom helmet, so no SmartHelm from Fieldline, meaning we have to integrate the custom helm sensor coordinates, based on AC-PC MRI coordinates, into the data. these are not stored within the .fif file as far as I reckon at the moment.  
Someone with any experience in that here?
