Advanced Registration¶
These utilities expose lower-level transform estimation and application functions. They are useful for custom registration experiments, but most users should use coregix.align_image_pair() instead.
coregix.preprocess.registration
¶
Image registration utilities.
estimate_elastix_transform(fixed_image_path, moving_image_path, *, parameter_map='rigid', force_linear_resample=False, force_nearest_resample=False, fixed_mask_path=None, moving_mask_path=None, log_to_console=False)
¶
Estimate transform parameters that map a source image to a reference image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fixed_image_path
|
str
|
Path to the reference image. |
required |
moving_image_path
|
str
|
Path to the source image to be aligned. |
required |
parameter_map
|
Union[str, Sequence[str]]
|
Elastix parameter map name(s). Typical values include
|
'rigid'
|
force_linear_resample
|
bool
|
If |
False
|
force_nearest_resample
|
bool
|
If |
False
|
fixed_mask_path
|
Optional[str]
|
Optional reference-image mask path. |
None
|
moving_mask_path
|
Optional[str]
|
Optional source-image mask path. |
None
|
log_to_console
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
Any
|
ITK transform parameter object produced by elastix. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
Source code in coregix/preprocess/registration.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
apply_elastix_transform(moving_image_path, output_image_path, transform_parameter_object, *, reference_image_path=None, log_to_console=False)
¶
Apply a precomputed registration transform to an image and write the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
moving_image_path
|
str
|
Path to the source image to warp. |
required |
output_image_path
|
str
|
Output path for the transformed image. |
required |
transform_parameter_object
|
Any
|
Transform parameter object from
:func: |
required |
reference_image_path
|
Optional[str]
|
Optional raster whose CRS/transform are copied to
|
None
|
log_to_console
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The written |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
Source code in coregix/preprocess/registration.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
apply_elastix_transform_array(moving_image, transform_parameter_object, *, log_to_console=False)
¶
Apply a precomputed registration transform to an in-memory image array.
Source code in coregix/preprocess/registration.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
deformation_field_from_transform(reference_image_path, transform_parameter_object, *, output_directory=None)
¶
Return the transformix deformation field as a NumPy array.
Source code in coregix/preprocess/registration.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
deformation_field_from_transform_region(transform_parameter_object, *, row_off, col_off, height, width, output_directory=None)
¶
Return a deformation field for a fixed-grid subregion.
Source code in coregix/preprocess/registration.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
run_elastix_registration(fixed_image_path, moving_image_path, output_image_path, *, parameter_map='rigid', fixed_mask_path=None, moving_mask_path=None, log_to_console=False)
¶
Register a source image to a reference image using the registration backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fixed_image_path
|
str
|
Path to the reference image. |
required |
moving_image_path
|
str
|
Path to the source image that will be warped. |
required |
output_image_path
|
str
|
Path where the registered image will be written. |
required |
parameter_map
|
Union[str, Sequence[str]]
|
Elastix parameter map name(s). Common values:
|
'rigid'
|
fixed_mask_path
|
Optional[str]
|
Optional reference-image mask path. |
None
|
moving_mask_path
|
Optional[str]
|
Optional source-image mask path. |
None
|
log_to_console
|
bool
|
Whether the registration backend should print logs to stdout. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The written |
Source code in coregix/preprocess/registration.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |