Registration¶
Image registration via ANTs (rigid and deformable) and DeepALI (deep learning–based).
Point-Based Rigid Registration¶
TPTBox.registration.Point_Registration
¶
Source code in TPTBox/registration/_ridged_points/point_registration.py
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 84 85 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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 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 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
__init__
¶
__init__(poi_fixed: POI, poi_moving: POI, exclusion=None, log: Logger_Interface = No_Logger(), verbose=True, ax_code=None, zooms=None, leave_worst_percent_out=0.0)
Use two Centroids object to compute a ridged_points registration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctd_fixed
|
Centroids
|
description |
required |
ctd_movig
|
Centroids
|
description |
required |
representative_fixed
|
Image_Reference
|
description. Defaults to None. |
required |
representative_movig
|
Image_Reference
|
description. Defaults to None. |
required |
exclusion
|
list
|
description. Defaults to []. |
None
|
log
|
_type_
|
description. Defaults to No_Logger(). |
No_Logger()
|
verbose
|
bool
|
description. Defaults to True. |
True
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Require at least two points |
Returns:
| Type | Description |
|---|---|
|
Resample_Filter |
Source code in TPTBox/registration/_ridged_points/point_registration.py
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 84 85 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 128 129 | |
get_resampler
¶
Build a configured SimpleITK resampler for this registration transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seg
|
bool
|
If True, use nearest-neighbour interpolation (segmentation mode). |
required |
c_val
|
float
|
Default fill value for background voxels (ignored when seg=True). |
required |
output_space
|
NII | None
|
Optional target image space. Defaults to the fixed image space. |
None
|
Returns:
| Type | Description |
|---|---|
ResampleImageFilter
|
A configured |
Source code in TPTBox/registration/_ridged_points/point_registration.py
transform
¶
Apply the registration transform to a NII image or a POI landmark set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
NII_or_POI
|
A |
required |
Returns:
| Type | Description |
|---|---|
NII_or_POI
|
Transformed object of the same type as the input. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If x is neither a |
Source code in TPTBox/registration/_ridged_points/point_registration.py
transform_poi
¶
transform_poi(poi_moving: POI, allow_only_same_grid_as_moving: bool = True, output_space: NII | POI | None = None) -> POI
Transform a set of landmarks (POI) from the moving to the fixed image space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poi_moving
|
POI
|
Landmark set defined in the moving image space. |
required |
allow_only_same_grid_as_moving
|
bool
|
If True, assert that poi_moving shares the grid of the moving image used during registration. |
True
|
output_space
|
NII | POI | None
|
Optional target space to resample the result into. |
None
|
Returns:
| Type | Description |
|---|---|
POI
|
Transformed |
Source code in TPTBox/registration/_ridged_points/point_registration.py
transform_cord
¶
Transform a single voxel coordinate from moving to fixed image space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cord
|
tuple[float, ...]
|
Voxel coordinate (x, y, z) in the moving image. |
required |
out
|
Image | None
|
Reference SimpleITK image defining the output space. Defaults to the fixed image used during registration. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Transformed coordinate as a NumPy array of shape (3,). |
Source code in TPTBox/registration/_ridged_points/point_registration.py
transform_cord_inverse
¶
Transform a single voxel coordinate from fixed to moving image space (inverse direction).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cord
|
tuple[float, ...]
|
Voxel coordinate (x, y, z) in the fixed image. |
required |
out
|
Image | None
|
Reference SimpleITK image defining the output space. Defaults to the fixed image used during registration. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Transformed coordinate as a NumPy array of shape (3,). |
Source code in TPTBox/registration/_ridged_points/point_registration.py
transform_nii
¶
transform_nii(moving_img_nii: NII, allow_only_same_grid_as_moving: bool = True, output_space: NII | None = None, c_val: float | None = None) -> NII
Resample a NII image from the moving into the fixed image space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
moving_img_nii
|
NII
|
Image defined in the moving image space. |
required |
allow_only_same_grid_as_moving
|
bool
|
If True, assert that moving_img_nii shares the grid of the moving image used during registration. |
True
|
output_space
|
NII | None
|
Optional target space for the resampled output. Defaults to the fixed image space. |
None
|
c_val
|
float | None
|
Background fill value. Derived from the image automatically when not provided. |
None
|
Returns:
| Type | Description |
|---|---|
NII
|
Resampled |
Source code in TPTBox/registration/_ridged_points/point_registration.py
get_affine
¶
Return the 4x4 affine matrix corresponding to the rigid registration transform.
The matrix follows the convention
T(x) = A(x - c) + (t + c)
Returns:
| Type | Description |
|---|---|
ndarray
|
A (4, 4) NumPy array representing the homogeneous affine transform. |
Source code in TPTBox/registration/_ridged_points/point_registration.py
get_dump
¶
Collect the serialisable state of this registration object.
Returns:
| Type | Description |
|---|---|
tuple
|
A tuple containing the version tag followed by all state components |
tuple
|
needed to reconstruct the object via :meth: |
Source code in TPTBox/registration/_ridged_points/point_registration.py
save
¶
Serialise the registration state to a pickle file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Destination file path. |
required |
load
classmethod
¶
Load a Point_Registration from a previously saved pickle file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the pickle file created by :meth: |
required |
Returns:
| Type | Description |
|---|---|
Point_Registration
|
Reconstructed |
Source code in TPTBox/registration/_ridged_points/point_registration.py
load_
classmethod
¶
Reconstruct a Point_Registration from a raw state tuple (as returned by :meth:get_dump).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
w
|
tuple
|
Serialised state tuple. |
required |
Returns:
| Type | Description |
|---|---|
Point_Registration
|
Reconstructed |
Source code in TPTBox/registration/_ridged_points/point_registration.py
TPTBox.registration.ridged_points_from_poi
¶
ridged_points_from_poi(poi_fixed: POI, poi_moving: POI, exclusion: list | None = None, log: Logger_Interface = No_Logger(), verbose: bool = True, ax_code=None, zooms=None, c_val: float | None = None, leave_worst_percent_out: float = 0.0) -> Point_Registration
Compute a rigid point-based registration from two POI landmark sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poi_fixed
|
POI
|
Landmark set in the fixed (target) image space. |
required |
poi_moving
|
POI
|
Landmark set in the moving (source) image space. |
required |
exclusion
|
list | None
|
List of landmark keys to exclude from the alignment. |
None
|
log
|
Logger_Interface
|
Logger used for progress and diagnostic output. |
No_Logger()
|
verbose
|
bool
|
If True, print detailed per-landmark information. |
True
|
ax_code
|
Optional orientation code to reorient poi_fixed before registration. |
None
|
|
zooms
|
Optional target voxel spacing to rescale poi_fixed before registration. |
None
|
|
c_val
|
float | None
|
Deprecated. Background fill value — has no effect and will trigger a
|
None
|
leave_worst_percent_out
|
float
|
Fraction (0–1) of worst-fitting landmarks to discard before computing the final transform. |
0.0
|
Returns:
| Type | Description |
|---|---|
Point_Registration
|
Fitted |
Source code in TPTBox/registration/_ridged_points/point_registration.py
TPTBox.registration.ridged_points_from_subreg_vert
¶
ridged_points_from_subreg_vert(poi_moving: POI_Reference, vert: Image_Reference, subreg: POI_Reference, poi_target_buffer: Path | str | None = None, orientation=None, zoom: tuple[float, float, float] = (-1, -1, -1), subreg_id: int | Location | list[int | Location] | list[Location] | list[int] = 50, c_val: float = -1050, verbose: bool = True, save_buffer_file: bool = True) -> Point_Registration
Compute a rigid point-based registration using vertebra sub-region centroids.
Derives a fixed-space POI from instance and semantic segmentation masks, then aligns it to a pre-computed moving-space POI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poi_moving
|
POI_Reference
|
POI landmark set (or loadable reference) for the moving image. |
required |
vert
|
Image_Reference
|
Instance (vertebra label) segmentation in the fixed image space. |
required |
subreg
|
POI_Reference
|
Semantic sub-region segmentation in the fixed image space. |
required |
poi_target_buffer
|
Path | str | None
|
Optional path to cache / load the computed fixed POI. |
None
|
orientation
|
Optional orientation code to reorient the fixed POI. |
None
|
|
zoom
|
tuple[float, float, float]
|
Target voxel spacing for rescaling the fixed POI.
Pass |
(-1, -1, -1)
|
subreg_id
|
int | Location | list[int | Location] | list[Location] | list[int]
|
Sub-region label(s) used to extract centroid landmarks. |
50
|
c_val
|
float
|
Background fill value forwarded to the registration (currently unused internally; kept for API compatibility). |
-1050
|
verbose
|
bool
|
If True, print progress information. |
True
|
save_buffer_file
|
bool
|
If True, save the computed fixed POI to poi_target_buffer. |
True
|
Returns:
| Type | Description |
|---|---|
Point_Registration
|
Fitted |
Source code in TPTBox/registration/_ridged_points/point_registration.py
Deformable Registration¶
TPTBox.registration.Deformable_Registration
¶
Bases: General_Registration
Deformable registration between a fixed and moving image using deepali.
Wraps General_Registration with default loss terms (LNCC + BSpline bending
energy) and a Stationary Velocity Field Free-Form Deformation (SVFFD) transform.
Attributes:
| Name | Type | Description |
|---|---|---|
transform |
The learned deformation field resulting from the registration. |
|
ref_nii |
Reference NII object used for registration. |
|
grid |
Target grid for image warping. |
|
mov |
Processed version of the moving image. |
Source code in TPTBox/registration/_deformable/deformable_reg.py
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 84 85 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 128 129 130 131 132 133 134 135 136 137 138 | |
TPTBox.registration.Template_Registration
¶
Multi-stage registration between two multi-label segmentations.
Supports optional POI landmark alignment and deformable registration; landmarks are computed on the fly if not provided. Particularly useful for MRI/CT atlas alignment with optional body-side flip handling.
Attributes:
| Name | Type | Description |
|---|---|---|
same_side |
bool
|
Whether the target and atlas represent the same anatomical side (e.g., both right sides). |
reg_point |
Point_Registration
|
The rigid point-based registration component. |
reg_deform |
Deformable_Registration
|
The deformable registration component. |
crop |
tuple
|
The crop applied to both target and atlas after registration. |
target_grid_org |
NII
|
Original spatial grid of the target. |
atlas_org |
NII
|
Original spatial grid of the atlas. |
target_grid |
NII
|
Cropped spatial grid used for deformable registration. |
Source code in TPTBox/registration/_deformable/multilabel_segmentation.py
15 16 17 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 84 85 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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 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 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | |
__init__
¶
__init__(target_seg: NII, atlas_seg: NII, target_img: NII | None = None, atlas_img: NII | None = None, poi_cms: POI | None = None, same_side: bool = True, verbose=99, gpu=0, ddevice: DEVICES = 'cuda', loss_terms=None, weights=None, lr=0.01, lr_end_factor=None, max_steps=1500, min_delta: float | list[float] = 1e-06, pyramid_levels=4, coarsest_level=3, finest_level=0, crop: bool = True, cms_ids: list | None = None, poi_target_cms: POI | None = None, max_history=100, change_after_point_reg=lambda x, y, z, w: (x, y, z, w), **args)
Initialize a multi-stage registration pipeline from an atlas to a target image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
NII
|
Target image segmentation (e.g., from a subject). |
required |
atlas
|
NII
|
Atlas image segmentation (e.g., a reference or template). |
required |
target_img
|
NII
|
Target image if None the segmentation is used as an image. |
None
|
atlas_img
|
NII
|
Atlas image if None the segmentation is used as an image. |
None
|
poi_cms
|
POI | None
|
POI centroids of the atlas, used for initial point registration. |
None
|
same_side
|
bool
|
Whether atlas and target represent the same body side. |
True
|
verbose
|
int
|
Verbosity level for logging. |
99
|
gpu
|
int
|
GPU device ID (only relevant if using GPU). |
0
|
ddevice
|
DEVICES
|
Device type ('cuda' or 'cpu'). |
'cuda'
|
loss_terms
|
dict
|
Dictionary of loss terms for deformable registration. |
None
|
weights
|
dict
|
Weights for the loss terms. |
None
|
lr
|
float
|
Learning rate for deformable registration optimizer. |
0.01
|
max_steps
|
int
|
Maximum optimization steps. |
1500
|
min_delta
|
float
|
Minimum delta for convergence. |
1e-06
|
pyramid_levels
|
int
|
Number of resolution levels in multi-scale deformable registration. |
4
|
coarsest_level
|
int
|
Coarsest level index. |
3
|
finest_level
|
int
|
Finest level index. |
0
|
cms_ids
|
list | None
|
List of segmentation labels used to extract POI centroids. |
None
|
poi_target_cms
|
POI | None
|
Optional precomputed centroids for the target image. |
None
|
**args
|
Additional keyword arguments passed to Deformable_Registration. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If an invalid axis is detected during flipping. |
Source code in TPTBox/registration/_deformable/multilabel_segmentation.py
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 84 85 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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 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 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
get_dump
¶
Collect the serialisable state of this registration object.
Returns:
| Type | Description |
|---|---|
tuple
|
A tuple containing the version tag followed by all state components |
tuple
|
needed to reconstruct the object via :meth: |
Source code in TPTBox/registration/_deformable/multilabel_segmentation.py
save
¶
Serialise the registration state to a pickle file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Destination file path. |
required |
load
classmethod
¶
Load a previously saved registration state from a pickle file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the pickle file created by :meth: |
required |
Returns:
| Type | Description |
|---|---|
Template_Registration
|
Reconstructed |
Source code in TPTBox/registration/_deformable/multilabel_segmentation.py
load_
classmethod
¶
Reconstruct a Template_Registration from a raw state tuple (as returned by :meth:get_dump).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
w
|
tuple
|
Serialised state tuple. |
required |
Returns:
| Type | Description |
|---|---|
Template_Registration
|
Reconstructed |
Source code in TPTBox/registration/_deformable/multilabel_segmentation.py
transform_nii
¶
Apply both rigid and deformable registration to a NII image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nii_atlas
|
NII
|
Atlas image to be transformed (must share the atlas grid). |
required |
allow_only_same_grid_as_moving
|
bool
|
If True, assert that nii_atlas matches the grid of the moving image used during point registration. |
True
|
Returns:
| Type | Description |
|---|---|
NII
|
Transformed |
Source code in TPTBox/registration/_deformable/multilabel_segmentation.py
transform_poi
¶
Apply both rigid and deformable registration to a POI landmark set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poi_atlas
|
POI_Global | POI
|
Atlas landmarks to be transformed (defined in the atlas space). |
required |
Returns:
| Type | Description |
|---|---|
POI
|
Transformed |
Source code in TPTBox/registration/_deformable/multilabel_segmentation.py
transform_poi_inverse
¶
Transform POIs from target space back into atlas space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poi_target
|
POI_Global | POI
|
POIs defined in target space. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
POI |
POIs mapped back into atlas space. |
Source code in TPTBox/registration/_deformable/multilabel_segmentation.py
Deep Learning Registration (DeepALI)¶
TPTBox.registration.General_Registration
¶
Bases: DeepaliPairwiseImageTrainer
A class for performing deformable registration between a fixed and moving image.
Attributes:
| Name | Type | Description |
|---|---|---|
transform |
Tensor
|
The transformation matrix resulting from the registration. |
ref_nii |
NII
|
Reference NII object used for registration. |
grid |
Tensor
|
Target grid for image warping. |
mov |
NII
|
Processed version of the moving image. |
Source code in TPTBox/registration/_deepali/deepali_model.py
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 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | |
inverse
¶
Invert the registration transformation.
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The instance with the inverted transformation. |
Source code in TPTBox/registration/_deepali/deepali_model.py
transform_nii
¶
transform_nii(img: NII, gpu: int | None = None, ddevice: DEVICES | None = None, target: Has_Grid | None = None, align_corners=True, inverse=False) -> NII
Apply the computed transformation to a given NII image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
NII
|
The NII image to be transformed. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NII |
NII
|
The transformed image as an NII object. |
Source code in TPTBox/registration/_deepali/deepali_model.py
transform_poi
¶
transform_poi(poi: POI, gpu: int | None = None, ddevice: DEVICES | None = None, align_corners: bool = True, inverse: bool = True) -> POI
Apply the computed registration to a POI object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poi
|
POI
|
Source |
required |
gpu
|
int | None
|
GPU index override. Defaults to the device used during registration. |
None
|
ddevice
|
DEVICES | None
|
Device type override (e.g. |
None
|
align_corners
|
bool
|
Whether corners or centres are aligned during warping. |
True
|
inverse
|
bool
|
Apply the inverse transform when |
True
|
Returns:
| Type | Description |
|---|---|
POI
|
A new |
Source code in TPTBox/registration/_deepali/deepali_model.py
transform_points
¶
transform_points(points, axes: Axes, to_axes: Axes, grid: Grid | Has_Grid, to_grid: Grid | Has_Grid, gpu: int | None = None, ddevice: DEVICES | None = None, inverse=True)
Transform a set of points using the registered transformation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
list
|
List of points to warp: (b,n) b points with n coordinates. |
required |
axes
|
Axes
|
Axes of the input points. |
required |
to_axes
|
Axes
|
Axes of the output points. |
required |
grid
|
Grid | Has_Grid
|
The grid to which the points belong. |
required |
to_grid
|
Grid | Has_Grid
|
The target grid for the transformed points. |
required |
gpu
|
int
|
GPU index to use. Defaults to None. |
None
|
ddevice
|
DEVICES
|
Device type. Defaults to "cuda". |
None
|
inverse
|
bool
|
Whether to apply the inverse transformation. Defaults to True. |
True
|
Source code in TPTBox/registration/_deepali/deepali_model.py
__call__
¶
Call method to apply the transformation using the transform_nii method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Positional arguments for the transform_nii method. |
()
|
|
**kwds
|
Keyword arguments for the transform_nii method. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
NII |
NII
|
The transformed image. |
Source code in TPTBox/registration/_deepali/deepali_model.py
get_dump
¶
Return a serialisable tuple of the registration state for pickling.
Returns:
| Type | Description |
|---|---|
tuple
|
Tuple of |
Source code in TPTBox/registration/_deepali/deepali_model.py
save
¶
Serialise the registration result to a pickle file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Destination file path. |
required |
load
classmethod
¶
Load a previously saved General_Registration from a pickle file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the pickle file written by :meth: |
required |
gpu
|
int
|
GPU index to map the transform to. |
0
|
ddevice
|
DEVICES
|
Device type (e.g. |
'cuda'
|
Returns:
| Type | Description |
|---|---|
Self
|
Reconstructed |
Source code in TPTBox/registration/_deepali/deepali_model.py
load_
classmethod
¶
Reconstruct a General_Registration from a raw dump tuple.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
w
|
tuple
|
Tuple as returned by :meth: |
required |
gpu
|
int
|
GPU index for device placement. |
0
|
ddevice
|
DEVICES
|
Device type string. |
'cuda'
|
Returns:
| Type | Description |
|---|---|
Self
|
Reconstructed |