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

Class EnsureChannelFirstd

monai/transforms/utility/dictionary.py:259–288  ·  view source on GitHub ↗

Dictionary-based wrapper of :py:class:`monai.transforms.EnsureChannelFirst`.

Source from the content-addressed store, hash-verified

257
258
259class EnsureChannelFirstd(MapTransform):
260 """
261 Dictionary-based wrapper of :py:class:`monai.transforms.EnsureChannelFirst`.
262 """
263
264 backend = EnsureChannelFirst.backend
265
266 def __init__(
267 self, keys: KeysCollection, strict_check: bool = True, allow_missing_keys: bool = False, channel_dim=None
268 ) -> None:
269 """
270 Args:
271 keys: keys of the corresponding items to be transformed.
272 See also: :py:class:`monai.transforms.compose.MapTransform`
273 strict_check: whether to raise an error when the meta information is insufficient.
274 allow_missing_keys: don't raise exception if key is missing.
275 channel_dim: This argument can be used to specify the original channel dimension (integer) of the input array.
276 It overrides the `original_channel_dim` from provided MetaTensor input.
277 If the input array doesn't have a channel dim, this value should be ``'no_channel'``.
278 If this is set to `None`, this class relies on `img` or `meta_dict` to provide the channel dimension.
279 """
280 super().__init__(keys, allow_missing_keys)
281 self.adjuster = EnsureChannelFirst(strict_check=strict_check, channel_dim=channel_dim)
282
283 def __call__(self, data: Mapping[Hashable, torch.Tensor]) -> dict[Hashable, torch.Tensor]:
284 d = dict(data)
285 for key in self.key_iterator(d):
286 meta_dict = d[key].meta if isinstance(d[key], MetaTensor) else None # type: ignore[attr-defined]
287 d[key] = self.adjuster(d[key], meta_dict)
288 return d
289
290
291class RepeatChanneld(MapTransform):

Callers 15

_default_transformsFunction · 0.90
get_dataFunction · 0.90
initializeMethod · 0.90
initializeMethod · 0.90
run_training_testFunction · 0.90
test_warn_non_randomMethod · 0.90
test_train_timingMethod · 0.90
run_testMethod · 0.90

Calls

no outgoing calls

Tested by 15

run_training_testFunction · 0.72
test_warn_non_randomMethod · 0.72
test_train_timingMethod · 0.72
run_testMethod · 0.72
run_training_testFunction · 0.72
run_inference_testFunction · 0.72
test_nnunet_bundleMethod · 0.72
run_training_testFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…