[ENH]: Rework masking logic #395
No reviewers
Labels
No labels
CRITICAL
Stale
WIP
bug
concept
coordinate
dataset
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
maintenance
maps
marker
mask
on hold
parcellation
preprocess
question
ready
storage
template-space
triage
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
juaml/junifer!395
Loading…
Reference in a new issue
No description provided.
Delete branch "refactor/mask-logic"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Right after "computing the brain mask", we resample the brain mask to the image and apply the threshold:
github.com/juaml/junifer@a0f883bbfb/junifer/data/masks/_masks.py (L109-L115)The order made sense when we implemented: we resample and then threshold, as these are probability maps.
When we added the multi-MNI space and "warping" to masks, we now need to do the warping BEFORE thresholding. What we actually want to warp is the probability map and then apply the threshold.
In short, compute_brain_mask should already give you the mask in the required space, even if this is "native" space.
We should also be able to combine
compute_brain_maskandcompute_epi_maskin native space, why not?I think the whole
getfunction is flawed in this sense as we started adding features like combining, interescting, computing and using pre-defined masks.The logic should be:
While this might be inefficient at some point (warping many images from the same MNI to native separately), it is a rare use case in which one might want to "merge" two or more masks that are in standard space to be used in native space. Usually (except for HCP), one has the subject-specific probseg files and can use the compute_brain_mask without warping.
A possible optimization would be: in the case that all masks are non-computed and the target space is native, warp to the intermediate required standard space and delay warping to native space at the end, after intersection/union/etc. Will not be numerically equal but would be conceptually the same in case of union/intersection (threshold 0 or 1)
Originally posted by @fraimondo in https://github.com/juaml/junifer/issues/394#issuecomment-2473608459
Codecov Report
Attention: Patch coverage is
0%with54 linesin your changes missing coverage. Please review.Additional details and impacted files
100.00% <ø> (ø)0.00% <0.00%> (ø)Flags with carried forward coverage won't be shown. Click here to find out more.
0.00% <ø> (ø)0.00% <0.00%> (ø)0.00% <0.00%> (ø)