Skip to content

Commit

Permalink
use mri_realigned from the mat file
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoostenveld committed Mar 6, 2024
1 parent 3c9bef1 commit 3f6b75a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions tutorial/coregistration_opm.md
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,8 @@ After reading in the MRI, you can check the coordinate system with `ft_determine

% read in the anatomical MRI
mri = ft_read_mri('example3_anatomical.nii');

% check the coordinate system
ft_determine_coordsys(mri, 'interactive', 'no');

{% include image src="/assets/img/tutorial/coregistration_opm/mri_notaligned.png" width="400" %}
Expand All @@ -556,22 +558,30 @@ As the above figure shows, the axes are labeled as 'unknown', but it seems that
We will explicitly align the MRI to an anatomical landmark-based coordinate system next, which requires interactive identification of the relevant landmarks (Nasion, Left, and Right pre-auricular points).

% define a head coordinate system linked to the anatomical landmarks
cfg = [];
cfg.coordsys = 'neuromag';
mri = ft_volumerealign(cfg, mri);
ft_determine_coordsys(mri, 'interactive', 'no');
cfg = [];
cfg.coordsys = 'neuromag';
mri_realigned = ft_volumerealign(cfg, mri);

% check the coordinate system after realignment
ft_determine_coordsys(mri_realigned, 'interactive', 'no');

{% include image src="/assets/img/tutorial/coregistration_opm/mri_aligned.png" width="400" %}
_Figure: anatomical MRI image with a 'neuromag' head coordinate system._

{% include markup/info %}
During MRI coregistration you have to click on the nasion, left and right ear. The landmark points at the ears are [ambiguous](/faq/how_are_the_lpa_and_rpa_points_defined) and if you click on different points, your alignment could be off by a centimeter or so. In the subsequent code we will use some rotation and translation parameters. To make sure that your subsequent results match what is presented here, you should download [example3_face_mri_realigned.mat](https://download.fieldtriptoolbox.org/tutorial/coregistration_opm/example3_mri_realigned.mat) and load it in MATLAB.

load example3_mri_realigned.mat % this contains the realigned mri
{% include markup/end %}

### Alignment of the 3D scan face with the MRI

We can extract the scalp surface from the anatomical MRI and interactively align this with the face from the 3D scan. In theory, an automatic algorithm, such as the iterative closest point (ICP) algorithm could be used, but the results of that highly depends on the number of points, and the quality of the initial alignment. Hence, in this example we stick to a manual alignment.

% segment the scalp
cfg = [];
cfg.output = 'scalp';
seg = ft_volumesegment(cfg, mri);
seg = ft_volumesegment(cfg, mri_realigned);

% create a mesh for the scalp
cfg = [];
Expand Down

0 comments on commit 3f6b75a

Please sign in to comment.