(data: dict)
| 115 | |
| 116 | @staticmethod |
| 117 | def inverse(data: dict) -> dict[Hashable, np.ndarray]: |
| 118 | if not isinstance(data, Mapping): |
| 119 | raise RuntimeError(f"Inverse can only currently be applied on dictionaries, got type {type(data)}.") |
| 120 | |
| 121 | d = dict(data) |
| 122 | for key in d: |
| 123 | transforms = None |
| 124 | if isinstance(d[key], MetaTensor): |
| 125 | transforms = d[key].applied_operations |
| 126 | else: |
| 127 | transform_key = InvertibleTransform.trace_key(key) |
| 128 | if transform_key in d: |
| 129 | transforms = d[transform_key] |
| 130 | if not transforms or not isinstance(transforms[-1], dict): |
| 131 | continue |
| 132 | if transforms[-1].get(TraceKeys.CLASS_NAME) == PadListDataCollate.__name__: |
| 133 | xform = transforms.pop() |
| 134 | cropping = CenterSpatialCrop(xform.get(TraceKeys.ORIG_SIZE, -1)) |
| 135 | with cropping.trace_transform(False): |
| 136 | d[key] = cropping(d[key]) # fallback to image size |
| 137 | return d |
nothing calls this directly
no test coverage detected