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

to_nibabel and from_nibabel don't cancel out #64

Closed
dangom opened this issue Jul 6, 2019 · 4 comments
Closed

to_nibabel and from_nibabel don't cancel out #64

dangom opened this issue Jul 6, 2019 · 4 comments

Comments

@dangom
Copy link
Contributor

dangom commented Jul 6, 2019

Describe the bug
I believe this may be related to #52. I've just built AntsPy from master, though, so the fix for #52 doesn't solve the issue.
For an ANTsImage (RSA), converting to and from nibabel changes their orientation (or at least their display). Also values for spacing and direction change.

To Reproduce
Steps to reproduce the behavior:

import ants
data = ants.image_read("some_nifti_rsa.nii")
ants.plot_ortho(data, flat=True)
ants.plot_ortho(ants.from_nibabel(ants.to_nibabel(data)), flat=True)

Expected behavior
The to_nibabel and from_nibabel conversions cancel each other out?

Screenshots

Screen Shot 2019-07-05 at 20 16 18

Screen Shot 2019-07-05 at 20 19 42

Desktop (please complete the following information):

  • OS: mac high sierra
  • ANTsPy: master
  • nibabel: 2.3.3
@stnava
Copy link
Member

stnava commented Jul 6, 2019

I've tested this in the past and it "works for me"

this probably tests the same thing:

def test_nibabel(self):
fn = ants.get_ants_data( 'mni' )
ants_img = ants.image_read( fn )
nii_mni = nib.load( fn )
ants_mni = ants_img.to_nibabel()
self.assertTrue( ( ants_mni.get_qform() == nii_mni.get_qform() ).all() )
temp = ants.from_nibabel( nii_mni )
self.assertTrue(ants.image_physical_space_consistency(ants_img,temp))

is there something different about these images? if you look at the code, I don't think there is any way that spacing could change as you describe ....... would need a reproducible example to debug.

@stnava
Copy link
Member

stnava commented Jul 6, 2019

also ITK coords are LPS.

@dangom
Copy link
Contributor Author

dangom commented Jul 6, 2019

Yes, get_ants_data('mni') doesn't showcase the issue. I tried that too as I thought that'd be a more reproducible example.
Try with the following data (zipped because github)
clone.nii.zip

import ants
data = ants.image_read("~/Downloads/clone.nii")
ants.plot_ortho(data, flat=True)
ants.plot_ortho(ants.from_nibabel(ants.to_nibabel(data)), flat=True)

@stnava
Copy link
Member

stnava commented Jul 6, 2019

probably resolved with 30b0038

please reopen if not

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

No branches or pull requests

2 participants