diff --git a/monai/transforms/spatial/dictionary.py b/monai/transforms/spatial/dictionary.py index 00322abf41..7e664a508d 100644 --- a/monai/transforms/spatial/dictionary.py +++ b/monai/transforms/spatial/dictionary.py @@ -522,8 +522,8 @@ def __call__(self, data: Mapping[Hashable, torch.Tensor], lazy: bool | None = No output_spatial_shape=output_shape_k if should_match else None, lazy=lazy_, ) - if isinstance(d[key], MetaTensor) and "filename_or_obj" in d[key].meta: - if is_supported_format(d[key].meta["filename_or_obj"], ["nii", "nii.gz"]): + if isinstance(d[key], MetaTensor) and f"{key}_meta_dict" in d: + if 'filename_or_obj' in d[key].meta and is_supported_format(d[key].meta['filename_or_obj'], ["nii", "nii.gz"]): d = transforms.sync_meta_info(key, d) if output_shape_k is None: output_shape_k = d[key].peek_pending_shape() if isinstance(d[key], MetaTensor) else d[key].shape[1:]