-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add option to skip resizing for RestoreLabeld Transform #6380
Comments
Solution DescriptionAs @AHarouni said, I noticed that the I have made modifications to the
This design allows users to selectively enable or disable each restoration operation as needed, providing greater flexibility. Example CodeTake resize as an example # This is the modified portion of the code, with the addition of new parameters
def __init(
self,
# ... (original code)
resize: bool = True,
spacing: bool = True,
fetch_2d_sliced: bool = True,
spatial_crop_guidance: bool = True,
) -> None:
# ... (original code)
def __call__(self, data: Any) -> dict:
d = dict(data)
meta_dict: dict = d[f"{self.ref_image}_{self.meta_key_postfix}"]
for key, mode, align_corners, meta_key in self.key_iterator(d, self.mode, self.align_corners, self.meta_keys):
image = d[key]
# Undo Resize
if self.resize:
current_shape = image.shape
cropped_shape = meta_dict[self.cropped_shape_key]
if np.any(np.not_equal(current_shape, cropped_shape)):
resizer = Resize(spatial_size=cropped_shape[1:], mode=mode)
image = resizer(image, mode=mode, align_corners=align_corners)
# ... (original code)
d[key] = image
meta_key = meta_key or f"{key}_{self.meta_key_postfix}"
meta = d.get(meta_key)
if meta is None:
meta = dict()
d[meta_key] = meta
meta["affine"] = meta_dict["original_affine"]
return d Additional contextHappy and new to contribute ! 😊 |
Welcome the contribution, please refer to the Contribution Guide. |
Hi @AHarouni ,Thank you for raising this issue. Currently, I am trying to solve this issue, at present the program logic has been largely completed, but in order to ensure that the use of the context so that you and other users can effectively use the modified version, I would like to ask you whether it is convenient to provide a reproduce to help me to complete the test part of it? Thanks! |
Signed-off-by: Hsin Tong <[email protected]>
Is your feature request related to a problem? Please describe.
RestoreLabeld transform in monai label app does multiple operations:
1- restore resizing
2 - restore cropping
3- undo spacing
4- undo slicing
currently it is all or none. I need to select operations to do
Describe the solution you'd like
Please options to disable the resizing. may be options to skip restore cropping and spacing as well. user can always use restore transform to restore the spacing
Describe alternatives you've considered
I have copped the transform and created my own transform to disable the resizing
The text was updated successfully, but these errors were encountered: