<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Nicola,<div><br></div><div>Would it make sense to look into the possibility to improve support for using the polhemus info from the .fif file directly? It sounds a bit silly that you have to go through another piece of software to be able to read in the data. From ft_read_headshape it seems that *.fif files are supported, could it be that your data is not recognized as such?</div><div><br></div><div>Best,</div><div>JM</div><div><br></div><div><br></div><div><br><div><div>On Nov 6, 2013, at 11:52 AM, Nicola Molinaro wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Thanks guys for any possible help. Really appreciate it!<div><br></div><div>I will summarize my tests:</div><div><br></div><div>1. reading the COR-<filename>.fif produced by MRIlab with ft_read_mri</div>
<div><br></div><div>Well, it seems that ft_read_mri reads the original (not coregistered) .fif file produced in earlier steps of the forward model calculation (COR.fif). For example, if I delete the COR.fif file, ft_read_mri gives an error. ft_read_mri applied to the COR-<filename>.fif should be able to read some header, and for this reason I tried the option suggested by Joram (including ft_volumereslice). However, when I plot the volume head model with </div>
<div><br></div><div><div><i>hs=ft_read_headshape(<meg_raw_filename>.fif. 'unit','mm'); %get headshape points</i></div><div><i>ft_plot_vol(vol)</i></div><div><i>ft_plot_headshape(hs)</i></div></div><div>
<br></div><div>There is an evident misalignment between isotrack points and the brain volume. I mean NO coregistration is done. you can also appreciate it when plotting a prearicular instead of the nasion with </div><div>
<br></div><div><div><i>cfg = [];</i></div><div><i>cfg.location = [66.4 0 0]; %%% fill in a fiducial point from the current subject by hand, to check if coregistration went correctly</i></div><div><i>cfg.locationcoordinates = 'head';</i></div>
<div><i>ft_sourceplot(cfg,mri);</i></div></div><div><br></div><div>Take home message: Fieldtrip does not read the coregistration done in MRIlab, and you have to coregister MEG and MRI again.</div><div><br></div><div>2. Using </div>
<div><br></div><div><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">cfg.method = 'headshape'</span><br></div><div>cfg.headshape = 'XXX.pos'</div><div><br></div><div>for ft_volumerealign. I played with it, but in neuromag the polhemous data are within the header of the <i><meg_raw_filename>.fif</i> file. You can export the isotrack point however from MRIlab. After importing then with </div>
<div><br></div><div>File>Import>Isotrack data</div><div><br></div><div>you can then export them with </div><div><br></div><div>File>Export>Points </div><div><br></div><div>and specifying the coordinate system in which you want your point (either Head, or MRI or Voxel). This file cannot be read by ft_volumerealign with the headshape method. However, the first three lines of the resulting .txt file will give you the nasion and the two pre-auricolar points positions. I tried importing the voxel positions of the three points in ft_volumerealign using the method</div>
<div><br></div><div><div>cfg.coordsys = 'neuromag';</div><div>cfg.method = 'fiducial';</div></div><div><br></div><div>And it worked, the brain volume is aligned with the isotrack points. This is the only solution that is visually reliable to perform </div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Nov 6, 2013 at 10:06 AM, Joram van Driel <span dir="ltr"><<a href="mailto:joramvandriel@gmail.com" target="_blank">joramvandriel@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hi Nicola,</div><div><br></div><div>I also did coregistration in MRI-lab using isotrak data.</div>
<div>Importing the fif files in fieldtrip worked fine, I don’t think you have to apply ft_volumerealign again. I suspect ft_volumereslice is a crucial ingredient.</div><div>This worked for me:</div><div><br></div><div><div>
<font face="Monaco" size="1"> mri = ft_read_mri(<mri.fif>); %%% read the MRI; the fif file is in mm but FT changes it into meters </font></div><div><font face="Monaco" size="1"> mri = ft_convert_units(mri,'mm'); %%% make it mm as it originally was</font></div>
<div><font face="Monaco" size="1"> mri = ft_volumereslice([], mri); %%% after this function the ficual points in the MEG header match the coordinates in the MRI</font></div></div><div><br></div><div>Then you should indeed check this with ft_sourceplot, where in the cfg you can fill in fiducial points to check if they make sense, e.g.:</div>
<div><br></div><div><div><font face="Monaco" size="1"> cfg = [];</font></div><div><font face="Monaco" size="1"> cfg.location = [0 90.5 0]; %%% fill in a fiducial point from the current subject by hand, to check if coregistration went correctly</font></div>
<div><font face="Monaco" size="1"> cfg.locationcoordinates = 'head';</font></div><div><font face="Monaco" size="1"> </font></div><div><font face="Monaco" size="1"> ft_sourceplot(cfg,mri);</font></div></div>
<div><br></div><div>Hope this helps.</div><div>Best,</div><div>Joram</div><br><div><div><div class="h5"><div>On 05 Nov 2013, at 09:43, jan-mathijs schoffelen <<a href="mailto:jan.schoffelen@donders.ru.nl" target="_blank">jan.schoffelen@donders.ru.nl</a>> wrote:</div>
<br></div></div><blockquote type="cite"><div><div class="h5"><div style="word-wrap:break-word">Dear Nicola,<div><br></div><div>I am forwarding your question to the list, "ter lering ende vermaak":<br><div><div><br>
</div><div>Begin forwarded message:</div><br><blockquote type="cite"><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><span style="font-family:Helvetica;font-size:inherit"><b>From: </b></span><span style="font-family:Helvetica;font-size:inherit">Nicola Molinaro <<a href="mailto:nicolaml@gmail.com" target="_blank">nicolaml@gmail.com</a>><br>
</span></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><span style="font-family:Helvetica;font-size:inherit"><b>Date: </b></span><span style="font-family:Helvetica;font-size:inherit">November 4, 2013 2:16:20 PM GMT+01:00<br>
</span></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><span style="font-family:Helvetica;font-size:inherit"><b>To: </b></span><span style="font-family:Helvetica;font-size:inherit">jan-mathijs schoffelen <<a href="mailto:jan.schoffelen@donders.ru.nl" target="_blank">jan.schoffelen@donders.ru.nl</a>><br>
</span></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><span style="font-family:Helvetica;font-size:inherit"><b>Subject: </b></span><span style="font-family:Helvetica;font-size:inherit"><b>mm -> voxels ??</b><br>
</span></div><br><div dir="ltr">Hi Jan,<div>I am trying to align the T1 images with isotrak data using MRIlab and then import the coregistrated image to fieldtrip. Comparing the headshape points with the volume, we can see that Fieldtrip is not taking into account the coregistration. Thus, we are trying to do the corregistration applying the ft_volumerealign function with the method='fiducial' in Fieldtrip. I have the information of the landmarks' position obtained with MRIlab in 'mm' and the function ft_volumerealign need them in voxel index. How can you convert that?</div>
<div>I don´t know if you ever used MRIlab to obtain this information or another software (MNE?).</div></div></blockquote><blockquote type="cite"><div dir="ltr"><div><br></div><div>Thanks</div><div><br></div><div>Nicola</div>
</div>
</blockquote><br></div><div><br></div><div>Indeed I have never used MRIlab for coregistration purposes, so I may not be of much help here. However, I suspect that the coregistration procedure in MRIlab allows you to export your MRI after coregistration, thus creating an file with an anatomical image in register with what you want to achieve. If this is the case, then I don't think that you need FieldTrip to coregister again. I am therefore a bit confused with respect to your remark that 'FieldTrip is not taking into account the coregistration'. If you read in an MRI into FieldTrip, the resulting MRI-structure will contain a transform field, that provides the mapping from voxel space into a more meaningful coordinate system. FieldTrip will not 'guess' the nature of this coordinate system: it just takes the values as they are in the file. Once you have read in your MRI, you can use the ft_sourceplot function for visualization. With cfg.method = 'ortho', the figure will also display the coordinates that you click on (both in voxel indices and in real world coordinates). Now, do you mean by 'FieldTrip does not take into account the coregistration' that these real world coordinates are not as expected?</div>
<div>To answer your question regarding the conversion of landmark positions in 'mm' back into voxel indices: this requires information from the mri.transform matrix, but this implies that the mri is already in register, so there would be no need anymore to call ft_volumerealign.</div>
<div>Either way, you could also do the coregistration entirely in FieldTrip. This requires a two-step approach, calling ft_volumerealign twice (starting from the raw DICOM files, i.e. prior to having used MRIlab). In the first step you will use cfg.interactive = 'yes' and identify the fiducials that define your corodinate system. Assuming that you are working with your MEG data acquired at BCBL, you should also specify cfg.coordsys = 'neuromag'). The output to this funcion call is an MRI structure that is approximately in register with the MEG-device. In the next step you can refine this coregistration by calling ft_volumerealign (with the approximately registered MRI in the input, and) with cfg.method = 'headshape', and cfg.headshape = 'XXX.pos' (the filename of your polhemus file). This should result (providing that the isotrak data can be read ;-) ) in an interactive figure, that allows you to further align the MRI with the polhemus point cloud that describes the headshape. Once you are happy enough, the figure can be closed, and an iterative-closest-point algorithm is applied for further refinement of the coregistration. </div>
<div>I hope this helps, and might inspire you to try out the coregistration in FieldTrip (and give feedback to us about it, in order to make the procedure more robust).</div><div><br></div><div>Best wishes,</div><div><br>
</div><br><div>
<span style="border-collapse:separate;font-family:Helvetica;border-spacing:0px;font-size:inherit"><span style="border-collapse:separate;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;border-spacing:0px;font-size:inherit"><div style="word-wrap:break-word">
<span style="border-collapse:separate;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;border-spacing:0px;font-size:inherit"><div style="word-wrap:break-word">
<span style="border-collapse:separate;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;border-spacing:0px;font-size:inherit"><div style="word-wrap:break-word">
<span style="border-collapse:separate;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;border-spacing:0px;font-size:inherit"><div style="word-wrap:break-word">
<span style="border-collapse:separate;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;border-spacing:0px;font-size:inherit"><div style="word-wrap:break-word">
<span style="border-collapse:separate;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;border-spacing:0px;font-size:inherit"><div style="word-wrap:break-word">
<span style="border-collapse:separate;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;border-spacing:0px;font-size:inherit"><div style="word-wrap:break-word">
<span style="border-collapse:separate;font-family:Helvetica;font-size:inherit;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;border-spacing:0px"><div style="word-wrap:break-word">
<div>Jan-Mathijs Schoffelen, MD PhD </div><div><br></div><div>Donders Institute for Brain, Cognition and Behaviour, <br>Centre for Cognitive Neuroimaging,<br>Radboud University Nijmegen, The Netherlands</div><div><br></div>
<div>Max Planck Institute for Psycholinguistics,</div><div>Nijmegen, The Netherlands</div><div><br></div><div><a href="mailto:J.Schoffelen@donders.ru.nl" target="_blank">J.Schoffelen@donders.ru.nl</a></div><div>Telephone: <a href="tel:%2B31-24-3614793" value="+31243614793" target="_blank">+31-24-3614793</a></div>
<div><br></div><div><a href="http://www.hettaligebrein.nl/" target="_blank">http://www.hettaligebrein.nl</a></div></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></span>
</div>
<br></div></div></div></div>_______________________________________________<br>fieldtrip mailing list<br><a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br><a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></blockquote>
</div><br></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><font color="#888888"><div><div style="color:rgb(34,34,34);font-family:arial;font-size:small"><br>------------------------------</div>
<div style="color:rgb(34,34,34);font-family:arial;font-size:small">Nicola Molinaro, Phd</div><div style="color:rgb(34,34,34);font-family:arial;font-size:small">Staff Scientist</div><div style="color:rgb(34,34,34);font-family:arial;font-size:small">
<a href="http://www.bcbl.eu/" target="_blank">www.bcbl.eu</a></div><div style="color:rgb(34,34,34);font-family:arial;font-size:small"><br></div><div style="color:rgb(34,34,34);font-family:arial;font-size:small"><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">Legal disclaimer/Aviso legal/Lege-oharra: </span><a href="http://www.bcbl.eu/legal-disclaimer" style="color:rgb(17,85,204);font-family:arial,sans-serif;font-size:12.727272033691406px" target="_blank">www.bcbl.eu/legal-disclaimer</a><br style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<br style="font-family:arial,sans-serif;font-size:12.727272033691406px"></div></div></font></div>
</div>
_______________________________________________<br>fieldtrip mailing list<br><a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Jan-Mathijs Schoffelen, MD PhD </div><div><br></div><div>Donders Institute for Brain, Cognition and Behaviour, <br>Centre for Cognitive Neuroimaging,<br>Radboud University Nijmegen, The Netherlands</div><div><br></div><div>Max Planck Institute for Psycholinguistics,</div><div>Nijmegen, The Netherlands</div><div><br></div><div><a href="mailto:J.Schoffelen@donders.ru.nl">J.Schoffelen@donders.ru.nl</a></div><div>Telephone: +31-24-3614793</div><div><br></div><div><a href="http://www.hettaligebrein.nl">http://www.hettaligebrein.nl</a></div></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></span>
</div>
<br></div></body></html>