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

Show method does not preserve pixel spacing #438

Closed
nocnokneo opened this issue Apr 10, 2018 · 8 comments
Closed

Show method does not preserve pixel spacing #438

nocnokneo opened this issue Apr 10, 2018 · 8 comments

Comments

@nocnokneo
Copy link

My expectation is that with the code below:

import SimpleITK as sitk
image = sitk.Image(64, 64, sitk.sitkFloat32)
image.SetSpacing((2.0, 3.0))
sitk.Show(image) # Image shown in ImageJ has unity pixel spacing

The image shown in ImageJ should have the same pixel spacing as image ((2.0, 3.0) in this case).

@nocnokneo nocnokneo changed the title Show does not preserve pixel spacing Show method does not preserve pixel spacing Apr 10, 2018
@blowekamp
Copy link
Member

This is an unfortunate limitation of ImageJ. It does not render anisotropic pixel spacing. You can configure sitk.Show to use another external viewer such as 3D Slicer or ITKSnap. This is documented in the SimpleITK Notebooks and in the Doxygen for Show.

@nocnokneo
Copy link
Author

I understand that ImageJ doesn't render anisotropic pixel spacing, but it does support measurements on an image with anisotropic pixel spacing.

Even when using isotropic pixel spacing as in:

import SimpleITK as sitk
image = sitk.Image(64, 64, sitk.sitkFloat32)
image.SetSpacing((2.0, 2.0))
sitk.Show(image) # Image shown in ImageJ has unity pixel spacing

The image shown in ImageJ by Show has 1 unit pixel spacing in all directions. From Analyze > Set Scale ... menu, this is what I see:

image

@blowekamp
Copy link
Member

blowekamp commented Apr 10, 2018 via email

@nocnokneo
Copy link
Author

nocnokneo commented Apr 11, 2018

Yep, using NRRD fixed it:

import os
os.environ["SITK_SHOW_EXTENSION"] = ".nrrd"

Being the default format used by SimpleITK and one designed for medical imaging I'd assumed that NIFTI supported pixel spacing information. Does it not? If not, perhaps the default format used by Show should be changed to NRRD?

@blowekamp
Copy link
Member

That is good you were able to find a work around.

The NIFTI file format certainly support spacing and other geometric imaging information. The limitation is in ImageJ(FIJI) not recognizing and using the spacing information. I would file a bug report with them.

We choose NIFTI over NRRD as the default export file format because ImageJ supports all pixel types for NIFTI, where as ImageJ does not support complex pixel types with NRRD file types.

@nocnokneo
Copy link
Author

Thanks for following up. I've filed an upstream bug: fiji/fiji#191

We choose NIFTI over NRRD as the default export file format because ImageJ supports all pixel types for NIFTI, where as ImageJ does not support complex pixel types with NRRD file types.

I see. That's unfortunate...

@nocnokneo
Copy link
Author

Looks like sitk.Show() is using .mha, at least for some users.[1] Has the default file format only recently changed to NIFTI?

[1] http://lists.openmicroscopy.org.uk/pipermail/ome-users/2018-May/007060.html

@dave3d
Copy link
Member

dave3d commented May 29, 2018

When the Show function uses Fiji, the default image format is set to '.mha'. We did that because for '.nii' Fiji brings up the Bio-Formats Import Options dialog box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants