Crop to bounding box of the mask #677
Replies: 3 comments 10 replies
-
Hello If you implement, it , I would go with CropOrPad, but the risk is then if mask are changing from subject to subject, you may end up with different crop between subject and thus a different shape, which is not a good idea I hope it helps |
Beta Was this translation helpful? Give feedback.
-
This seems to be related to #675 @mattwarkentin, can you tell us a bit more about what you're planning to do? |
Beta Was this translation helpful? Give feedback.
-
Indeed this is what I am trying to avoid. By choosing a fixed size, you will end up with more or less (perhaps undesired) volume surrounding the ROI.
This is true, but I think when paired with the recently added
@fepegar I think there are use-cases where one might want to crop an ROI to "fill" the FOV. In other words, even if the ROI is a different size across subjects, the cropped volume will have the ROI centred and generally filling the cropped volume space. In the example of #675, one may wish to crop down to the bounding box of the lung mask, and then resize so that the output volumes for all subjects are equivalent in shape. For example, sub = tio.Subject(
image = tio.ScalarImage(...),
mask = tio.LabelMap(...)
)
trans = tio.Compose([
tio.CropToMask('mask'),
tio.Resize((100, 100, 100))
])
sub_t = trans(sub) In this case, you will always get a consistent volume size that contains the entire ROI for every subject; and the ROI will generally fill the viewport. Hopefully that makes sense. Please let me know if you think this is not sensible. |
Beta Was this translation helpful? Give feedback.
-
Hi @fepegar,
Is there a way to crop to the bounding box of the non-zero values in a mask?
Such as with data like:
Beta Was this translation helpful? Give feedback.
All reactions