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

Are there 'better' parameters for using antsRegistration for EPI -> T2 on mice than the default? #1588

Open
chainhomelow opened this issue Aug 16, 2023 · 9 comments

Comments

@chainhomelow
Copy link

Describe the problem
I am doing preprocessing on mice EPIs for the first time (its not going great). I have been using 'fslchpixdim' to make the voxels in the header of the EPI file to be multiplied by 10 to be a more 'human' resolution because the native EPI resolution is .156x.600x.156 and a lot of preprocessing tools I'm using will error or not work as expected with files of this native resolution. Changing the resolution of the EPIs to 1.563x6.000x1.563 seems to 'work' insofar that processing proceeds successfully until registration.
I am trying to register the mean EPI image (single 3D image) to a preprocessed T2 anatomical image. I have also changed the voxels in the header of my anatomical file from .078x.200x.078 to .781x2.00x.781 - so both the anatomical and EPI files had their voxel resolutions scaled the same. I originally used the following antsRegistration call. In this call, ${ANAT} is the 'human' sized, masked T2 and ${TS_ROI} is the 'human' sized masked EPI (both files are skullstripped/masked)

  # coregister to native anatomical ----------------------------------------------
   antsRegistration -v 1 \
    --dimensionality 3 --float --random-seed 13311800 \
    --collapse-output-transforms 1 \
    --use-histogram-matching 0 \
    --use-estimate-learning-rate-once 0 \
    --initial-moving-transform [${ANAT},${TS_ROI},1] \
    --output ${DIR_PREP}/xfm_ \
    --transform "Rigid[0.1]" \
      --metric Mattes[${ANAT},${TS_ROI},1,32,Regular,0.2] \
      --convergence [1200x1200x100,1e-6,5] \
      --smoothing-sigmas 2x1x0vox \
      --shrink-factors 4x2x1 
    --transform "Affine[0.25]" \
      --metric Mattes[${ANAT},${TS_ROI},1,32,Regular,0.2] \
      --convergence [1200x1200x100,1e-6,5] \
      --smoothing-sigmas 2x1x0vox \
      --shrink-factors 4x2x1 \
    --transform "SyN[0.2,3,0]" \
      --metric Mattes[${ANAT},${TS_ROI},1,32] \
      --convergence [1200x1200x100,1e-6,5] \
      --smoothing-sigmas 2x1x0vox \
      --shrink-factors 4x2x1

This kept erroring at the Syn step with some version of this error:

WARNING: In /Shared/pinc/sharedopt/apps/ants/Linux/x86_64/2.3.1/ITKv5-install/include/ITK-5.0/itkGaussianOperator.hxx, line 61
GaussianOperator (0x7fff1f376960): Kernel size has exceeded the specified maximum width of 6 and has been truncated to 7 elements. You can raise the maximum width using the SetMaximumKernelWidth method.

I got these parameters from someone who used to work here so I figured the parameters I was using here were not 'optimized' (or even good) for mice so I searched here and the closest I could find to my problem was issue #734
So I tried again with some parameters changed from (probably stupid) guesses I made off of reading that issue thread and I came up with this:

    # coregister to native anatomical ----------------------------------------------
  antsRegistration -v 1 \
    --dimensionality 3 --float --random-seed 13311800 \
    --collapse-output-transforms 1 \
    --use-histogram-matching 0 \
    --use-estimate-learning-rate-once 0 \
    --initial-moving-transform [${ANAT},${TS_ROI},1] \
    --output [${DIR_PREP}/xfm_ ,${DIR_PREP}/${PFX}_proc-mean_roi-brain_reg-intermodalSyn+native-noSmooth_bold.nii.gz ] \
    --transform "Rigid[0.1]" \
      --metric Mattes[${ANAT},${TS_ROI},1,32,Regular,0.3] \
      --convergence [1000x500x100,1e-6,15] \
      --smoothing-sigmas 0x0x0vox \
      --shrink-factors 2x1x1 \
    --transform "Affine[0.25]" \
      --metric Mattes[${ANAT},${TS_ROI},1,32,Regular,0.2] \
      --convergence [1000x500x100,1e-6,15] \
      --smoothing-sigmas 0x0x0vox \
      --shrink-factors 1x1x1 \
    --transform "SyN[0.2,1,1]" \
      --metric CC[${ANAT},${TS_ROI},1,2] \
      --convergence [500x300x100,1e-6,15] \
      --smoothing-sigmas 0x0x0vox \
      --shrink-factors 1x1x1

Mostly I changed a lot of the smoothing sigmas to 0 (guessed from the kernal error) but did change shrink factors and convergence values. But to be clear, I changed them to these things based off that thread, not based on any good understanding of how these options are affecting mice data.

Now, this code ran without erroring and the results are the best I've gotten with any registration so far but they are still just, okay.
Screenshot 2023-08-16 at 2 31 11 PM

Basically at this point I'm wondering if this is the best I'm going to get with this data or if there are just some glaring errors I'm making in this code somewhere.

To Reproduce
I'll upload the ${ANAT} and ${TS_ROI} file with this post but I don't expect anyone to fix this for me; more hopefully just some recommendations.
This is the $ANAT
sub-LS101_ses-20221214T100203_roi-brain_T2w.nii.gz
This is the $TS_ROI
sub-LS101_ses-20221214T100203_dir-fwd_proc-mean_roi-brain_bold.nii.gz

The raw EPIs are not the BEST quality and have gone through the following preprocessing steps:

  1. reorienting to match anatomical orientation
  2. fslchpixdim to change pixel dimensions in header by a factor of 10
  3. 4D Rician Denoising
  4. N4 Bias Correct
  5. Motion Correction
  6. Masking

System information (please complete the following information)
I am using my work's high performance computing environment to code and run this.
It's a SGE and I run this on an HPC cluster.

ANTs version information

  • ANTs code version: ANTs Version: 2.2.0
    Compiled: Jul 5 2018 15:12:12 (wow, is the age an issue?)
  • ANTs installation type: i honestly dont feel comfortable enough even guessing

Thanks all!

@gdevenyi
Copy link
Contributor

gdevenyi commented Aug 16, 2023

You may be interested in https://github.com/CoBrALab/RABIES which is a comprehensive preprocessing pipeline for rodent fRMI

preprint: https://www.biorxiv.org/content/10.1101/2022.08.20.504597v1

@ntustison
Copy link
Member

How many slices for each image?

@chainhomelow
Copy link
Author

@ntustison there are 128 slices I believe. header info provided to confirm.
Screenshot 2023-08-17 at 10 46 27 AM

@gdevenyi thanks for the link! I'll check out the preprint. I don't know that we have RABIES on our system but I'll certainly look at the docs

@ntustison
Copy link
Member

My guess is that, yes, you're dealing with an outdated build. I run the following and don't have any issues:

$ antsRegistrationSyNQuick.sh -d 3 -f sub-LS101_ses-20221214T100203_roi-brain_T2w.nii -m sub-LS101_ses-20221214T100203_dir-fwd_proc-mean_roi-brain_bold.nii -n 4 -o test

@chainhomelow
Copy link
Author

Hi all, sorry to resurrect this a million years later.
@ntustison you were indeed correct that my prior problem was the old ANTS build. I had been under the impression I was using AT LEAST a version from 2022 but we've gotten this changed to the most recent version. When we updated ANTS and ran the following command, it worked for about 60 mice.
antsRegistrationSyNQuick.sh -d 3 \ -f ${ANAT} -m ${TS_ROI} -n 4 \ -o ${DIR_PREP}/${PFX}_proc-mean_roi-brain_reg-intermodalSyn_bold

It failed for 10 mice and I've had a difficult time trying to fix it (hence the follow up). I've investigated the files that failed and I think most of them have the same problem which is a bad affine transform specifically.
Most of the failed mice look similar to this:
Screenshot 2023-11-07 at 12 21 03 PM
with the back and bottom blown out a little bit. The images are both anisotropic at this point if it matters. They are .781x2.000x.781

I've tested using antsRegistrationSyNQuick.sh with the -t r option and those files look pretty good. Using the -t a seemed to replicate the bad alignments pretty closely. I also tried skipping affine and using -t sr but that didn't give enough coverage of the brain (which I expected so, no big deal).

Basically I'm wondering if there's a way to 'fix' the bad affines? Would this be something I'd have to tweak specific parameters for using regular antsRegistration? Or maybe you might have expert eyes on it and see a totally different problem. I'm happy to provide more screenshots, code, or files if you need it.

Thanks all.

@ntustison
Copy link
Member

Screenshots are sometimes adequate but, in this case, you're going to need to post a problematic data set.

@stnava
Copy link
Member

stnava commented Nov 7, 2023

another issue that we once had - and may still have - is that negative intensities can blow up one of the initialization estimators. worth a check.

@chainhomelow
Copy link
Author

@ntustison - you got it. I'm attaching the files that created the above screenshot when run through the antsRegistrationSyNQuick.sh command as written above. In this situation the ${ANAT} is called sub-LS102_ses-20221214T113013_roi-brain_T2w.nii.gz and the ${TS_ROI} is the other one (ends in mean_roi-brain_bold.nii.gz.)
sub-LS102_ses-20221214T113013_roi-brain_T2w.nii.gz

sub-LS102_ses-20221214T113013_dir-fwd_proc-mean_roi-brain_bold.nii.gz

And to @stnava 's point - yeah these do have negatives in them. We do registration at sn early-ish step in the pipeline so we haven't done any normalization or anything yet.
let me know if i can provide anything else for you.

@ntustison
Copy link
Member

I ran the following:

$ antsRegistrationSyNQuick.sh -d 3 -f sub-LS102_ses-20221214T113013_roi-brain_T2w.nii -m sub-LS102_ses-20221214T113013_dir-fwd_proc-mean_roi-brain_bold.nii -n 4 -o test

and got something perfectly reasonable (attached as testWarped.nii.gz) considering the input images. I use ITK-SNAP to view the results so I can't tell if it corresponds with what your screenshot shows but you can check.

testWarped.nii.gz

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

4 participants