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

Method __call__

monai/transforms/utility/array.py:971–988  ·  view source on GitHub ↗

Args: label: input data to compute foreground and background indices. image: if image is not None, use ``label = 0 & image > image_threshold`` to define background. so the output items will not map to all the voxels in the label. output_sh

(
        self, label: NdarrayOrTensor, image: NdarrayOrTensor | None = None, output_shape: Sequence[int] | None = None
    )

Source from the content-addressed store, hash-verified

969 self.output_shape = output_shape
970
971 def __call__(
972 self, label: NdarrayOrTensor, image: NdarrayOrTensor | None = None, output_shape: Sequence[int] | None = None
973 ) -> tuple[NdarrayOrTensor, NdarrayOrTensor]:
974 """
975 Args:
976 label: input data to compute foreground and background indices.
977 image: if image is not None, use ``label = 0 & image > image_threshold``
978 to define background. so the output items will not map to all the voxels in the label.
979 output_shape: expected shape of output indices. if None, use `self.output_shape` instead.
980
981 """
982 if output_shape is None:
983 output_shape = self.output_shape
984 fg_indices, bg_indices = map_binary_to_indices(label, image, self.image_threshold)
985 if output_shape is not None:
986 fg_indices = unravel_indices(fg_indices, output_shape)
987 bg_indices = unravel_indices(bg_indices, output_shape)
988 return fg_indices, bg_indices
989
990
991class ClassesToIndices(Transform, MultiSampleTrait):

Callers

nothing calls this directly

Calls 2

map_binary_to_indicesFunction · 0.90
unravel_indicesFunction · 0.90

Tested by

no test coverage detected