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
[FIX] INU correction before merging several T1w #925
Conversation
Otherwise, we get funky composite bias fields that N4 can't recover. This will also make coregistration between T1s robuster.
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.
This looks reasonable, though I think we can simplify further in the N = 1 case.
My main concern will be whether doubling up of N4 correction (because it's also performed in the skull-stripping step) might cause artifacts.
Possibly a simpler (conceptually, if not in practice) solution would be to factor N4 out of skull-stripping, apply before merging, and eliminate the need to branch on number of T1w images at all.
fmriprep/workflows/anatomical.py
Outdated
|
||
workflow.connect([ | ||
(t1_conform, t1_reorient, [(('out_file', _get_first), 'in_file')]), | ||
(t1_reorient, concat_affines, [('transform', 'mat_BtoC')]), |
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.
t1_reorient
is not necessary if t1_merge
is not used. Conformation orients to RAS, but for reasons I don't understand, merging sometimes changes the orientation. Then you can get rid of concat_affines
and just use the conformation affine.
I've been working at times in a pure-nipype implementation of I'm not particularly worried about running N4 twice though, as long as it gets us sensible brain masks. But I agree, it'd be better not doubling up. |
Okay, so if we're fairly confident that the quality of the brain mask would be unaffected, but don't want to risk any artifacts of doubling up N4, we could use the following sequence in all cases:
This would mean we stop using the WDYT? |
Yes, though I would give it a try to what we have right now. My real, deep interest in deconstructing
But I can't see this happening anytime soon. |
Alright. So we can keep this if branch for now, and maybe create an issue to move to avoid having double N4 correction in skull-stripping outputs. It shouldn't be a huge task, but it will still be some work. |
I'd go for that. I'm simplifying the workflow following your suggestions. |
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.
Looks reasonable. Some small comments.
CHANGES.rst
Outdated
@@ -1,6 +1,7 @@ | |||
1.0.3 (3rd of January 2018) | |||
=========================== | |||
|
|||
* [FIX] INU correction before merging several T1w (#925). |
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.
Should go in a "Next release" section.
#Transform 0 | ||
Transform: MatrixOffsetTransformBase_double_3_3 | ||
Parameters: 1 0 0 0 1 0 0 0 1 0 0 0 | ||
FixedParameters: 0 0 0 |
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.
I think this file will need to be added to setup.py
?
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.
yes
fmriprep/workflows/anatomical.py
Outdated
concat_affines = pe.MapNode( | ||
ConcatAffines(3, invert=True), iterfield=['mat_AtoB', 'mat_BtoC'], | ||
ConcatAffines(1 + min(num_t1w, 2), invert=True), |
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.
I think you can revert lta_to_fsl
and concat_affines
entirely, cleaning up the diff a little.
In any event, this no longer needs the 1 + min(...)
construct.
Otherwise, we get funky composite bias fields that N4 can't recover.
This will also make coregistration between T1s robuster.
Fixes #924