Chapter 21 Modified TBSS using ENGIMA
Non-FA Analysis

21.1 Job Script

On the remote computer create script.

vi ~/scripts/ACAP/ENIMGA-tbss-nonFA-job.sh

Copy and paste.

#!/bin/bash

#SBATCH --time=02:00:00   # walltime
#SBATCH --ntasks=1   # number of processor cores (i.e. tasks)
#SBATCH --nodes=1   # number of nodes
#SBATCH --mem-per-cpu=12G  # memory per CPU core

# LOAD ENVIRONMENTAL VARIABLES
username=`id -un`
module load lib/openblas/0.2.20-gnu
module load fsl/6.0.0
export ANTSPATH=/home/${username}/apps/ants/bin/
PATH=${ANTSPATH}:${PATH}

# INSERT CODE, AND RUN YOUR PROGRAMS HERE
ENIGMAtemplateDirectory=~/templates/ENIGMA
TBSS_DIR=/work/ashley.ware/data/ACAP/enigma/tbss/
DTIFIT_DIR=/work/ashley.ware/data/ACAP/enigma/dwiprep/

mkdir ${TBSS_DIR}/MD/
mkdir ${TBSS_DIR}/AD/
mkdir ${TBSS_DIR}/RD/

cd $TBSS_DIR

# COPY MD IMAGE
cp -v ${DTIFIT_DIR}/${1}/dti_MD.nii.gz ${TBSS_DIR}/MD/${1}_MD.nii.gz

# COPY AD IMAGE
cp -v ${DTIFIT_DIR}/${1}/dti_L1.nii.gz ${TBSS_DIR}/AD/${1}_AD.nii.gz

# CREATE RD IMAGE
fslmaths ${DTIFIT_DIR}/${1}/dti_L2.nii.gz \
-add ${DTIFIT_DIR}/${1}/dti_L3.nii.gz \
-div 2 \
${TBSS_DIR}/RD/${1}_RD.nii.gz
 
for DIFF in MD AD RD
do
  mkdir -p ${TBSS_DIR}/${DIFF}/origdata/
  mkdir -p ${TBSS_DIR}/${DIFF}-individ/${1}/${DIFF}/
  mkdir -p ${TBSS_DIR}/${DIFF}-individ/${1}/stats/
 
  fslmaths ${TBSS_DIR}/${DIFF}/${1}_${DIFF}.nii.gz \
  -mas ${TBSS_DIR}/FA/${1}_FA_FA_mask.nii.gz \
  ${TBSS_DIR}/${DIFF}-individ/${1}/${DIFF}/${1}_${DIFF}
 
  immv ${TBSS_DIR}/${DIFF}/${1} ${TBSS_DIR}/${DIFF}/origdata/
 
  applywarp \
  -i ${TBSS_DIR}/${DIFF}-individ/${1}/${DIFF}/${1}_${DIFF} \
  -o ${TBSS_DIR}/${DIFF}-individ/${1}/${DIFF}/${1}_${DIFF}_to_target \
  -r $FSLDIR/data/standard/FMRIB58_FA_1mm \
  -w ${TBSS_DIR}/FA/${1}_FA_FA_to_target_warp.nii.gz
  
  fslmaths \
  ${TBSS_DIR}/${DIFF}-individ/${1}/${DIFF}/${1}_${DIFF}_to_target \
  -mas ${ENIGMAtemplateDirectory}/ENIGMA_DTI_FA_mask.nii.gz \
  ${TBSS_DIR}/${DIFF}-individ/${1}/${DIFF}/${1}_masked_${DIFF}.nii.gz
  
  tbss_skeleton \
  -i ${ENIGMAtemplateDirectory}/ENIGMA_DTI_FA.nii.gz \
  -p 0.049 \
  ${ENIGMAtemplateDirectory}/ENIGMA_DTI_FA_skeleton_mask_dst.nii.gz \
  $FSLDIR/data/standard/LowerCingulum_1mm.nii.gz \
  ${TBSS_DIR}/FA-individ/${1}/FA/${1}_masked_FA.nii.gz  \
  ${TBSS_DIR}/${DIFF}-individ/${1}/stats/${1}_masked_${DIFF}skel -a \
  ${TBSS_DIR}/${DIFF}-individ/${1}/${DIFF}/${1}_masked_${DIFF}.nii.gz -s \
  ${ENIGMAtemplateDirectory}/ENIGMA_DTI_FA_skeleton_mask.nii.gz
done

21.2 Batch Script

Create script.

vi ~/scripts/ACAP/ENIMGA-tbss-nonFA-batch.sh

Copy and paste code:

#!/bin/bash
curTime=`date +"%Y%m%d-%H%M%S"`
mkdir -p ~/logfiles/ACAP/${curTime}
for subjid in $(ls ~/analyses/ACAP/tbss/FA-individ/); do
  sbatch \
  -o ~/logfiles/ACAP/${curTime}/output_${subjid}.txt \
  -e ~/logfiles/ACAP/${curTime}/error_${subjid}.txt \
  ~/scripts/ACAP/ENIMGA-tbss-nonFA-job.sh \
  ${subjid}
  sleep 1
done

21.3 Submit Jobs with Batch Script

sh ~/scripts/ACAP/ENIMGA-tbss-nonFA-batch.sh

You can check the status of your jobs by checking if it is running or pending.

squeue

You can check the outputs.

tail -n 5 ~/logfiles/ACAP/<date>/output*

21.4 Sync Data

rsync -rauv \
ashley.ware@arc.ucalgary.ca:/work/ashley.ware/data/ACAP/enigma/tbss/ \
/Volumes/bobo/data/ACAP/enigma/tbss/

You may want to double check your skeleton images:

/Volumes/bobo/data/ACAP/enigma/tbss/*-individual/sub-*/stats/*skel.nii.gz