-
-
Notifications
You must be signed in to change notification settings - Fork 381
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
Output sform matrix does not match that of the target image. #1804
Comments
Have seen this? |
Sorry - After posting this, I did find the explanation of how qform and sform transformations are handled here: https://github.com/ANTsX/ANTs/wiki/How-does-ANTs-handle-qform-and-sform-in-NIFTI-1-images%3F This should not be an issue if I update to ANTs >= 2.3.5, correct? |
Hi, This is handled upstream of ANTs in ITK. There has been an ongoing debate about how best to handle NIFTI I/O. Because of ITK's limitations on the transforms it can use (rotation + offset + voxel scaling), there are a some compromises and tradeoffs that can affect some use cases. I went through the current code and made a flow chart of the heuristic InsightSoftwareConsortium/ITK#4839 (comment) This shows what is done on read. For writing images, the internal transform (rotation + offset + voxel scaling), however defined, is written to both the qform and sform, and both are set to If you can post the headers of your fixed and moving images, I can probably tell how modern ANTs would handle them. |
And thanks for the speedy reply! |
Here is the header for the target image: endian little |
And from the source: endian little |
Thanks, this looks like what ANTs 2.1 would produce, qform_code was set to 2, sform_code set to 1. The qform is always rigid so it was used on read, and then the sform would be set to the same transform. Later versions set qform_code=1 and sform_code=0, to make clear that qform was being used. However, this made precision errors worse, so the switch was made to set qform_code=1 and sform_code=1, and use the sform where possible. Looking at these, I think if you use a recent ANTs, the output should match the target header. |
Perfect- many thanks! |
Operating system and version
Cent OS 7
CPU architecture
x86_64 (PC, Intel Mac, other Intel/AMD)
ANTs code version
ANTs Version: 2.1.0.post783-g64645 Compiled: Apr 25 2017 23:53:19
ANTs installation type
Compiled from source
Summary of the problem
I recently noticed that the sform matrix in the output NIFTI from antsRegistrationSyN.sh sometimes does not match that of the target volume, which creates some confusing discrepancies in the alignment of the images. We found this after being confounded by images that align well in voxel space but not upon being viewed in fsleyes, freeview, leadDBS, etc. I eventually traced the problem to cases in which the q_offset values in the target NIFTI are discrepant with the translation component of the sform matrix. ANTs evidently substitutes the sform matrix from the target image with one derived from qform values. I'd urge you you to preserve all the transformations from the target image as they are, so that images align regardless of the space in which a given viewer renders them.
Commands to reproduce the problem.
antsRegistrationSyN.sh -d 3 -n ${nthreads} -t b -o ${prefix} -f ${T1ind} -m ${T1tmp} 2>&1 > ${logfile}
Output of the command with verbose output.
N/A
Data to reproduce the problem
N/A
The text was updated successfully, but these errors were encountered: