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

ANTs and SPM compatibility #1726

Open
lisajeschke opened this issue Apr 18, 2024 · 3 comments
Open

ANTs and SPM compatibility #1726

lisajeschke opened this issue Apr 18, 2024 · 3 comments
Labels
help needed Issues that require feedback or expertise from the community. Discussion and PRs welcome

Comments

@lisajeschke
Copy link

I work with fmri BOLD data of a brain slab and currently encounter problems when I calculate GLMs in SPM after I have warped them into mni space using ANTs.

The warping works fine and the output looks anatomically and qualitatively correct. However, in contrast to native space images, my warped images cause SPM to display my results very frizzy/noisy, such as if my significant clusters would be very small and frizzy. I have attached two example images of my "normal" (native space, 1st image) output and the "distorted" issue (mni space with ants; 2nd image). The resolution and smoothing kernel are the same in both spaces.

Has anyone dealt with that problem before? Is it just a displaying problem?

Is there some header issue or something else that would need to be changed before I use SPM on the warped data?

nativespace
mnispace

@gdevenyi
Copy link
Contributor

Please take a look at https://github.com/ANTsX/ANTs/wiki/How-does-ANTs-handle-qform-and-sform-in-NIFTI-1-images%3F which explains how ITK/ANTs handles the coordinate systems in NIFTI imaging data.

I cannot provide a reference for how SPM handles things, but I suspect the answer is "differently". Either SPM will have to be adjusted to read things by the same conventions, or you will have to do post processing on the ANTs images to provide metadata in a convention SPM can use.

@cookpa
Copy link
Member

cookpa commented Apr 19, 2024

I recommend never using statistical images to evaluate image processing quality. Look at the actual data in the template space.

There are two main issues I'm aware of:

  1. SPM does use sform_code=4, with the sform describing an affine transform to MNI space. ITK and therefore ANTs does not support this (header transforms must be rotation + voxel scaling + offset), but I think this is more of a problem for importing SPM images into ITK frameworks, whereas here we want to import ITK/ANTs images to SPM.

SPM might be OK with an image that is properly resampled into MNI space, with the sform indicating an identity transform, but

  1. There are different MNI spaces, and different references images at resolutions in each space. You need to check your MNI reference image aligns with the SPM one. The resolution might also be important, it might need the images resampled into the 2mm version of whatever MNI space it's using.

This man page might be helpful to figure out what the reference space is

https://github.com/spm/spm12/blob/03ac9473cad402407b6472228377c0167fdc54b8/spm_templates.man#L499

@cookpa cookpa added the help needed Issues that require feedback or expertise from the community. Discussion and PRs welcome label Apr 21, 2024
@cookpa
Copy link
Member

cookpa commented Apr 21, 2024

BTW, ITK does not correctly write the temporal units of NIFTI images (the xyzt_units field), and has some issues with scaling of nonstandard units. I'm working on a fix InsightSoftwareConsortium/ITK#4595.

I don't know if this has anything to do with this issue.

@lisajeschke, when you say

The warping works fine and the output looks anatomically and qualitatively correct.

Does it look correct with an ITK viewer or in SPM? What is the MNI template image for this visualization?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help needed Issues that require feedback or expertise from the community. Discussion and PRs welcome
Projects
None yet
Development

No branches or pull requests

3 participants