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

Method _resolve_spatial_shape

monai/transforms/post/array.py:879–891  ·  view source on GitHub ↗
(self, call_shape: Sequence[int] | None, spatial_dims: int)

Source from the content-addressed store, hash-verified

877 return converted
878
879 def _resolve_spatial_shape(self, call_shape: Sequence[int] | None, spatial_dims: int) -> tuple[int, ...]:
880 shape = call_shape if call_shape is not None else self.spatial_shape
881 if shape is None:
882 raise ValueError("Argument `spatial_shape` must be provided either at construction time or call time.")
883 shape_tuple = ensure_tuple(shape)
884 if len(shape_tuple) != spatial_dims:
885 if len(shape_tuple) == 1:
886 shape_tuple = shape_tuple * spatial_dims # type: ignore
887 else:
888 raise ValueError(
889 "Argument `spatial_shape` length must match the landmarks' spatial dims (or pass a single int to broadcast)."
890 )
891 return tuple(int(s) for s in shape_tuple)
892
893 def _resolve_sigma(self, spatial_dims: int) -> tuple[float, ...]:
894 if len(self._sigma) == spatial_dims:

Callers 1

__call__Method · 0.95

Calls 1

ensure_tupleFunction · 0.90

Tested by

no test coverage detected