<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="">
Dear Tibor,
<div class=""><br class="">
</div>
<div class="">Thanks for sharing.</div>
<div class="">Indeed coordinate systems (<a href="https://www.fieldtriptoolbox.org/faq/coordsys/#details-of-the-freesurfer-coordinate-system" class="">https://www.fieldtriptoolbox.org/faq/coordsys/#details-of-the-freesurfer-coordinate-system</a>) are a pain
 in the bum. And indeed Freesurfer is notorious for having the surfaces expressed in a different coordinate system than the corresponding volumetric anatomicals. Specifically, where you mention ’typically’ a volume from the same FreeSurfer processing, I’d say
 it is mandatory to use a reference image (e.g. T1.mgz or so, at least a volume that is in the /mri/ folder of a recon-all output) from the same FreeSurfer pipeline. Alternatively, one can run <a href="https://github.com/fieldtrip/fieldtrip/blob/master/bin/ft_postfreesurferscript.sh" class="">https://github.com/fieldtrip/fieldtrip/blob/master/bin/ft_postfreesurferscript.sh</a> on
 the files in the /surf/ directory, which expresses the output surfaces in the same coordinate system as the input MRI images. (as per line 85 in the referenced shell script).</div>
<div class=""><br class="">
</div>
<div class="">Best wishes and keep up the good work,</div>
<div class=""><br class="">
</div>
<div class="">JM<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 20 Oct 2021, at 13:14, Tibor Auer 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 class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Dear FieldTrippers,<o:p class=""></o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
I came across an issue when atlasing the source-level measures and the sourcemodel was estimated using FreeSurfer cortical sheet.<o:p class=""></o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
The typical code to read the corresponding FreeSurfer annotation uses<span class="Apple-converted-space"> </span><i class="">ft_read_atlas</i>:<o:p class=""></o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<i class="">    atlaslh = ft_read_atlas({‘label/lh.aparc.DKTatlas’,’surf/lh.pial’ },'format','freesurfer_aparc');<o:p class=""></o:p></i></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<i class="">    atlasrh = ft_read_atlas({‘label/rh.aparc.DKTatlas’,’surf/rh.pial’ },'format','freesurfer_aparc');<o:p class=""></o:p></i></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<i class="">    sourceatlas = rmfield(atlaslh,'rgba');<o:p class=""></o:p></i></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<i class="">    sourceatlas.pos = vertcat(atlaslh.pos, atlasrh.pos);<o:p class=""></o:p></i></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<i class="">    sourceatlas.tri = vertcat(atlaslh.tri, atlasrh.tri+size(atlaslh.pos,1));<o:p class=""></o:p></i></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<i class="">    sourceatlas.aparclabel = vertcat(spm_file(atlaslh.aparclabel,'prefix','lh_'),spm_file(atlaslh.aparclabel,'prefix','rh_'));<o:p class=""></o:p></i></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<i class="">    sourceatlas.aparc = vertcat(atlaslh.aparc, atlasrh.aparc+numel(atlaslh.aparclabel));<o:p class=""></o:p></i></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
The issue, however, is that the positions do not correspond to those of the sourcemodel. It is not a FieldTrip issue, but a more generic one. E.g. FSL:<span class="Apple-converted-space"> </span><a href="https://urldefense.com/v3/__https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=fsl;19c45d5b.1803__;!!HJOPV4FYYWzcc1jazlU!s-pXYehuu6woMknmRYORhLOPZ2KHyp8vbG1ReYL_ocY5Ur7pbnHMxCIE2jCayGkh0Wu1LS1L-tAJ9Wc$" style="color: rgb(5, 99, 193); text-decoration: underline;" class="">JISCMail
 - FSL Archives</a>. FSL solves the issue by asking for a reference image (typically a volume from the same FreeSurfer processing). Based on the FSL codes for<span class="Apple-converted-space"> </span><a href="https://urldefense.com/v3/__https://open.win.ox.ac.uk/pages/fsl/fsleyes/fsleyes/apidoc/_modules/fsleyes/displaycontext/meshopts.html__;!!HJOPV4FYYWzcc1jazlU!s-pXYehuu6woMknmRYORhLOPZ2KHyp8vbG1ReYL_ocY5Ur7pbnHMxCIE2jCayGkh0Wu1LS1L6P1iGA4$" style="color: rgb(5, 99, 193); text-decoration: underline;" class="">fsleyes</a><span class="Apple-converted-space"> </span>and<span class="Apple-converted-space"> </span><a href="https://urldefense.com/v3/__https://git.fmrib.ox.ac.uk/fsl/fslpy/-/blob/master/fsl/data/mghimage.py__;!!HJOPV4FYYWzcc1jazlU!s-pXYehuu6woMknmRYORhLOPZ2KHyp8vbG1ReYL_ocY5Ur7pbnHMxCIE2jCayGkh0Wu1LS1La76onHQ$" style="color: rgb(5, 99, 193); text-decoration: underline;" class="">fsl.data.mghimage</a>,
 I managed to implement something similar in MATLAB:<o:p class=""></o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<i class="">    fsmri = MRIread(‘mri/T1.mgz’);<o:p class=""></o:p></i></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<i class="">    sourceatlas = ft_transform_geometry(fsmri.vox2ras/fsmri.tkrvox2ras, sourceatlas);<o:p class=""></o:p></i></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
After transformation, the sourceatlas will be aligned to the sourcemodel.<o:p class=""></o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Kind regards,<o:p class=""></o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span class="">Tibor<span class="Apple-converted-space"> </span></span><span lang="HU" class=""><o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span class=""> </span><span lang="HU" class=""><o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<b class=""><span style="color: rgb(34, 42, 53);" class="">Auer, Tibor M.D. Ph.D.</span></b><span lang="HU" class=""><o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<b class=""><span style="color: rgb(0, 102, 255);" class="">Research Fellow</span></b><span lang="HU" class=""><o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<b class=""><span style="color: rgb(0, 102, 255);" class="">School of Psychology, Faculty of Health and Medical Sciences</span></b><span lang="HU" class=""><o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span class="">University of Surrey, Guildford GU2 7XH</span><span lang="HU" class=""><o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span class=""><a href="mailto:T.Auer@surrey.ac.uk" style="color: rgb(5, 99, 193); text-decoration: underline;" class=""><span style="color: rgb(5, 99, 193);" class="">T.Auer@surrey.ac.uk</span></a></span><span lang="HU" class=""><o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span class=""><a href="https://urldefense.com/v3/__https://eur02.safelinks.protection.outlook.com/?url=https*3A*2F*2Ftwitter.com*2FTiborAuer&data=04*7C01*7Ct.auer*40surrey.ac.uk*7C5f32dba325f5422f5c5a08d8becc029f*7C6b902693107440aa9e21d89446a2ebb5*7C0*7C0*7C637469131016806177*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C1000&sdata=wkpejqTmmo*2Fe4JA9QIaA6Z3*2BzipbFY*2FCEmRXC9UvKJs*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSU!!HJOPV4FYYWzcc1jazlU!s-pXYehuu6woMknmRYORhLOPZ2KHyp8vbG1ReYL_ocY5Ur7pbnHMxCIE2jCayGkh0Wu1LS1LYjZgM-Y$" style="color: rgb(5, 99, 193); text-decoration: underline;" class=""><span style="color: rgb(5, 99, 193);" class="">@TiborAuer</span></a></span><span lang="HU" class=""><o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
</div>
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">fieldtrip
 mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" style="color: rgb(5, 99, 193); text-decoration: underline; font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!s-pXYehuu6woMknmRYORhLOPZ2KHyp8vbG1ReYL_ocY5Ur7pbnHMxCIE2jCayGkh0Wu1LS1LhbTATZM$" style="color: rgb(5, 99, 193); text-decoration: underline; font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!s-pXYehuu6woMknmRYORhLOPZ2KHyp8vbG1ReYL_ocY5Ur7pbnHMxCIE2jCayGkh0Wu1LS1LhbTATZM$</a><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""></span></div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>