MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / Spacingd

Class Spacingd

monai/transforms/spatial/dictionary.py:367–540  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

365
366
367class 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).

Callers 15

_default_transformsFunction · 0.90
test_train_timingMethod · 0.90
run_training_testFunction · 0.90
run_inference_testFunction · 0.90
test_spacingdMethod · 0.90
test_orntd_torchMethod · 0.90
test_space_same_shapeMethod · 0.90
test_load_spacingdMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_train_timingMethod · 0.72
run_training_testFunction · 0.72
run_inference_testFunction · 0.72
test_spacingdMethod · 0.72
test_orntd_torchMethod · 0.72
test_space_same_shapeMethod · 0.72
test_load_spacingdMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…