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

Method __call__

monai/transforms/spatial/array.py:1273–1294  ·  view source on GitHub ↗

Args: img: channel first array, must have shape: (num_channels, H[, W, ..., ]), randomize: whether to execute `randomize()` function first, default to True. lazy: a flag to indicate whether this transform should execute lazily or not durin

(self, img: torch.Tensor, randomize: bool = True, lazy: bool | None = None)

Source from the content-addressed store, hash-verified

1271 self._rand_k = self.R.randint(self.max_k) + 1
1272
1273 def __call__(self, img: torch.Tensor, randomize: bool = True, lazy: bool | None = None) -> torch.Tensor:
1274 """
1275 Args:
1276 img: channel first array, must have shape: (num_channels, H[, W, ..., ]),
1277 randomize: whether to execute `randomize()` function first, default to True.
1278 lazy: a flag to indicate whether this transform should execute lazily or not
1279 during this call. Setting this to False or True overrides the ``lazy`` flag set
1280 during initialization for this call. Defaults to None.
1281 """
1282
1283 if randomize:
1284 self.randomize()
1285
1286 lazy_ = self.lazy if lazy is None else lazy
1287 if self._do_transform:
1288 xform = Rotate90(self._rand_k, self.spatial_axes, lazy=lazy_)
1289 out = xform(img)
1290 else:
1291 out = convert_to_tensor(img, track_meta=get_track_meta())
1292
1293 self.push_transform(out, replace=True, lazy=lazy_)
1294 return out
1295
1296 def inverse(self, data: torch.Tensor) -> torch.Tensor:
1297 xform_info = self.pop_transform(data)

Callers

nothing calls this directly

Calls 5

randomizeMethod · 0.95
convert_to_tensorFunction · 0.90
get_track_metaFunction · 0.90
Rotate90Class · 0.85
push_transformMethod · 0.80

Tested by

no test coverage detected