-
Notifications
You must be signed in to change notification settings - Fork 13
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
[ENH]: Rework masking logic #395
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 task
|
fraimondo
approved these changes
Nov 18, 2024
synchon
force-pushed
the
refactor/mask-logic
branch
from
November 19, 2024 12:27
2870f1a
to
b0acf15
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #395 +/- ##
========================================
- Coverage 0.01% 0.01% -0.01%
========================================
Files 133 133
Lines 5675 5698 +23
========================================
Hits 1 1
- Misses 5674 5697 +23
Flags with carried forward coverage won't be shown. Click here to find out more.
|
synchon
force-pushed
the
refactor/mask-logic
branch
3 times, most recently
from
November 28, 2024 12:04
681952d
to
a9c31b2
Compare
synchon
force-pushed
the
refactor/mask-logic
branch
2 times, most recently
from
December 3, 2024 10:54
1f2d0ef
to
b8a0899
Compare
3 tasks
synchon
force-pushed
the
refactor/mask-logic
branch
from
December 5, 2024 16:38
2d6c069
to
75a733a
Compare
synchon
force-pushed
the
refactor/mask-logic
branch
from
December 6, 2024 10:39
75a733a
to
c160e88
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Right after "computing the brain mask", we resample the brain mask to the image and apply the threshold:
junifer/junifer/data/masks/_masks.py
Lines 109 to 115 in a0f883b
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_mask
andcompute_epi_mask
in native space, why not?I think the whole
get
function 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 #394 (comment)