Dictionary-based wrapper of :py:class:`monai.transforms.WriteFileMapping`. Args: keys: keys of the corresponding items to be transformed. See also: :py:class:`monai.transforms.compose.MapTransform` mapping_file_path: Path to the JSON file where the mapping
| 321 | |
| 322 | |
| 323 | class WriteFileMappingd(MapTransform): |
| 324 | """ |
| 325 | Dictionary-based wrapper of :py:class:`monai.transforms.WriteFileMapping`. |
| 326 | |
| 327 | Args: |
| 328 | keys: keys of the corresponding items to be transformed. |
| 329 | See also: :py:class:`monai.transforms.compose.MapTransform` |
| 330 | mapping_file_path: Path to the JSON file where the mappings will be saved. |
| 331 | Defaults to "mapping.json". |
| 332 | allow_missing_keys: don't raise exception if key is missing. |
| 333 | """ |
| 334 | |
| 335 | def __init__( |
| 336 | self, keys: KeysCollection, mapping_file_path: Path | str = "mapping.json", allow_missing_keys: bool = False |
| 337 | ) -> None: |
| 338 | super().__init__(keys, allow_missing_keys) |
| 339 | self.mapping = WriteFileMapping(mapping_file_path) |
| 340 | |
| 341 | def __call__(self, data: Mapping[Hashable, NdarrayOrTensor]) -> dict[Hashable, NdarrayOrTensor]: |
| 342 | d = dict(data) |
| 343 | for key in self.key_iterator(d): |
| 344 | d[key] = self.mapping(d[key]) |
| 345 | return d |
| 346 | |
| 347 | |
| 348 | LoadImageD = LoadImageDict = LoadImaged |