From 05816d5622034c6df3d0f0134c3a26bf0872567d Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:07:45 +0800 Subject: [PATCH] fix #8186 Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- monai/transforms/transform.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/monai/transforms/transform.py b/monai/transforms/transform.py index 15c2499a73..afd6bf9f84 100644 --- a/monai/transforms/transform.py +++ b/monai/transforms/transform.py @@ -136,8 +136,10 @@ def apply_transform( Union[List[ReturnType], ReturnType]: The return type of `transform` or a list thereof. """ try: - if isinstance(data, (list, tuple)) and map_items: - return [_apply_transform(transform, item, unpack_items, lazy, overrides, log_stats) for item in data] + if not map_items: + return _apply_transform(transform, data, unpack_items, lazy, overrides, log_stats) + if isinstance(data, (list, tuple)): + return [apply_transform(transform, item, map_items, unpack_items, log_stats, lazy, overrides) for item in data] return _apply_transform(transform, data, unpack_items, lazy, overrides, log_stats) except Exception as e: # if in debug mode, don't swallow exception so that the breakpoint