Skip to content

Commit 2ecaef9

Browse files
Ensuring the cropping transform is invertible (#1262)
This is a small change to ensure the transform is invertible and works with the latest monai code-base. --------- Signed-off-by: myron <amyronenko@nvidia.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent c501cbe commit 2ecaef9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

auto3dseg/tasks/hecktor22/hecktor_crop_neck_region.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def __call__(self, data):
5050

5151
box_start, box_end = self.extract_roi(im_pet=im_pet, box_size=box_size)
5252

53-
if "label" in d and "label" in self.keys:
53+
use_label = "label" in d and "label" in self.keys and (d["image"].shape[1:] == d["label"].shape[1:])
54+
55+
if use_label:
5456
# if label mask is available, let's check if the cropped region includes all foreground
5557
before_sum = d["label"].sum().item()
5658
after_sum = (
@@ -83,7 +85,8 @@ def __call__(self, data):
8385
d[self.end_coord_key] = box_end
8486

8587
for key, m in self.key_iterator(d, self.mode):
86-
self.push_transform(d, key, extra_info={"box_start": box_start, "box_end": box_end})
88+
if key == "label" and not use_label:
89+
continue
8790
d[key] = self.cropper.crop_pad(img=d[key], box_start=box_start, box_end=box_end, mode=m)
8891

8992
return d

0 commit comments

Comments
 (0)