-
Notifications
You must be signed in to change notification settings - Fork 290
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
[RFC] ENH: Always sync qforms, refactor error messaging #851
Conversation
df30e54
to
79865a1
Compare
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.
Seems reasonable, but we would get the same ValueError
(just earlier). Please check that. Thanks for the clarification on the appropriate xform codes.
fmriprep/interfaces/images.py
Outdated
@@ -370,47 +370,54 @@ def _run_interface(self, runtime): | |||
# Check affine information is valid | |||
valid_codes = (qform_code, sform_code) != (0, 0) | |||
|
|||
# Matching affines | |||
matching_affines = np.allclose(img.get_qform(), img.get_sform()) |
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.
If valid_qform is False
this line will fail: img.get_qform()
will raise a ValueError
.
fmriprep/interfaces/images.py
Outdated
<p class="elem-desc">Input file does not have a valid qform matrix.</p> | ||
""" | ||
|
||
if not (valid_qform and matching_affines): |
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.
like before, if qform is not valid then it doesn't make much sense to see if it matches the sform (or, better said, you can't even check).
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 is a short-circuit. We want to set the qform in the two cases: not valid_qform
and not matching_affines
.
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, I just wanted to point out the fact that we need to set matching_affines
in a different way for this switch to work as expected.
Follow-up to #847, intended to clarify my opinions on this interface.
First, I think this is the easiest place to go ahead and sync qforms and sforms, unconditionally.
Second, I've refactored the warnings to follow this logic:
Just as some after-the-fact commentary on #847: I think the warnings for invalid qforms are weird, in that a qform_code of 0 is treated as intensifying the problem with invalid qforms, rather than mitigating it. It's bad and marked as bad. That seems like some software did a reasonable thing, even if it's now something we have to clean up after.
Relatedly, I think the only time that we need to say analyses "MAY BE INVALID" is when there is no usable qform or sform. A good sform but bad qform is a totally reasonable situation to be in, if it weren't for our choice of using ANTs. It's thus our responsibility to handle that case, and make clear what we've done, but we know from the headers what the correct orientation of the image is.
I'm okay with keeping code 1 as the default. I think that makes sense when we use the default affine. However, if we sync the sform, we should use whatever code it has.