Skip to content

FIX: Correctly reorient dim_info when reorienting NIfTI images #741

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

Merged
merged 3 commits into from
Mar 19, 2019

Conversation

effigies
Copy link
Member

Starting with a test to demonstrate the failure. Will push a fix shortly.

cc @constracti

Fixes #716.

@effigies effigies added this to the 2.4.0 milestone Mar 17, 2019
@effigies effigies force-pushed the fix/dim_info_reorientation branch from 0e106e9 to c13756d Compare March 17, 2019 20:48
@effigies
Copy link
Member Author

Anybody up for a review on this?

@effigies
Copy link
Member Author

@markhymers This was originally your contribution. Would you care to check my logic, and make sure that I'm not breaking things?

@codecov-io
Copy link

codecov-io commented Mar 17, 2019

Codecov Report

Merging #741 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #741      +/-   ##
==========================================
- Coverage   89.55%   89.54%   -0.01%     
==========================================
  Files          93       93              
  Lines       11474    11470       -4     
  Branches     1992     1991       -1     
==========================================
- Hits        10275    10271       -4     
+ Misses        859      858       -1     
- Partials      340      341       +1
Impacted Files Coverage Δ
nibabel/nifti1.py 91.47% <100%> (-0.06%) ⬇️
nibabel/cmdline/parrec2nii.py 32.73% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9430224...7c37276. Read the comment docs.

@effigies effigies mentioned this pull request Mar 18, 2019
20 tasks
Copy link
Contributor

@constracti constracti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit does the same thing in a more pythonic way, as you note, with the list comprehension. It does not fix the bug.

@effigies
Copy link
Member Author

Thanks for the review.

I thought the confusion was that the freq/phase/slice ordering will only sometimes rotate in the same way as the shapes, but it turns out that orientations also didn't work how I thought... The issue was that I keep thinking of the orientation produced by axcodes2ornt as how to get from RAS to a given axis code, but it's exactly the reverse. So my consistency check was off, which was why your fix didn't seem to work. By instead cycling through orientations and getting the axis codes from the affine, I can now verify your proposed fix was correct.

@effigies effigies force-pushed the fix/dim_info_reorientation branch from 7847628 to 317b4ee Compare March 18, 2019 15:12
@effigies
Copy link
Member Author

@constracti I found 46476cc in your history, so I went ahead and cherry-picked it and got rid of my flailing about for a wrong solution. I did still tack on the refactor to a list comprehension and casting to int(), as orientation matrices may not be integer-typed. If you want to let me know your preferred name for publication, your ORCID and your affiliation, I'll update the mailmap and Zenodo file as needed.

@effigies effigies force-pushed the fix/dim_info_reorientation branch from 317b4ee to 7c37276 Compare March 18, 2019 15:33
@effigies
Copy link
Member Author

Any more comments?

@effigies
Copy link
Member Author

Thanks for the contribution and feedback.

@effigies effigies merged commit 2222df0 into nipy:master Mar 19, 2019
@effigies effigies deleted the fix/dim_info_reorientation branch March 19, 2019 12:04
@effigies effigies restored the fix/dim_info_reorientation branch March 19, 2019 12:09
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.

nifti dim_info transformation after orientation
3 participants