Skip to content

Ensuring the cropping transform is invertible #1262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions auto3dseg/tasks/hecktor22/hecktor_crop_neck_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def __call__(self, data):

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

if "label" in d and "label" in self.keys:
use_label = "label" in d and "label" in self.keys and (d["image"].shape[1:] == d["label"].shape[1:])

if use_label:
# if label mask is available, let's check if the cropped region includes all foreground
before_sum = d["label"].sum().item()
after_sum = (
Expand Down Expand Up @@ -83,7 +85,8 @@ def __call__(self, data):
d[self.end_coord_key] = box_end

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

return d
Expand Down