[FieldTrip] polhemus-mri coregistration for OPM

Kirandeep Kaur kkaur.aiims at gmail.com
Wed Jul 8 18:02:04 CEST 2026


Dear all, I am working with Mag4Health OPM data, We are using the polhemus
system to create the headshape (which is separately co-registered with opm
sensors).

Therefore, we are creating a 'headshape' structure from scratch, and trying
to co-register this 'headshape' with mri (.nii format). However, when I try
to do this, the polhemus cloud is ~400mm away from the mri surface, and is
oriented at 90 degrees to the MRI (in the plottted figure-mri is facing
MATLAB's x -axis, polhemus cloud is facing y-axis).
We have already taken steps to ensure that coordinate system/orientation is
in 'neuromag' system for both polhemus and mri (+x= right, +y= anterior,
+z=superior). So I am quite confused about what is going on.

Shared my code here below:
----------------------------------------------------------------------------------------
% The headshape struct in fieldtrip consiststs of the following fields:
%         pos: [N×3 double]  #in cm to begin with
%         fid: [1×1 struct] # to be left empty for now
%       label: {N×1 cell}
%    coordsys: 'neuromag'
%        unit: 'cm' % converted to mm before coregistration

% From the dopm_calib_coreg.m, we are importing the following fields in
% headshape_H2.mat file: pos [NX3], coordsys, unit.

%% Create the headsape struct
headshape = headshape_H2;

% add dummy labels to the polhemus points
headshape.label = cell(size(headshape.pos, 1),1);
for i = 1:size(headshape.pos, 1)
    headshape.label{i}= sprintf('extra_%d', i);
end

% check once
ft_plot_headshape(headshape)

%% re-align the volume
% re-align the volume to neuromag coordinates as a first step
%mark the n,l,r points, then press q to escape
close all force
cfg=[];
cfg.method='interactive';
cfg.coordsys='neuromag';
mri_neuromag=ft_volumerealign(cfg,mri_orig);

% re-align using the headshape
headshape=ft_convert_units(headshape, 'mm');
cfg=[];
cfg.method='headshape';
cfg.headshape.headshape=headshape;
cfg.headshape.icp='yes';
cfg.headshape.interactive='yes';
cfg.coordsys= 'neuromag';
mri_realigned=ft_volumerealign(cfg, mri_neuromag);
close all force
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20260708/12760f19/attachment.htm>


More information about the fieldtrip mailing list