Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following #1426, this PR proposes to improve the
crop_nifti
function.Currently the function behaves in a very specific way, by cropping the provided image with a hardcoded bounding box that we defined for a specific use case (T1 images with MNI reference template). Therefore, I think the name is misleading and we could make use of a more generic function.
This PR proposes to make
crop_nifti
more generic by letting users provide both the bounding box and the reference image. If no bounding box is provided, then no cropping is performed. If no reference image is provided, the input image is used as a reference. In other wordscrop_nifti(img)
with no other argument is the identity function.The old
crop_nifti
has been renamedcrop_nifti_using_t1_mni_template
and is nothing more than a partial function on the newcrop_nifti
, calling it with the MNI_BBOX and the MNI cropped template.Implementation details: I introduced two classes called
NiftiImage
andNiftiImage3D
which behave as wrappers around a path to a nifti image. I'm still unsure whether we should keep them or not, but I think it could help us reduce boilerplate code we have in various places to check that a nifti is 3D, or that a nifti file exists, and so on.