transforms — pre-computed ANTs transforms#
Schema: TransformsConfig in src/thesis/core/config/validators.py. Drives ROI/atlas warping in the hcp, atlas_to_patient, and transform workflows.
Top-level fields#
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Optional base directory prepended to every relative path field on this section (and on each |
|
|
|
Full path pattern for the patient→template warp field. Supports |
|
|
|
Full path pattern (or ordered transform chain) for template→patient transforms. Supports |
|
|
|
Patient-space reference image used as the resampling target for template→patient transforms. Supports |
|
|
|
Template-space reference image used as the resampling target for patient→template transforms. |
|
|
|
Named atlas-specific template→patient transform pairs. Reference by name from |
|
|
|
Transform jobs executed by the standalone |
A model_validator walks patient_to_template, template_to_patient, reference_image, template_reference_image, and every atlas_transforms entry and prepends base_dir to relative paths.
atlas_transforms[name] — AtlasTransformConfig#
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Single path or ordered transform chain for this atlas. |
|
|
|
Patient-space reference image for this atlas. |
jobs[] — TransformJobConfig#
Field |
Type |
Default |
Constraints |
Description |
|---|---|---|---|---|
|
|
— |
required |
Unique job name (used in output filenames and Nipype node names). |
|
|
|
— |
Paths to the images to transform. Supports |
|
|
|
one of |
Transform direction. |
|
|
|
ANTs interpolation names |
ANTs interpolation method applied to every input image. Valid: |
|
|
|
— |
Output subdirectory under the patient output directory. |
|
|
|
— |
Per-job reference image override. Useful for resampling a single job onto a different grid (e.g. DWI-space) without affecting other jobs. Supports |
|
|
|
must match a resolved registration-job name |
Drive this job from a registration job produced in the same run, instead of the static |
from_registration — consuming registration output directly#
When a transform job sets from_registration, its transform chain is read
straight from the named registration job’s produced transforms (resolved via
get_registration_job_transform_paths) — no transforms.template_to_patient /
patient_to_template placeholder paths are needed. This is the mechanism
full_pipeline uses to wire the patient→template registration into the
atlas-warping jobs without the old placeholder dance.
A PipelineConfig model-validator checks every from_registration value against
the resolved registration jobs (the implicit patient_to_template is always
valid; an unknown name raises a ValidationError). The direction field then
picks forward vs reverse:
direction: template_to_patient→ registration job’s reverse chain (template → patient), used to warp atlas/template-space images into patient space.direction: patient_to_template→ registration job’s forward chain.
Still set a per-job reference_image (or rely on transforms.reference_image)
to define the output grid — from_registration only supplies the transform
chain, not the resampling target. Inside full_pipeline the meta-workflow may
override reference_image at runtime with the live patient image; jobs that set
their own reference_image (e.g. a DWI-space mask) keep it.
transforms:
jobs:
- name: atlas_main
input_files:
- data/masks/annotation_full.nii.gz
direction: template_to_patient
from_registration: patient_to_template # consume the registration job's reverse chain
interpolation: Linear
output_subdir: atlas_in_patient_space
reference_image: outputs/{patient_id}/registration/{patient_id}_T1_brain.nii.gz
Example#
transforms:
base_dir: data/transforms
patient_to_template: "{patient_id}/patient_to_template_warp.nii.gz"
template_to_patient: "{patient_id}/template_to_patient_warp.nii.gz"
reference_image: data/raw/{patient_id}/T1w/T1w_acpc_dc_restore_1.25.nii.gz
template_reference_image: data/templates/template_T1w.nii.gz
atlas_transforms:
homba:
template_to_patient:
- "{patient_id}/homba_to_patient_warp.nii.gz"
- "{patient_id}/homba_to_patient_affine.mat"
reference_image: "{patient_id}/T1w_in_patient.nii.gz"
jobs:
- name: atlas_mean_to_patient
input_files:
- results/atlas/atlas_mean.nii.gz
direction: template_to_patient
interpolation: Linear
output_subdir: atlas_in_patient_space
- name: cohort_mask_to_dwi_space
input_files:
- results/atlas/cohort_core_mask.nii.gz
direction: template_to_patient
interpolation: NearestNeighbor
output_subdir: atlas_in_patient_space
reference_image: data/processed/{patient_id}/T1w/Diffusion/nodif_brain_mask.nii.gz
Notes#
The
transformworkflow registers under the short nametransform(singular), even though the package directory isworkflows/transforms/.For
atlas_to_patient, the entire job is driven bytransforms.jobs; the workflow factory iterates over the list and creates one Nipype subgraph per job.{patient_id}is the only substitution token supported in path patterns.