AFNI Message Board

Dear AFNI users-

We are very pleased to announce that the new AFNI Message Board framework is up! Please join us at:

https://discuss.afni.nimh.nih.gov

Existing user accounts have been migrated, so returning users can login by requesting a password reset. New users can create accounts, as well, through a standard account creation process. Please note that these setup emails might initially go to spam folders (esp. for NIH users!), so please check those locations in the beginning.

The current Message Board discussion threads have been migrated to the new framework. The current Message Board will remain visible, but read-only, for a little while.

Sincerely, AFNI HQ

History of AFNI updates  

|
December 08, 2020 11:39AM
Dear AFNI experts,

I am trying to implement @SSwarper into my pre-processing and whilst the defaults (@SSwarper -input ${T1 file} -subid ${subject} -odir ${out_dir} -base ${template}) worked well for most subjects, some subjects had clippings in axial inferior slices. To combat this, I have updated AFNI (now running Precompiled binary linux_ubuntu_16_64: Nov 12 2020 (Version AFNI_20.3.02 'Vespasian')) and consulted the message board where I found suggestions that the lack of alignment between the anatomical scan and the template image could be the reason for clippings (see this post). Hence, I have changed my pipeline to (a) run @Align_centers to align the template and scan before running @SSwarper and (b) add settings (-giant_move -SSopt '-push_to_edge') for the skull stripping (see code below).

#!/bin/bash

# define path
DIR="/storage/shared/research/cinn/2018/MAGMOT"

# change directory to BIDS folder
BIDS_dir="$DIR"/MAGMOT_BIDS
# change directory to the raw NIFI files
cd $BIDS_dir

subjects=($(ls -d sub*))
subjects=(sub-control003)

# define derivatives directory
deriv_dir="$DIR"/derivatives

# define which template to use and where to find them
template=MNI152_2009_template_SSW.nii.gz
template_path=`@FindAfniDsetPath $template`

# for each subject in the subjects array
for subject in "${subjects[@]}"; do

    echo "###################################################################################"	
    echo "@SSwarper for subject $subject"
    echo "###################################################################################"	

	# create output folder
	out_root=$deriv_dir/afniproc
	out_dir=$out_root/$subject/SSwarper
	mkdir $out_dir

	# define BIDS anat folder
	anat_dir=$DIR/MAGMOT_BIDS/"${subject}"/anat
    anat="$subject"_rec-NORM_T1w.nii.gz
    prefix="$subject"_shft.nii.gz
    cd $anat_dir

    # copy original anatomical scan
    3dcopy $anat $out_dir/$anat

    cd $out_dir

    # align centers
    @Align_Centers  \
        -cm \
        -prefix $prefix     \
        -dset $anat \
        -base $template_path/$template

	# specify SSwarper
	@SSwarper -input $prefix                             \
		-subid $subject							\
		-odir $out_dir							\
		-base $template_path/$template	\
		-giant_move -SSopt '-push_to_edge'

done

Although the adaptations have improved the output of @SSwarper significantly (compared to default ran on an older version), it is still not as good as the output of most default subjects and some cortex is still clipped (see attachment). When checking the file init_qc_00_overlap_usrc_obase.jpg I noticed that even though the output of @Align_centers is used as input for @SSwarper, the alignment is still poor. I have tried to play with the alignments a bit to improve the results (e.g. by running 3dMC before running @Align_centers; see code below), but the result still does not seem satisfying (see attachment).

#!/bin/bash

# define path
DIR="/storage/shared/research/cinn/2018/MAGMOT"

# change directory to BIDS folder
BIDS_dir="$DIR"/MAGMOT_BIDS
# change directory to the raw NIFI files
cd $BIDS_dir

# define subjects based on folder names in the BIDS directory
subjects=($(ls -d sub*))
subjects=(sub-control003)

# define derivatives directory
deriv_dir="$DIR"/derivatives

# define which template to use and where to find them
template=MNI152_2009_template_SSW.nii.gz
template_path=`@FindAfniDsetPath $template`

# for each subject in the subjects array
for subject in "${subjects[@]}"; do

  # create output folder
	out_root=$deriv_dir/afniproc
	out_dir=$out_root/$subject/align_centers
	mkdir $out_dir

	# define BIDS anat folder
	anat_dir=$DIR/MAGMOT_BIDS/"${subject}"/anat
    anat="$subject"_rec-NORM_T1w.nii.gz
    anat_rf="$subject"_refit.nii.gz
	cd $anat_dir

	# define prefix
    prefix_shft="$subject"_shft.nii.gz
    prefix_shft_rf="$subject"_shft_refit.nii.gz	

	prefix_3dCM="$subject"_3dCM.nii.gz
	prefix_3dCM_rf="$subject"_3dCM_refit.nii.gz
	prefix_3dCM_shft="$subject"_3dCM_shft.nii.gz
	prefix_3dCM_shft_rf="$subject"_3dCM_shft_refit.nii.gz

    # copy original anatomical scan
    3dcopy $anat $out_dir/$anat

	# go to output directory
    cd $out_dir

	# change center of mass
	3dcopy $anat $prefix_3dCM
	3dCM -automask -set 0 0 0 $prefix_3dCM

    # align centers between anatomical and template
    @Align_Centers \
        -cm \
        -prefix $prefix_shft \
        -dset $anat \
        -base $template_path/$template

    # align centers between anatomical and template after changing center of mask of anatomical
    @Align_Centers \
        -cm \
        -prefix $prefix_3dCM_shft \
        -dset $prefix_3dCM \
        -base $template_path/$template
	

	# refit to MNI for visualisation purposes: first copy files, then refit
	3dcopy $anat $anat_rf	
	3dcopy $prefix_shft $prefix_shft_rf
	3dcopy $prefix_3dCM $prefix_3dCM_rf
	3dcopy $prefix_3dCM_shft $prefix_3dCM_shft_rf

	3drefit -space MNI $anat_rf
	3drefit -space MNI $prefix_shft_rf
	3drefit -space MNI $prefix_3dCM_rf
	3drefit -space MNI $prefix_3dCM_shft_rf

	# copy template into directory for visualisation purposes
	3dcopy $template_path/$template $template
		
done

I have noticed that even after running 3dCM the center of mass is still not close to the ACPC line (though closer than before) and also that it seems as if the center of mass moves back to its original position if I run 3dCM + @Align_centers. Is there any way how I can improve the alignment between my anatomical scan and the MNI template further to improve the skull stripping performed by @SSwarper?

Also, because this has been discussed previously, I have added the obliquity information of the original anatomical image and the output of @Align_centers.
3dWarp -disp_obl_xform_only -deoblique $anat
++ 3dWarp: AFNI version=AFNI_20.3.02 (Nov 12 2020) [64-bit]
++ Authored by: RW Cox
# mat44 Obliquity Transformation ::
0.998696 0.015065 -0.048780 -5.739861
-0.026233 0.971115 -0.237165 -13.290672
0.043798 0.238135 0.970244 -36.265778
3dWarp -disp_obl_xform_only -deoblique $prefix_shft
++ 3dWarp: AFNI version=AFNI_20.3.02 (Nov 12 2020) [64-bit]
++ Authored by: RW Cox
# mat44 Obliquity Transformation ::
1.000000 0.000000 0.000000 0.000000
0.000000 1.000000 0.000000 0.000000
0.000000 0.000000 1.000000 0.000023

Any pointers on how to improve the alignment between anatomical and MNI would be really helpful!

Many thanks in advance,
Stef
Attachments:
open | download - Screenshot 2020-12-08 at 16.45.21.png (733.8 KB)
open | download - Screenshot 2020-12-08 at 16.30.31.png (501.7 KB)
Subject Author Posted

Problems with @Align_centers Attachments

s.meliss December 08, 2020 11:39AM

Re: Problems with @Align_centers

ptaylor December 08, 2020 01:44PM

Re: Problems with @Align_centers

s.meliss December 14, 2020 10:32AM

Re: Problems with @Align_centers

s.meliss December 16, 2020 12:22PM