-
Notifications
You must be signed in to change notification settings - Fork 55
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
Continuing refactoring of the extraction objects #686
Continuing refactoring of the extraction objects #686
Conversation
The classes are now tested with 100% coverage. |
I just added some useful class methods to manipulate TorchIO's class
So, in the participant, session, img_index, sample_index = self._get_meta_data(idx)
image, image_path = self._get_image(img_index)
label = self._get_label(img_index)
tio_image = self.transforms.extraction.get_tio_image(image, label)
tio_image = self.transforms.image_transforms(tio_image)
if not self.eval_mode:
tio_image = self.transforms.image_augmentation(tio_image)
tio_sample = self.transforms.extraction.extract_tio_sample(tio_image, sample_index)
tio_sample = self.transforms.sample_transforms(tio_sample)
if not self.eval_mode:
tio_sample = self.transforms.sample_augmentation(tio_sample)
return self.transforms.extraction.format_output(
tio_sample,
participant_id=participant,
session_id=session,
image_path=image_path,
) |
In |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM !
Following #685, I continued the refactoring of the extraction classes
Image
,ROI
,Patch
andSlice
. I suggest to get rid of some complicated features while adding some useful ones:For all: remove
use_uncropped_image
that should be put inPreprocessing
.Slice
: in addition todiscarded_slices
that only enable slice filtering, I suggest to introduce two new arguments.slices
enables slice selection (e.g.Slice(slices=[128, 129, 130])
); andborders
enables slice filtering at the edge of the image. For example,Slice(discarded_slices=[42], borders=5)
will filter out the slice with index42
, as well as the first five and the last five slices in each direction.borders
can also be specified for each border (e.g.Slice(borders=((1, 1), (2, 3), (1, 1))
).Patch
: I suggest to enable anisotropic sliding window by allowing the user to pass anisotropic values forpatch_size
andstride
(e.g.Patch(patch_size=(18, 16, 17), stride=(1, 1, 2)
).ROI
: to replaceroi_list
,roi_mask_location
,roi_crop_input
,roi_crop_output
,roi_template
,roi_mask_pattern
,roi_custom_template
androi_custom_mask_pattern
, I would suggest to have only two arguments.masks
, where a list of masks can be passed via their file location (e.g.ROI(masks=["masks/leftHippocampus.nii.gz", "masks/rightHippocampus.nii.gz"])
); andcrop
that enables to filter out regions that are always 0 for all masks, in order to reduce the size of the images.In doing so, I purposely release some constraints on the masks that can be used, that I felt unnecessary.
Besides, I also made some minor changes:
BaseExtraction
toExtraction
, in order not to haveBase...
in our typings;roi
,patch
,slice
andimage
under the generic wordsample
. I changed the function names and dosctrings accordingly;As of now, the classes are not tested. i'm waiting for your opinion first.