If you used default parameters, linear_transforms_6
should be the first affine registration, before that only rigid registrations were used. The previous registrations might have been poor as well but were not detected as the detection mechanism uses non-rigid properties (shear, scaling). While you could ignore this warning via the option -linear_no_pause
, given the scaling and shear, the registration went completely wrong and would unlikely recover in subsequent steps.
For below, I am assuming you used intensity normalised Orientation Distribution Function (ODF) images as input and corresponding masks and the latest version of MRtrix3
.
To debug population_template
problems, it is best to go to the scratch directory of population_template
(printed at the beginning of the output of the script) and have a look at its content. The file log.txt
contains the commands that were run. Close to the end you should see mrregister
and subsequent mrtransform
calls that should guide you on what data to inspect. The folder content should look something like this:
βββ average_header.mif
βββ average_header_c0.mif
βββ command.txt
βββ cwd.txt
βββ initial_template_c0.mif
βββ input_transformed_c0
β βββ 0.mif
β βββ 1.mif
β βββ 2.mif
βββ isfinite_c0
β βββ 0.mif
β βββ 1.mif
β βββ 2.mif
βββ isfinite_c0.mif
βββ linear_template00_c0.mif
βββ linear_template01_c0.mif
βββ linear_template02_c0.mif
βββ linear_template03_c0.mif
βββ linear_template04_c0.mif
βββ linear_template05_c0.mif
βββ linear_transform_average.txt
βββ linear_transform_average_inv.txt
βββ linear_transforms
βββ linear_transforms_00
β βββ 0.txt
β βββ 1.txt
β βββ 2.txt
βββ linear_transforms_01
β βββ 0.txt
β βββ 1.txt
β βββ 2.txt
βββ linear_transforms_02
β βββ 0.txt
β βββ 1.txt
β βββ 2.txt
βββ linear_transforms_03
β βββ 0.txt
β βββ 1.txt
β βββ 2.txt
βββ linear_transforms_04
β βββ 0.txt
β βββ 1.txt
β βββ 2.txt
βββ linear_transforms_05
β βββ 0.txt
β βββ 1.txt
β βββ 2.txt
βββ linear_transforms_06
β βββ 0.txt
β βββ 1.txt
β βββ 2.txt
βββ linear_transforms_07
βββ linear_transforms_08
βββ linear_transforms_09
βββ linear_transforms_10
βββ linear_transforms_11
βββ linear_transforms_initial
β βββ 0.txt
β βββ 1.txt
β βββ 2.txt
βββ log.txt
βββ mask_transformed
β βββ 0.mif
β βββ 1.mif
β βββ 2.mif
βββ warps_00
βββ warps_01
βββ warps_02
βββ warps_03
βββ warps_04
βββ warps_05
βββ warps_06
βββ warps_07
βββ warps_08
βββ warps_09
βββ warps_10
βββ warps_11
βββ warps_12
βββ warps_13
βββ warps_14
βββ warps_15
You probably best start comparing the current template and previous registration result, which is used for initialisation to the registration that went wrong.
mrcat linear_template05_c0.mif $(mrgrid input_transformed_c0/01170.mif regrid -template linear_template05_c0.mif -) -axis 4 - | mrview - -roi.load mask_transformed/01170.mif -roi.opacity 0.3
shift + right,left
in mrview
allows you to switch between template (volume group 0) and transformed subject image (1). Look for gross misalignment and global and local large intensity differences between the images as well as poor mask coverage. Affine registration going wrong can usually be traced back to one of these reasons. If your input is not scalar (ODFs), check also a few volumes (right,left
in mrview
).
If the subject data is grossly misaligned (large rotation or translation) with the template, have a look at the data from previous registration stages:
mrcat linear_template05_c0.mif $(mrtransform -reorient_fod <yes,no> <INPUT DATA/>01170.mif -template linear_template05_c0.mif -linear linear_transforms_<previous stage number>/01170.txt -) -axis 4 - | mrview -
If your data and mask are OK, you have a few options:
- donβt include that subject in the template, once the template is done you can register each subject of interest to the template
- if you have abnormal data (lesions, tumour, artefacts) masked out, use
-nanmask
to exlude these areas from appearing in the template
- dilate or erode that subjectβs mask to nudge registration in a hopefully better direction
- experiment with parameters to
population_template
. For instance, increase the initial scale and number of steps in -affine_scale
, set -affine_lmax
to zero, or force nonlinear registration to take over the affine part -type rigid_nonlinear
(might yield suboptimal results)
- intervene manually in the registration for that subject using the pause functionality (requires you to experiment with
mrregister
parameters to overwrite the transformation that went wrong and then press enter once you found settings that worked to continue population_template
)