Args: keys: keys of the corresponding items to be transformed. See also: :py:class:`monai.transforms.compose.MapTransform` output_postfixes: the postfixes to construct keys to store split data. for example: if the key of input data is
(
self,
keys: KeysCollection,
output_postfixes: Sequence[str] | None = None,
dim: int = 0,
keepdim: bool = True,
update_meta: bool = True,
list_output: bool = False,
allow_missing_keys: bool = False,
)
| 342 | backend = SplitDim.backend |
| 343 | |
| 344 | def __init__( |
| 345 | self, |
| 346 | keys: KeysCollection, |
| 347 | output_postfixes: Sequence[str] | None = None, |
| 348 | dim: int = 0, |
| 349 | keepdim: bool = True, |
| 350 | update_meta: bool = True, |
| 351 | list_output: bool = False, |
| 352 | allow_missing_keys: bool = False, |
| 353 | ) -> None: |
| 354 | """ |
| 355 | Args: |
| 356 | keys: keys of the corresponding items to be transformed. |
| 357 | See also: :py:class:`monai.transforms.compose.MapTransform` |
| 358 | output_postfixes: the postfixes to construct keys to store split data. |
| 359 | for example: if the key of input data is `pred` and split 2 classes, the output |
| 360 | data keys will be: pred_(output_postfixes[0]), pred_(output_postfixes[1]) |
| 361 | if None, using the index number: `pred_0`, `pred_1`, ... `pred_N`. |
| 362 | dim: which dimension of input image is the channel, default to 0. |
| 363 | keepdim: if `True`, output will have singleton in the split dimension. If `False`, this |
| 364 | dimension will be squeezed. |
| 365 | update_meta: if `True`, copy `[key]_meta_dict` for each output and update affine to |
| 366 | reflect the cropped image |
| 367 | list_output: it `True`, the output will be a list of dictionaries with the same keys as original. |
| 368 | allow_missing_keys: don't raise exception if key is missing. |
| 369 | """ |
| 370 | super().__init__(keys, allow_missing_keys) |
| 371 | self.output_postfixes = output_postfixes |
| 372 | self.splitter = SplitDim(dim, keepdim, update_meta) |
| 373 | self.list_output = list_output |
| 374 | if self.list_output is None and self.output_postfixes is not None: |
| 375 | raise ValueError("`output_postfixes` should not be provided when `list_output` is `True`.") |
| 376 | |
| 377 | def __call__( |
| 378 | self, data: Mapping[Hashable, torch.Tensor] |