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

Function _stack_images

monai/data/image_reader.py:153–165  ·  view source on GitHub ↗
(image_list: list, meta_dict: dict, to_cupy: bool = False)

Source from the content-addressed store, hash-verified

151
152
153def _stack_images(image_list: list, meta_dict: dict, to_cupy: bool = False):
154 if len(image_list) <= 1:
155 return image_list[0]
156 if not is_no_channel(meta_dict.get(MetaKeys.ORIGINAL_CHANNEL_DIM, None)):
157 channel_dim = int(meta_dict[MetaKeys.ORIGINAL_CHANNEL_DIM])
158 if to_cupy and has_cp:
159 return cp.concatenate(image_list, axis=channel_dim)
160 return np.concatenate(image_list, axis=channel_dim)
161 # stack at a new first dim as the channel dim, if `'original_channel_dim'` is unspecified
162 meta_dict[MetaKeys.ORIGINAL_CHANNEL_DIM] = 0
163 if to_cupy and has_cp:
164 return cp.stack(image_list, axis=0)
165 return np.stack(image_list, axis=0)
166
167
168@require_pkg(pkg_name="itk")

Callers 7

get_dataMethod · 0.90
get_dataMethod · 0.85
get_dataMethod · 0.85
get_dataMethod · 0.85
get_dataMethod · 0.85
get_dataMethod · 0.85
get_dataMethod · 0.85

Calls 2

is_no_channelFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…