Dictionary-based wrapper of :py:class:`monai.transforms.Spacing`. This transform assumes the ``data`` dictionary has a key for the input data's metadata and contains `affine` field. The key is formed by ``key_{meta_key_postfix}``. After resampling the input array, this transform
| 365 | |
| 366 | |
| 367 | class Spacingd(MapTransform, InvertibleTransform, LazyTransform): |
| 368 | """ |
| 369 | Dictionary-based wrapper of :py:class:`monai.transforms.Spacing`. |
| 370 | |
| 371 | This transform assumes the ``data`` dictionary has a key for the input |
| 372 | data's metadata and contains `affine` field. The key is formed by ``key_{meta_key_postfix}``. |
| 373 | |
| 374 | After resampling the input array, this transform will write the new affine |
| 375 | to the `affine` field of metadata which is formed by ``key_{meta_key_postfix}``. |
| 376 | |
| 377 | This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic<lazy_resampling>` |
| 378 | for more information. |
| 379 | |
| 380 | see also: |
| 381 | :py:class:`monai.transforms.Spacing` |
| 382 | """ |
| 383 | |
| 384 | backend = Spacing.backend |
| 385 | |
| 386 | def __init__( |
| 387 | self, |
| 388 | keys: KeysCollection, |
| 389 | pixdim: Sequence[float] | float, |
| 390 | diagonal: bool = False, |
| 391 | mode: SequenceStr = GridSampleMode.BILINEAR, |
| 392 | padding_mode: SequenceStr = GridSamplePadMode.BORDER, |
| 393 | align_corners: Sequence[bool] | bool = False, |
| 394 | dtype: Sequence[DtypeLike] | DtypeLike = np.float64, |
| 395 | scale_extent: bool = False, |
| 396 | recompute_affine: bool = False, |
| 397 | min_pixdim: Sequence[float] | float | None = None, |
| 398 | max_pixdim: Sequence[float] | float | None = None, |
| 399 | ensure_same_shape: bool = True, |
| 400 | allow_missing_keys: bool = False, |
| 401 | lazy: bool = False, |
| 402 | ) -> None: |
| 403 | """ |
| 404 | Args: |
| 405 | pixdim: output voxel spacing. if providing a single number, will use it for the first dimension. |
| 406 | items of the pixdim sequence map to the spatial dimensions of input image, if length |
| 407 | of pixdim sequence is longer than image spatial dimensions, will ignore the longer part, |
| 408 | if shorter, will pad with `1.0`. |
| 409 | if the components of the `pixdim` are non-positive values, the transform will use the |
| 410 | corresponding components of the original pixdim, which is computed from the `affine` |
| 411 | matrix of input image. |
| 412 | diagonal: whether to resample the input to have a diagonal affine matrix. |
| 413 | If True, the input data is resampled to the following affine:: |
| 414 | |
| 415 | np.diag((pixdim_0, pixdim_1, pixdim_2, 1)) |
| 416 | |
| 417 | This effectively resets the volume to the world coordinate system (RAS+ in nibabel). |
| 418 | The original orientation, rotation, shearing are not preserved. |
| 419 | |
| 420 | If False, the axes orientation, orthogonal rotation and |
| 421 | translations components from the original affine will be |
| 422 | preserved in the target affine. This option will not flip/swap |
| 423 | axes against the original ones. |
| 424 | mode: {``"bilinear"``, ``"nearest"``} or spline interpolation order 0-5 (integers). |
no outgoing calls
searching dependent graphs…