Skip to content

Commit 4bb8b5d

Browse files
committed
fixes tests
Signed-off-by: Wenqi Li <[email protected]>
1 parent aa1bcdd commit 4bb8b5d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

monai/data/meta_tensor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ def __init__(
150150

151151
if MetaKeys.SPACE not in self.meta:
152152
self.meta[MetaKeys.SPACE] = SpaceKeys.RAS # defaulting to the right-anterior-superior space
153+
if MetaKeys.EVALUATED not in self.meta:
154+
self.meta[MetaKeys.EVALUATED] = True
153155
if MetaKeys.ORIGINAL_CHANNEL_DIM not in self.meta:
154-
self.meta[MetaKeys.ORIGINAL_CHANNEL_DIM] = 0 # defaulting to channel first
156+
self.meta[MetaKeys.ORIGINAL_CHANNEL_DIM] = "no_channel" # defaulting to channel first
155157

156158
@property
157159
def evaluated(self) -> bool:

tests/test_ensure_channel_first.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ def test_check(self):
8181
with self.assertRaises(ValueError): # not MetaTensor
8282
EnsureChannelFirst(add_channel_default=False)(im)
8383
with self.assertRaises(ValueError): # no meta
84-
EnsureChannelFirst(add_channel_default=False)(MetaTensor(im))
84+
test_case = MetaTensor(im)
85+
test_case.meta.pop("original_channel_dim")
86+
EnsureChannelFirst(add_channel_default=False)(test_case)
8587
with self.assertRaises(ValueError): # no meta channel
8688
EnsureChannelFirst(add_channel_default=False)(im_nodim)
8789

0 commit comments

Comments
 (0)