Skip to content
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

Certain Transformations disregard *args and **kwargs (including copy) #1223

Open
1 task done
nicoloesch opened this issue Oct 15, 2024 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@nicoloesch
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Bug summary

Certain children of the base class torchio.Transform do not adhere to the *args and **kwargs provided during __init__ as they utilise already existing transformations in apply_transform. This mainly includes the kwarg copy, which is not passed to the transform utilised in apply_transform. However, other attributes may be required depending on the circumstances.

Examples of this are:

  • torchio.transforms.preprocessing.spatial.crop_or_pad.CropOrPad: L.282 and L.286 -> no instantiation of Crop/Pad with self.copy
  • torchio.transforms.preprocessing.label.sequential_labels.SequentialLabels: L. 55 -> no instantiation of RemapLabels with self.copy
  • torchio.transforms.preprocessing.spatial.ensure_shape_multiple.EnsureShapeMultiple: L.136 -> no instantiation of CropOrPad with self.copy
  • torchio.transforms.preprocessing.spatial.resize.Resize: L. 75 -> no instantiation of CropOrPad with self.copy

This extends to any transformation that re-utilises an already defined base transformation.

Code for reproduction

from torchio import CropOrPad
from torchio.datasets import Colin27

subject = Colin27()
transform = CropOrPad((64,64,64), copy=False)

transformed = transform(subject)

Actual outcome

The underlying transform in apply_transform is not called with copy=False as intended in the Constructor. This results in the copying of the respective copying of the Subject despite not defined by the user.

Error messages

No response

Expected outcome

All *args and **kwargs of any Transform should be passed onto each temporary/placeholder transform during apply_transform if it utilises an already implemented Transform opposed to a standalone implementation.

System info

Platform:   Linux-6.8.0-45-generic-x86_64-with-glibc2.35
TorchIO:    0.20.1
PyTorch:    2.3.1
SimpleITK:  2.4.0 (ITK 5.4)
NumPy:      2.0.2
Python:     3.10.15 (main, Oct  3 2024, 07:27:34) [GCC 11.2.0]
@nicoloesch nicoloesch added the bug Something isn't working label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant