T2 SPACE Dark Fluid Anatomical Image and Nonlinear Warping to MNI Template

AFNI version info (afni -ver): 24.0.03

@SSwarper v2.6

Hello all,

I have EPI and T2-weighted anatomical images. I am trying to do nonlinear warping of anatomical image to MNI template. However, T2 image (actually, T2 SPACE Dark Fluid, which means suppressed fluids) gave problematic results. Like that:

And, here is my code I used

#!/bin/tcsh 
 
### Define base directory and static filenames 
set topdir        = $cwd 
set subj          = "fibro_single" 
set anat_file     = "fibro_t2.nii.gz" 
set template_file = "MNI152_2009_template_SSW.nii.gz" 
 
echo "Warping subject: $subj" 
 
# Create subject-specific directory structure 
mkdir -p $topdir/$subj/anat_orig 
mkdir -p $topdir/$subj/anat_warped 
mkdir -p $topdir/$subj/anat_warped/snapshots 
 
# Go to anat_orig directory 
cd $topdir/$subj/anat_orig 
 
# Create temp directory and copy subject T2-weighted image 
mkdir -p temp_$subj 
cp $topdir/$anat_file temp_$subj 
cd temp_$subj 
 
# Run AFNI @SSwarper 
@SSwarper \ 
    -input $anat_file \ 
    -subid $subj \ 
    -base $topdir/$template_file 
 
# Compress output datasets (turns .nii into .nii.gz) 
gzip -1v *.nii 
 
# Move results to subject's anat_warped directory 
\mv -f anatSS.${subj}.nii.gz anatQQ.${subj}.nii.gz \ 
       anatQQ.${subj}.aff12.1D anatQQ.${subj}_WARP.nii.gz \ 
       $topdir/$subj/anat_warped 
 
# Move snapshots for visual QC 
\mv -f *.jpg $topdir/$subj/anat_warped/snapshots 
 
# Clean up temp directory 
cd .. 
\rm -rf temp_$subj 
 
echo "Finished processing $subj" 
exit 0

How can I overcome this problem? Unfortunately, I do not have T1 images and there is no possibility to obtain them. Thank you for your help in advance.

Howdy-

Since that is a T2w dataset being input, and the template file is a T1w dataset, you should probably use a different cost function to align across the opposite contrasts. (The default cost functions assume you are inputting a dset with similar tissue contrast to the template.)

I will also note that there is "sswarper2", which you could use, which is a more modern/updated version of the original @SSwarper. It has mostly the same options.

Assuming you are going for sswarper2, could you try adding these options:

-cost_aff lpc     \
-cost_nl_init lpc   \
-cost_nl_final lpc   \

... and see how it goes? If the initial affine alignment fails, you could try changing the first opt to:

-cost_aff lpc+ZZ

... which is a more stable version of the first one, but it runs a fair bit slower. NB: if you are going to stick with @SSwarper, you can do the same kind of thing, but there is no separate -cost_aff .. opt, so you would only ues the other two.

Note that sswarper2 creates automatic QC images of its results, too, so you can check them quickly and see results. Those files are called QC*. There is also a directory called ssw_align_hist.sub-000 that contains a running set of intermediate images, to see where things might be going awry.

--pt

Also, your version of AFNI is 2 years old, so I would probably update it, which could likely be done with:

@update.afni.binaries -d

It might not be so necessary for this command, but it might help with other aspects of processing (newer opts, newer programs, more QC outputs).

--pt

Hello Paul, thank you for your help.

I tried with

-cost_aff lpc \
-cost_nl_init lpc \
-cost_nl_final lpc

and

-cost_aff lpc+ZZ \
-cost_nl_init lpc \
-cost_nl_final lpc

However, neither result is usable.

#!/bin/tcsh

### Define base directory and static filenames
set topdir        = $cwd
set subj          = "fibro_single"
set anat_file     = "fibro_t2.nii.gz"
set template_file = "MNI152_2009_template_SSW.nii.gz"

echo "Warping subject: $subj"

# Create subject-specific directory structure
mkdir -p $topdir/$subj/anat_orig
mkdir -p $topdir/$subj/anat_warped
mkdir -p $topdir/$subj/anat_warped/snapshots

# Go to anat_orig directory
cd $topdir/$subj/anat_orig

# Create temp directory and copy subject T2-weighted image
mkdir -p temp_$subj
cp $topdir/$anat_file temp_$subj
cd temp_$subj

# Run AFNI sswarper2
sswarper2 \
    -input $anat_file \
    -subid $subj \
    -base $topdir/$template_file \
    -cost_aff nmi \
    -cost_nl_init nmi \
    -cost_nl_final nmi

# Compress output datasets (turns .nii into .nii.gz)
gzip -1v *.nii

# Move results to subject's anat_warped directory
\mv -f anatSS.${subj}.nii.gz anatQQ.${subj}.nii.gz \
       anatQQ.${subj}.aff12.1D anatQQ.${subj}_WARP.nii.gz \
       $topdir/$subj/anat_warped

# Move snapshots for visual QC
\mv -f *.jpg $topdir/$subj/anat_warped/snapshots

# Clean up temp directory
cd ..
\rm -rf temp_$subj

echo "Finished processing $subj"
exit 0

I am trying with

-cost_aff nmi \
-cost_nl_init nmi \
-cost_nl_final nmi

now. But it is too slow, I couldn't see the results yet. Do you have another suggestion for this problem? Thank you again for your time and help.

Howdy-

Are you able to share any example datasets? That would help me run it and track the process, esp. through the QC images that are output, and see if I can offer a simpler way forward.

--pt