<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
Hi Kirandeep,
<div><br>
</div>
<div>There’s no figure attached, so it’s difficult for me to comment to the point.</div>
<div><br>
</div>
<div>My first thought is that the ‘headshape’ is in a coordinate system that is not aligned with what you think it should be.</div>
<div><br>
</div>
<div>Can you do </div>
<div><br>
</div>
<div>ft_plot_headshape(headshape);</div>
<div><br>
</div>
<div>followed by</div>
<div><br>
</div>
<div>ft_plot_axes(headshape).</div>
<div><br>
</div>
<div>This should give you an image that shows the origin of the 3D-axes in the middle of the point cloud, with the x-axis pointing to the right, y-axis to the front, z-axis to the top. At least, this is what I would expect if you say that the coordinate system
is in ’neuromag’ coordinates.</div>
<div><br>
</div>
<div>If this is not the case, it would explain the misalignment in the interactive figure when calling ft_volumerealign</div>
<div><br>
</div>
<div><br>
</div>
<div>Best wishes,</div>
<div>Jan-Mathijs</div>
<div><br>
</div>
<div>
<div><br>
<blockquote type="cite">
<div>On 8 Jul 2026, at 18:02, Kirandeep Kaur via fieldtrip <fieldtrip@science.ru.nl> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div dir="ltr">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).
<div><br>
</div>
<div>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).</div>
<div>We have already taken steps to ensure that coordinate system/orientation is in 'neuromag' system for both polhemus and mri (+x= right, +y= anterior, <a class="gmail_plusreply" id="plusReplyChip-1">+z=superior).</a> So I am quite confused about what is
going on. </div>
<div><br>
</div>
<div>Shared my code here below: </div>
<div>----------------------------------------------------------------------------------------<br>
% The headshape struct in fieldtrip consiststs of the following fields: <br>
% pos: [N×3 double] #in cm to begin with<br>
% fid: [1×1 struct] # to be left empty for now<br>
% label: {N×1 cell} <br>
% coordsys: 'neuromag'<br>
% unit: 'cm' % converted to mm before coregistration<br>
<br>
% From the dopm_calib_coreg.m, we are importing the following fields in<br>
% headshape_H2.mat file: pos [NX3], coordsys, unit. <br>
<br>
%% Create the headsape struct<br>
headshape = headshape_H2; <br>
<br>
% add dummy labels to the polhemus points<br>
headshape.label = cell(size(headshape.pos, 1),1); <br>
for i = 1:size(headshape.pos, 1)<br>
headshape.label{i}= sprintf('extra_%d', i);<br>
end<br>
<br>
% check once <br>
ft_plot_headshape(headshape)<br>
<br>
%% re-align the volume <br>
% re-align the volume to neuromag coordinates as a first step<br>
%mark the n,l,r points, then press q to escape<br>
close all force<br>
cfg=[]; <br>
cfg.method='interactive'; <br>
cfg.coordsys='neuromag'; <br>
mri_neuromag=ft_volumerealign(cfg,mri_orig);<br>
<br>
% re-align using the headshape <br>
headshape=ft_convert_units(headshape, 'mm');<br>
cfg=[]; <br>
cfg.method='headshape'; <br>
cfg.headshape.headshape=headshape; <br>
cfg.headshape.icp='yes'; <br>
cfg.headshape.interactive='yes'; <br>
cfg.coordsys= 'neuromag'; <br>
mri_realigned=ft_volumerealign(cfg, mri_neuromag); <br>
close all force<br>
<div><br>
</div>
</div>
</div>
_______________________________________________<br>
fieldtrip mailing list<br>
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<br>
https://doi.org/10.1371/journal.pcbi.1002202<br>
</div>
</blockquote>
</div>
<br>
</div>
</body>
</html>