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

NIFTI_XFORM_UNKNOWN issue #75

Closed
jeffduda opened this issue Mar 19, 2019 · 4 comments
Closed

NIFTI_XFORM_UNKNOWN issue #75

jeffduda opened this issue Mar 19, 2019 · 4 comments

Comments

@jeffduda
Copy link
Contributor

jeffduda commented Mar 19, 2019

Recently ran across an odd issue when trying to deal some old ANALYZE images. If you run PrintHeader on the original image it reports:
qform_code_name = NIFTI_XFORM_UNKNOWN

If I read this file into ANTsR, then immediately write it back out as NIFTI, the resulting file also has:
qform_code_name = NIFTI_XFORM_UNKNOWN

If I read it in, multiply it by 1 or antsImageClone() it, and write it to NIFTI, you get the expected: qform_code_name = NIFTI_XFORM_SCANNER_ANAT

One consequence of this, is that if you read in the file, change the direction to something valid, and try to write it out as NIFTI, your output still has an identity matrix for the direction, but no errors or warnings were thrown. See below data links and code.

fa.hdr - https://drive.google.com/file/d/1e1LNfxyAEJBx2SOrZmm6nasd5D6cUF5N/view?usp=sharing
fa.img - https://drive.google.com/file/d/1wMTrdgadIjihFfMzjyHJlPGtBN5YlO8v/view?usp=sharing

fa = antsImageRead("fa.hdr")
d = antsGetDirection(fa)
d[2,2] = -1
antsSetDirection(fa, d)
antsImageWrite(fa, "faFixed.nii.gz")

This output will still have the wrong direction info. If you print(fa) before writing it, the direction appears to have been changed successfully. If you add fa = fa*1 as the second line, then the output is as expected. It's weird.

@cookpa
Copy link
Member

cookpa commented Mar 26, 2019

Possibly related? Sounds like a similar issue of changes not being permanent due to pipeline connections

https://itk.org/pipermail/community/2014-July/002858.html

@jeffduda
Copy link
Contributor Author

I tried calling itkImage->DisconnectPipeline() before returning the image from antsImageRead(), also tried to set ReleaseDataFlagOn() on the reader, but neither approach fixed this issue.

@jeffduda
Copy link
Contributor Author

The ChangeImageInformationFilter would likely work, but would break the interface for backwards compatibility since it would require:
img = antsSetSpacing(img, spacing)

@jeffduda
Copy link
Contributor Author

Solution is to set SetUseInputMetaDataDictionary(false) on the image file writer. However, not calling DisconnectPipeline means pointers to the file readers, etc are being kept alive which could lead to memory issues. Not a bad idea to add a lot of calls to DisconnectPipeline throughout.

@stnava stnava closed this as completed Oct 16, 2024
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

3 participants