<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Benjy,
<div class=""><br class="">
</div>
<div class="">There’s an error in your logic here: the template MRI is defined in a RAS coordinate space, and you want to align it to the fiducial-based coordinate space. The alignment procedure is based on the assumption that the coordinates of the fiducials
are expressed in the same coordinate space as the input MRI, which is not the case, because they are already expressed in the fiducial-based coordinate space.</div>
<div class=""><br class="">
</div>
<div class="">Also I think that your expression ‘I will end up with one head model for all subjects’ is actually true (and unavoidable), because you are using a single template MRI. What you probably wanted to say is that you want a subject-specific coregistration
of the template headmodel to the sensor array, based on the subject-specific position in the MEG device during the measurement. The latter information is not present in the headshape files, but is reflected in the position of the sensors (expressed in head
coordinates). You may consider making all this a bit more fancy by warping the headmodel (inflating/shrinking) based on the participant’s headshape derived head size, but I think that this is tricky. </div>
<div class=""><br class="">
</div>
<div class="">Good luck and best wishes,</div>
<div class="">Jan-Mathijs<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 21 Mar 2023, at 20:45, Barnett, Benjy via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" class="">fieldtrip@science.ru.nl</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hey Guys,
<div class=""><br class="">
</div>
<div class="">I am trying to create a head model using a template anatomical MRI and the fiducial points included in my CTF MEG data. However, when I include the fiducial points as returned by ft_read_heashape, it causes the head model and sensors to be completely
misaligned (see attached photo). I have tried with and without converting them both into mm units using ft_convert_units but this did not help. The process works if I use the interactive method in ft_volumerealign so I’m sure the error is coming at this point.
The reason I do not want to use the interactive method is because if I do that I will end up with one head model for all subjects (as I would just be clicking on the same fiducial points for each subject). I want to use the fiducial points measured by the
MEG system per subject, to improve the fit of the head model for each subject. I’ve included my code below. </div>
<div class=""><br class="">
</div>
<div class="">Would you be able to help me figure out how to use subject specific, MEG-measured fiducial points in the volume realignment step of the forward-model process? Thank you.</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(170, 4, 249);" class="">
<span style="" class="">mri = ft_read_mri(</span>‘~\template\anatomy\single_subj_T1.nii'<span style="" class="">);</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);" class="">
%get fiducial points</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(170, 4, 249);" class="">
<span style="" class="">raw_data_dir = fullfile(</span>‘~\data\Raw'<span style="" class="">,subject,</span>'meg'<span style="" class="">,</span>'raw'<span style="" class="">);</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Courier" class=""><span style="font-size: 11px;" class="">dataSets = str2fullfile(raw_data_dir,</span></font><font color="#aa04f9" face="Courier" class=""><span style="caret-color: rgb(170, 4, 249); font-size: 11px;" class="">’</span><span style="font-size: 11px;" class="">*wildcard*'</span></font><font face="Courier" class=""><span style="font-size: 11px;" class="">);</span></font></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
ds = dataSets(1);</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
head = ft_read_headshape(ds);</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">head = ft_convert_units(head,<span style="color: rgb(243, 35, 255);" class="">'mm'</span>);</div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; min-height: 13px;" class="">
<br class="">
</div>
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);" class="">
%align to ctf</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
cfg = [];</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
cfg.method = <span style="color: #aa04f9" class="">'fiducial'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
cfg.coordsys = <span style="color: #aa04f9" class="">'ctf'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
cfg.fiducial.nas = head.fid.pos(1,:);</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
cfg.fiducial.lpa = head.fid.pos(2,:);</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
cfg.fiducial.rpa = head.fid.pos(3,:);</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
mri_realigned = ft_volumerealign(cfg,mri);</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; min-height: 13px;" class="">
%And then the rest of the code to create the head model, which I believe is correct.</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);" class="">
%segment brain from skull</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
cfg = [];</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
cfg.output = <span style="color: #aa04f9" class="">'brain'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
segmentedmri = ft_volumesegment(cfg, mri_realigned);</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);" class="">
% Build volume conduction model from geometry of brain</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
cfg = [];</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(170, 4, 249);" class="">
<span style="" class="">cfg.method=</span>'singleshell'<span style="" class="">;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
vol = ft_prepare_headmodel(cfg, segmentedmri);</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);" class="">
% Visualise</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
vol = ft_convert_units(vol, <span style="color: #aa04f9" class="">'cm'</span>);</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
sens = ft_read_sens(ds{1}, <span style="color: #aa04f9" class="">'senstype'</span>,
<span style="color: #aa04f9" class="">'meg'</span>);</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
figure</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(170, 4, 249);" class="">
<span style="" class="">ft_plot_sens(sens, </span>'coilshape'<span style="" class="">,</span>'point'<span style="" class="">,</span>'style'<span style="" class="">,
</span>'r+'<span style="" class="">);</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
hold <span style="color: #aa04f9" class="">on</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
ft_plot_headmodel(vol);</div>
</div>
<div class=""><span id="cid:0A5F1B61-897A-45A3-8BFF-B7E25928C878@cust.communityfibre.co.uk"><Screenshot 2023-03-21 at 7.36.36 PM.png></span></div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!59U0dhFLXtFqU5wZuQmpd-_WZi7AWfvdXqv651a3wjZcavfUAzddhNHRLfBMhHPdt9HgEM_6OqN1CfwORWtahrI3vaDjWMskhLlKzQ$
<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>