registration — image registration#
Schema: RegistrationConfig in src/thesis/core/config/validators.py. Drives the standalone registration workflow and the patient → template registration stage inside full_pipeline.
Two distinct “registrations” — don’t confuse them.
This
registration:block configures the patient → template registration (e.g. ANTs/FireANTs SyN to a study template). Itsfixed_imageis the template.The intra-subject DWI → T1 coregistration (plus T2 → T1 and MNI-label warps) inside the
preprocessworkflow is a separate step, toggled bypreprocess.run_coregistration(bool, defaultTrue; not by this block). That toggle is defined authoritatively in the preprocessing guide.full_pipelineconsumes its DWI→T1 transform to place atlas ROIs on the DWI grid; it is optional — when off, ROIs are regridded instead, which is only valid when T1 and DWI already share a world. (preprocess.run_coregistrationwas previously namedrun_registration.)
Top-level fields#
Field |
Type |
Default |
Constraints |
Description |
|---|---|---|---|---|
|
|
|
— |
Whether the registration workflow is enabled. |
|
|
|
one of |
Registration backend. |
|
|
|
one of |
Modality selector. Falls back to |
|
|
|
— |
Optional explicit moving-image path. When set, overrides the |
|
|
|
— |
Path to the template-space fixed image. Required when the workflow runs. |
|
|
|
ANTs interpolation names |
Interpolation method applied during resampling. |
|
|
|
— |
Similarity metric (MI, CC, MeanSquares, etc. as supported by ANTs). |
|
|
|
one of |
Transform family. |
|
|
|
— |
Use float precision in ANTs. |
|
|
|
— |
Pass |
|
|
|
— |
Pass |
|
|
|
— |
Patient output subdirectory for registration artefacts. |
|
|
(see below) |
— |
FireANTs backend settings. Used only when |
|
|
(see below) |
— |
Post-registration QC viewer settings. |
|
|
|
job names must be unique |
Named registration jobs. When empty, the top-level fields above are treated as a single implicit job named |
registration.fireants — FireantsRegistrationConfig#
Field |
Type |
Default |
Constraints |
Description |
|---|---|---|---|---|
|
|
|
— |
Torch device string (e.g. |
|
|
|
— |
Multi-resolution pyramid scales. |
|
|
|
same length as |
Affine iterations per scale. |
|
|
|
same length as |
Deformable iterations per scale. |
|
|
|
one of |
FireANTs optimizer. |
|
|
|
|
Affine learning rate. |
|
|
|
|
Deformable learning rate. |
|
|
|
|
Cross-correlation kernel size. |
|
|
|
one of |
Similarity metric for the rigid/affine/deformable stages. |
|
|
|
— |
Min-max normalise fixed and moving intensities to |
|
|
|
one of |
FireANTs deformation model. |
|
|
|
one of |
Torch dtype. |
|
|
|
|
Cap on the deformable-step image spacing. When the template has finer voxels, both images are resampled to this cap before FireANTs runs. |
|
|
|
— |
Run the |
|
|
|
— |
Run the |
|
|
|
|
Downsampling scale used for the moments init stage. FireANTs recommends 4 (the moments init is robust at low resolution). |
|
|
|
|
Number of moments used in the moments init. FireANTs recommends 1 (centre-of-mass + first order); 2 adds a second-order principal-axis term prone to 180° flips on near-symmetric brains. |
|
|
|
same length as |
Rigid-stage iterations per pyramid scale. |
|
|
|
|
Rigid-stage learning rate. |
|
|
|
one of |
Deformable engine for |
|
|
|
one of |
How the reverse (template→patient) warp is produced for SyN-family transforms. |
|
|
|
|
Maximum fixed-point iterations for the SimpleITK displacement-field inversion ( |
|
|
|
|
Mean-error tolerance (mm) for the SimpleITK displacement-field inversion. Lower = tighter inverse, more iterations. |
|
|
|
one of |
How the staged FireANTs flow is executed. |
affine_backendremoved. Earlier versions exposed anaffine_backend: ants \| fireantsknob that shelled out toantsRegistrationSyNQuick.shfor the affine step. The FireANTs backend now runs a native staged flow (MomentsRegistration → RigidRegistration → AffineRegistration → GreedyRegistration); the moments stage provides the robust orientation init the ANTs hack was substituting for.affine_backendis no longer a field — configs that still set it fail validation (extra="forbid"). Remove it.
A model_validator enforces that affine_iterations, deformable_iterations, and rigid_iterations all have the same length as scales. The moments stage is always run in float32 (it rejects fp16/bf16); when dtype is float16/bfloat16 a separate float32 image pair is loaded just for moments while the rigid/affine/deformable stages use the configured dtype.
registration.viewer — RegistrationViewerConfig#
Field |
Type |
Default |
Constraints |
Description |
|---|---|---|---|---|
|
|
|
— |
Whether viewer support is enabled. |
|
|
|
one of |
Viewer backend. Only |
|
|
|
— |
Launch the viewer automatically after registration completes. |
|
|
|
|
Opacity of the warped patient image overlay. |
Example#
registration:
enabled: true
method: fireants
moving_modality: t1
fixed_image: data/templates/template_T1w.nii.gz
transform_type: SyN
interpolation: Linear
metric: MI
output_subdir: registration
fireants:
device: cuda
scales: [4, 2, 1]
affine_iterations: [200, 100, 50]
deformable_iterations: [200, 100, 25]
optimizer: Adam
affine_lr: 0.003
deformable_lr: 0.5
cc_kernel_size: 5
loss_type: cc # cc | mi | mse | fusedcc | fusedmi
normalize: true # min-max to [0,1] before registration
deformation_type: compositive
dtype: float32
deformable_max_spacing_mm: 1.0 # cap resolution to keep GPU happy
# ---- native staged affine-init knobs (replaces the old affine_backend hack) ----
do_moments: true
do_rigid: true
moments_scale: 4
moments_moments: 1
rigid_iterations: [200, 100, 25] # must match len(scales)
rigid_lr: 0.03
deform_algo: greedy # greedy | syn (syn disables analytic inverse)
inverse_method: simpleitk # simpleitk | fireants
driver: inprocess # inprocess | cli
viewer:
enabled: true
backend: fsleyes
auto_open: false
overlay_opacity: 0.5
registration.jobs — named multi-job registration#
By default the block above describes a single registration synthesised into one
implicit job named patient_to_template (legacy-flat on-disk layout under
registration/transforms/). No jobs: entry is required for the common case.
To run several registrations in one pass, list them under registration.jobs.
Each entry is a RegistrationJobConfig: a required name plus optional per-job
overrides for any of method, moving_modality, moving_image, fixed_image,
interpolation, metric, transform_type, use_float, and a sparse fireants
dict (merged onto and re-validated against the shared registration.fireants).
Unset fields inherit the shared top-level values. Job names must be unique.
Explicit (non-default) jobs write to a nested layout
(registration/<job>/transforms/<pid>_<job>_*); the implicit default job keeps
the legacy-flat paths so existing on-disk caches stay valid. Downstream transform
jobs reference a registration job by name via
transforms.jobs[*].from_registration (see the transforms guide).
registration:
method: fireants
fixed_image: data/templates/template_T1w.nii.gz
transform_type: SyN
# ... shared fields inherited by every job below ...
jobs:
- name: patient_to_template # legacy-flat layout; inherits all shared fields
transform_type: SyN
- name: t2_affine # nested layout: registration/t2_affine/transforms/
moving_modality: t2
transform_type: Affine
fireants: # sparse override, re-validated on merge
deform_algo: greedy
Notes#
FireANTs deformable runs export affine + composed warp as ANTs-compatible 5-D NIfTI (intent_code=1007). The transform list contains only the warp file; no separate affine is emitted.
Install FireANTs separately when using that backend:
pip install fireants.The CLI does not expose registration-specific flags; configure via YAML.