bad DTI results

Dear Afni forum,

I have generated a script to run fatcat (steps as described on 7. FATCAT — AFNI, SUMA and FATCAT: v23.1.06). I have run the scripts on about 13 subjects, with only one set of “good” results.
This is my processing pipeline (i apologize for the amount of txt, in this script “i” refers to the subject ID, and this is all in for loops. I have 3 different scripts doing this):
#----- Converting DWIs to nii files -------------------------------------
fat_proc_convert_dcm_dwis
-indir “$path_Base_ss/$dti_folder”
-prefix “path_Base_ss/dti_raw/{i}_dti”
#read -n 1 -p “hit enter to continue…”
echo “-------------------------------STEP ONE COMPLETE-----------------------------------”
#----- Convert anatomy to nii
fat_proc_convert_dcm_anat
-indir $t1_path
-prefix $path_Base_ss/t1w/{$i}t1
echo “-------------------------------STEP TWO COMPLETE-----------------------------------”

#------- axialization with reference to icbm152 t1w image ----------------------
ref_t1w="$home_dir/mni_icbm152_nlin_sym_09c/mni_icbm152_t1_tal_nlin_sym_09c.nii"
ref_t1w_wt="$home_dir/mni_icbm152_nlin_sym_09c/mni_icbm152_wm_tal_nlin_sym_09c.nii"

fat_proc_axialize_anat                   \
-inset   "$path_Base_ss/t1w/${i}_t1_.nii.gz"     \
-prefix  "$path_Base_ss/t1w/${i}_t1_axial" \
-mode_t1w                                \
-refset          $ref_t1w                \
-extra_al_wtmask $ref_t1w_wt             \
-out_match_ref                           \
-extra_al_opts "-newgrid 1.0"            \
-pre_center_mass                         \
-remove_inf_sli 20

echo "Current Subject is :$i"
# or do whatever with individual element of the array
# for I/O, "basic" (= DICOM) and "proc" (= NIFTI) directories
path_Base_ss="$home_dir/$i"
echo "Subject path is : $path_Base_ss"
t1_axial_loc="$path_Base_ss/t1w/${i}_t1_axial.nii.gz"

# ID of individual subj from "tail" of path, above
ss_id="fs"

# FS function
recon-all                                 \
	-all                                      \
	-sd       $path_Base_ss                   \
	-subjid   fs                              \
	-i        $t1_axial_loc

# AFNI-SUMA function: convert FS output
@SUMA_Make_Spec_FS                        \
	-NIFTI                                    \
	-fspath $path_Base_ss/fs                   \
	-sid    $ss_id

echo "--------------FILTER DTI IMAGES--------------------------"
# filter from both AP and PA dwi sets, both vols and b-matrices
fat_proc_filter_dwis                                 \
    -in_dwi        $path_P_ss/${i}_dti.nii.gz       \
    -in_col_matT   $path_P_ss/${i}_dti_matT.dat     \
    -select        `cat $path_P_ss/${i}_dti_sel_ap_goods.txt`     \
    -prefix        $path_P_ss/${i}_dti_filt

read -n 1 -p “hit enter to continue…”

echo "---------------- DIFFPREP STARTED ---------------------"

# make a directory to hold 'starter' data for DIFFPREP, as well
# as all the files it creates
odir=$path_P_ss/diffprep_starter
if test ! -d $odir; then
    mkdir $odir
fi

# uncompress the anatomical
gunzip $path_P_ss/${i}_dti_filt.nii.gz

# for DIFFPREP command line, need row-vec and row-bval format
1dDW_Grad_o_Mat++                                      \
    -in_col_matT      $path_P_ss/${i}_dti_matT.dat \
    -unit_mag_out                                      \
    -out_row_vec      $odir/${i}_dti_rvec.dat                \
    -out_row_bval_sep $odir/${i}_dti_bval.dat

read -n 1 -p “hit enter to continue…”

# the NIFTI file must be unzipped
3dcopy                                                 \
    $path_P_ss/${i}_dti_filt.nii                    \
    $odir/${i}_dti_filt.nii

# finally, the main command itself
DIFFPREP                                               \
    --dwi         $odir/${i}_dti_filt.nii                         \
    --bvecs       $odir/${i}_dti_rvec.dat                    \
    --bvals       $odir/${i}_dti_bval.dat                    \
    --structural  $home_dir/$i/t1w/${i}_t1_axial.nii.gz \
    --phase       vertical                             \
    --will_be_drbuddied  0                             \
    --reg_settings example_registration_settings.dmc

read -n 1 -p “hit enter to continue…”

# shortcut names for what will be our input (-> from TORT proc)
# and output (-> another dwi_* directory)
itort=$path_P_ss/diffprep_starter

# A) do autoflip check: not ideal to need this, but such is life
@GradFlipTest \
    -in_dwi       $itort/${i}_dti_filt_DMC.nii        \
    -in_col_matT  $itort/${i}_dti_filt_DMC.bmtxt      \
    -prefix       $itort/GradFlipTest_rec.txt

# get the 'recommended' flip; still should verify visually!!
my_flip=`cat $itort/GradFlipTest_rec.txt`

# B) DT+parameter estimates, with flip chosen from @GradFlipTest
fat_proc_dwi_to_dt \
    -in_dwi       $itort/${i}_dti_filt_DMC.nii                     \
    -in_col_matT  $itort/${i}_dti_filt_DMC.bmtxt                   \
    -in_struc_res $itort/${i}_dti_filt_DMC_structural.nii          \
    -in_ref_orig  $home_dir/$i//t1w/${i}_t1_axial.nii  \
    -prefix       $itort/${i}                             \
    -mask_from_struc                                    \

$my_flip

read -n 1 -p “hit enter to continue…”

fat_proc_decmap                                     \
    -in_fa       $itort/dt_FA.nii.gz     \
    -in_v1       $itort/dt_V1.nii.gz     \
    -mask        $itort/${i}_mask.nii.gz  \
    -prefix      $itort/${i}_decmap

read -n 1 -p “hit enter to continue…”

fat_proc_map_to_dti                                                   \
    -source          $home_dir/$i/fs/SUMA/brain.nii                   \
    -base            $itort/${i}_dwi.nii.gz'[0]'                      \
    -prefix          $itort/indt       			              \
    -followers_NN    $home_dir/$i/fs/SUMA/aparc*_REN_*.nii.gz         \
    -followers_surf  $home_dir/$i/fs/SUMA/std.141.*.gii               \
    -followers_ndset $home_dir/$i/fs/SUMA/std.141.*.niml.dset         \
    -followers_spec  $home_dir/$i/fs/SUMA/std.141.*.spec  

read -n 1 -p “hit enter to continue…”

3dmask_tool                                  \
    -dilate_inputs -2                        \
    -inputs $itort/${i}_mask.nii.gz      \
    -prefix $itort/${i}_mask_ERODE.nii.gz

# basic whole-brain, mini-prob tracking in it.
3dTrackID                                    \
    -mode MINIP                              \
    -mini_num 10                              \
    -mask $itort/${i}_mask_ERODE.nii.gz             \
    -netrois $itort/${i}_mask_ERODE.nii.gz      \
    -dti_in $itort/dt                           \
    -prefix $itort/TTT                              \
    -uncert $itort/dt_UNC.nii.gz                \
    -logic AND                                \
    -alg_Nseed_X 1                           \
    -alg_Nseed_Y 1                           \
    -alg_Nseed_Z 1                           

read -n 1 -p “hit enter to continue…”

I have messed around with some of the varaibles, however I do not seem to get a good results (the mini_num number of sli to remove before axialization). the same script has run on all subjects, it has run very well on only one subject ( i have attached png images from the good run and one of the bad runs). Any help is appreciated, thank you!

Something looks a bit awry, indeed.

Just glancing through the code, I wonder about why the $my_flip variable is commented out when converting tensors here:


# B) DT+parameter estimates, with flip chosen from @GradFlipTest
fat_proc_dwi_to_dt \
-in_dwi $itort/${i}_dti_filt_DMC.nii \
-in_col_matT $itort/${i}_dti_filt_DMC.bmtxt \
-in_struc_res $itort/${i}_dti_filt_DMC_structural.nii \
-in_ref_orig $home_dir/$i//t1w/${i}_t1_axial.nii \
-prefix $itort/${i} \
-mask_from_struc \
# $my_flip

Also, there are QC images generated at each fat_proc* step (and even TORTOISE should be calling @chauffeur_afni to generate images). Where does the badness start creeping in, as you look through these processing-chronologically? See ugliness at the end is a reminder to doublecheck steps starting from the very beginning.

–pt

Hey ptaylor thanks for the reply,

I am going through the qc images generated, i have found this picture, which i can tell does not look right). the qc02_ref_b0 also is different; on the correct run it seems to be slanted (I don’t know if this matters). The qc03_MD_FA_thr0 ( not attached) also looks bad for the bad runs

My guess is that if you look at the accompanying sagittal image, the “slantedness” at the bottom of these lower axial slices is really the limited extent of the FOV of the overlay volume.

–pt

You mean this image ? But this is from the good run. On the bad run, the “purple” plane on the image is not slanted.

I attached the MD_FA_thr0 images, because these seem bad too. I think in this step is where things are getting messed up.

That looks good to me, based on the quality of alignment of the olay (DWI b=0?) and ulay (anatomical?).

There looks like there is a large oblique angle between the FOV of the acquisitions-- that is why one FOV is so heavily rotated with respect to the other (i.e., the edges of the bounding boxes of the acquisitions are not close to parallel). That is just a question of how the data were acquired, not a function of the processing.

–pt

Here, the “abi003*png” file looks good to me-- the FA>0.2 map looks like a WM map.

The “abi001*png” map looks a bit off-- not very specific or limited to WM.

These maps are derived from tensor fitting. Again, I woudl encourage you to look at these from the beginning to check for problems (motion, artifact in the acquired DWIs? Something else odd?) and then see how things progress, rather than start at the end and work backwards. What do your original DWI maps look like?

–pt