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

Function pre_process_data

monai/transforms/utils_create_transform_ims.py:271–277  ·  view source on GitHub ↗

If transform requires 2D data, then convert to 2D by selecting the middle of the last dimension.

(data, ndim, is_map, is_post)

Source from the content-addressed store, hash-verified

269
270
271def pre_process_data(data, ndim, is_map, is_post):
272 """If transform requires 2D data, then convert to 2D by selecting the middle of the last dimension."""
273 if ndim == 2:
274 data = {k: v[..., v.shape[-1] // 2] for k, v in data.items()}
275 if is_map:
276 return data
277 return data[CommonKeys.LABEL] if is_post else data[CommonKeys.IMAGE]
278
279
280def get_2d_slice(image, view: int, is_label):

Callers 1

create_transform_imFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…