torchio
torchio copied to clipboard
the results are not expected when using the include='str', exclude='str' arguments in the transform
Is there an existing issue for this?
- [X] I have searched the existing issues
Bug summary
For example, If I have several scans in the a subject such as subject['img'] subject['imgCT'], subject['label']. the include and exclude augments in transform will have unexpected behaviour.
this is because in the function:
class Subject(dict): def get_images_dict( self, intensity_only=True, include: Optional[Sequence[str]] = None, exclude: Optional[Sequence[str]] = None, ) -> Dict[str, Image]: images = {} for image_name, image in self.items(): if not isinstance(image, Image): continue if intensity_only and not image[TYPE] == INTENSITY: continue if include is not None and image_name not in include: continue if exclude is not None and image_name in exclude: continue images[image_name] = image return images
in the line "if include is not None and image_name not in include: " , if image_name = 'img' and include = 'imgCT'. the subject['img'] will still be included in the computation for the transform.
Code for reproduction
import torch
import torchio as tio
subject = tio.Subject(
imgCT = tio.ScalarImage(os.path.join(case_path, 'imgCT.nii.gz')),
img = tio.ScalarImage(os.path.join(case_path, 'img.nii.gz')),
label = tio.LabelMap(os.path.join(case_path, 'segm.nii.gz'))
)
subject.plot()
transform = tio.Compose([
tio.RandomAffine(degrees=(20, 30), exclude='img'),
tio.RandomBlur(std=(3, 4), include='imgCT'),
])
transformed = transform(subject)
transformed.plot()
Actual outcome
as described above the subject['img'] will still be included in the computation for the transform.
Error messages
No response
Expected outcome
the subject['img'] should not be included in the computation for the transform.
System info
No response