Skip to content
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

Merged
merged 2 commits into from
Nov 29, 2017

Conversation

effigies
Copy link
Member

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:

  1. If qform/sform codes are bad, declare "WARNING - Invalid header"; if only qform is invalid, declare "WARNING - Invalid qform".
  2. If the qform is invalid (and is not marked invalid), note it simply in the description.
  3. If qform/sform are valid, but out of sync, make a note (without "WARNING") that they're mismatched.

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.

Copy link
Member

@oesteban oesteban left a 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.

@@ -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())
Copy link
Member

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.

<p class="elem-desc">Input file does not have a valid qform matrix.</p>
"""

if not (valid_qform and matching_affines):
Copy link
Member

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).

Copy link
Member Author

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.

Copy link
Member

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.

@oesteban oesteban merged commit 387ad83 into nipreps:master Nov 29, 2017
@effigies effigies deleted the bold_qform_sync branch November 29, 2017 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants