Issues with @animal_warper

AFNI version info (afni -ver): Version AFNI_24.0.13 'Caracalla'
Hello there,
I have rat images that I'm trying to warp using @animal_warper. I'm using the following command:

@animal_warper -input Rat_T2_map.nii -base wax_rat_atlas_v2.nii.gz

I've downloaded the Waxholm atlas from AFNI's website. However, the result is quite big (10 GB!) and the QC shows there's something wrong. Here are the images I have in there:




I think the problem is about the direction of the images, but I couldn't figure out exactly what it is.

Howdy-

Looking at the init_qc_00.input+base image (thanks for including that), it looks like the initial dataset-template overlap is quite poor. From the slice number in the axial image, it looks like the coordinates of your input rat data are veeeeeeery far away from having a coordinate origin (x,y,z)=(0,0,0) located in the vicinity of the center of the rat's brain.

To set the coordinates better, please try copying the dataset and resetting the coordinate origin to the center of mass of the dataset (the preliminary copying is necessary because the 3dCM command will overwrite the header of the input dataset):

3dcopy DATA_IN DATA_OUT
3dCM -set 0 0 0 DATA_OUT

--pt

Thank you so much,
I've done what's suggested but I'm still facing problems. Here are the QC images I got now:



Also, there's a part in @animal_warper where optimization starts, the terminal is crashing whenever it comes to that step for some reason.

Another thing is that although I'm adding the lines below to my .afnirc file and then saving it, when I open the atlas itself and try to use the Whereami function, it doesn't work.

The lines I'm adding:
AFNI_WHEREAMI_DEC_PLACES = 3
AFNI_SUPP_ATLAS_DIR = (atlas directory)
AFNI_TEMPLATE_SPACE_LIST = waxholm_rat

But when I open AFNI and select the atlas as the underlay:

I know there are many things I could be doing wrong, but what can I look at?
Thank you,
Kindest regards.

P.S. I referred to this post to use the atlas

Hi-

Hmm, I'm confused with init_qc_00 still.

What is the output of:
3dinfo -n4 -ad3 -extents -obliquity DSET_ANAT
?

And also, just so I can see the underlay itself more clearly, what do these images of the input anatomical look like?

@chauffeur_afni  \
    -montx 5 -monty 3 \
    -ulay DSET_ANAT \
    -prefix img_anat_00

--pt

The output of 3dinfo -n4 -ad3 -extents -obliquity T2W.nii is:

** ERROR: Option -extents unknown
   Here's hoping these excerpts from '3dinfo -help' enlighten:
        '-extent: The spatial extent of the dataset along R, L, A, P, I and S'
        '-Rextent: Extent along R'
        '-Lextent: Extent along L'

Running the @chauffeur_afni produces these images:



Thanks for sending that.

Re. the 3dinfo command, I mistyped one option, and it should be:
3dinfo -n4 -ad3 -extent -obliquity DSET_ANAT
Could you please send that output?

Thanks for sending the images, that shows one initial issue: the rat data is still in "sphinx" position, so what is called "coronal" in the header is not really a coronal view---it is the axial view. You will need to correct the orientation of the dataset before starting to use @animal_warper, etc. Do you have a script that you normally use to do this? The tricky part is making sure that "left is left" in the end---making a mistake about reorienting other directions is easily visually verifiable, but left-right symmetry makes it difficult/impossible to just visually verify the left-right correctness. Do you use vitamin E tablets or some other marker, or some other way to know definitively how the data should be reoriented?

--pt

This is the output now:
238 256 24 1 0.134500 0.125000 0.800003 -16.177439 15.699060 -17.982870 13.892130 -9.215508 9.184564 0.000

I don't have any script to do that but maybe I can further look into it. To make sure how the reorientation should be, I think I need to contact the imaging center, I'm not sure what they use for that.

Thank you so much
--Bilal

Hi, Bilal-

Thanks for those numbers, those look reasonable.

To help with trying to desphinxify the data, here is a draft script, called do_10_desphinxify.tcsh. NB: you can likely visually verify that it does a reasonable reorientation of the dataset for all planes except distinguishing left vs right. For that, you need something to break the left-right symmetry in the dataset (or in a reference dataset) in a known way, like using a vitamin E table. If you think this current script gets left-right incorrect, then you can alter the variable ori_mid to be LIP instead of RIP (or any other fix that works for your data).

--pt

the script: to be run with 1 command line argument, the name of the file to be desphinxified, like tcsh do_10_desphinxify.tcsh DSET_INPUT.

#!/bin/tcsh

# A simple script that *might* be useful for desphinxifying
# datasets. That is, when datasets are acquired in "sphinx" position,
# this will try to reorient them to match with axial/coronal/sagittal
# definitions standard to human neuroimaging.  
# 
# NB: there is an inherent difficulty in visually verifying left-right
# correctness, so users should do something to verify that, like with
# a vitamin E tablet in the acquisition field or something.

# auth: PA Taylor (SSCC, NIMH, NIH, USA)
# ver : 1.0  [2024-03-27]
# -------------------------------------------------------------------------

# provide input file via command line
set dset_in  = $1

# intermediate/final values derived from input dset
set inori    = `3dinfo -orient       "${dset_in}"`
set inpre    = `3dinfo -prefix_noext "${dset_in}"`
set inobl    = `3dinfo -is_oblique   "${dset_in}"`

# output dir+fname (just derived from input here)
set odir     = `dirnaname "${dset_in}"`
set dset_out = "${odir}/${inpre}_reorient.nii"

# the mid-processing orientation that actually rotates the brain in
# the dset. NB: this could also be LIP in some cases, **user must verify**.
set ori_mid  = RIP

# -------------------------------------------------------------------------

# default file for starting processing
set dset_00 = "${dset_in}"

# recenter around origin, if obliquity exists (3dresample would purge
# obliquity anyways)
if ( ${inobl} ) then
    echo "++ deoblique input around origin (no resampling)"
    adjunct_deob_around_origin                       \
        -input   "${dset_in}"                        \
        -prefix  __tmp_00.nii

    set dset_00 = __tmp_00.nii
endif

# resample input to have RAI orientation (will lose obliquity info)
3dresample -orient RAI -prefix __tmp_01.nii -input "${dset_00}"

# refit the tmp dset to effectively rotate.  
3drefit -orient ${ori_mid}  __tmp_01.nii

# resample tmp to have its original orientation in final output
3dresample -orient ${inori} -prefix "${dset_out}" -input __tmp_01.nii

# clean up
\rm __tmp_??.nii
1 Like