Custom the sensor location for MEG in raw objects?

Hi, I’m recently learning to use MNE-pyhton to analyze cerebral magnetic data. I created the raw object from scratch and I need the MEG sensor position information for the subsequent drawing of the scalp topography, I tried the montage but this does not set the ‘mag’ channel type. My question is how can I add the MEG sensor position information to the raw object?

all MEG file formats I know of already include sensor positions. You can check raw.info['chs'] to see if sensor locations are already present.

I am creating raw object from scratch with my own data, I tried to add sensor position to raw object with montage, it failed, I checked the official website documentation and learned that ‘mag’ channel type cannot add sensor position with montage, I would like to ask if you have any tips about this situation?

In that case, you’ll have to populate info['chs'] manually. My advise is to load the sample MEG dataset and carefully examine this dictionary and read mne.Info — MNE 1.3.0 documentation. It’s going to be a tricky endeavor though. Sorry I can’t be of more help.

1 Like

Okay, I appreciate your patience with my question.

Hello, if it is a custom OPM sensor, how can I get the rotation matrix representing the normal direction of the sensor?

like this:
First specify the channel type as eeg, and then create montage,
Finally, change each channel type to MEG:

montage = mne.channels.make_dig_montage(ch_pos=dic, coord_frame=‘head’)
info = mne.create_info(ch_names=loc_name,
ch_types=tts,
sfreq=freq

rawData = mne.io.RawArray(data, info)
rawData = rawData.set_montage(montage)

rawData.info[‘dig’][j][‘kind’] = 4
rawData.info[‘chs’][j][‘kind’] = mne.io.constants.FIFF.FIFFV_MEG_CH
rawData.info[‘chs’][j][‘unit’] = mne.io.constants.FIFF.FIFF_UNIT_T
rawData.info[‘chs’][j][‘loc’][3:12] = np.array([1., 0., 0., 0., 1., 0., 0., 0., 1.])