Population_template error on linear transformation

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)
1 Like