Skip to content

Commit ef68f16

Browse files
authored
Solve LoadImage issue when track_meta is False (#5239)
1. Fix the issue #5227 2. fix a small code flaw Signed-off-by: David <dyq.004@gmail.com>
1 parent 21ad9c8 commit ef68f16

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

monai/data/meta_obj.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ def meta(self, d) -> None:
174174
"""Set the meta."""
175175
if d == TraceKeys.NONE:
176176
self._meta = MetaObj.get_default_meta()
177-
self._meta = d
177+
else:
178+
self._meta = d
178179

179180
@property
180181
def applied_operations(self) -> list[dict]:

monai/transforms/io/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def __call__(self, filename: Union[Sequence[PathLike], PathLike], reader: Option
278278
img = EnsureChannelFirst()(img)
279279
if self.image_only:
280280
return img
281-
return img, img.meta # for compatibility purpose
281+
return img, img.meta if isinstance(img, MetaTensor) else meta_data
282282

283283

284284
class SaveImage(Transform):

0 commit comments

Comments
 (0)