Chapter 20 Modified TBSS using ENGIMA
FA ROI Analysis

On the remote computer download the ENIGMA ROI code.

cd ~/apps
wget http://enigma.ini.usc.edu/wp-content/uploads/2012/06/ROIextraction_info.zip
unzip ROIextraction_info.zip 
rm ROIextraction_info.zip 

20.1 Part 1

On the remote computer, loop through all subjids to create a subjid ROI file.

cd /work/ashley.ware/data/ACAP/enigma/tbss/
mkdir -p ROI/part1/FA
outDir=/work/ashley.ware/data/ACAP/enigma/tbss/ROI/part1/FA
for subjid in $(ls ~/analyses/StB/tbss/FA-individ/); do
  inDir=/work/ashley.ware/data/ACAP/enigma/tbss/FA-individ/${subjid}/stats/
  inFile=${inDir}/${subjid}_masked_FAskel.nii.gz
  
  ~/apps/ROIextraction_info/singleSubjROI_exe \
  ~/apps/ROIextraction_info/ENIGMA_look_up_table.txt \
  ~/apps/ROIextraction_info/mean_FA_skeleton.nii.gz \
  ~/apps/ROIextraction_info/JHU-WhiteMatter-labels-1mm.nii.gz \
  ${outDir}/${subjid}_ROIout \
  ${inFile}
done

20.2 Part 2

Loop through all subjids to create ROI file removing ROIs not of interest and averaging others.

cd /work/ashley.ware/data/ACAP/enigma/tbss/
mkdir -p ROI/part2/FA
inDir=/work/ashley.ware/data/ACAP/enigma/tbss/ROI/part1/FA
outDir=/work/ashley.ware/data/ACAP/enigma/tbss/ROI/part2/FA
for subjid in $(ls /work/ashley.ware/data/ACAP/enigma/tbss/FA-individ/); do
  ~/apps/ROIextraction_info/averageSubjectTracts_exe \
  ${inDir}/${subjid}_ROIout.csv \
  ${outDir}/${subjid}_ROIout_avg.csv
done

20.3 Part 3

Create subjid list file.

cd /work/ashley.ware/data/ACAP/enigma/tbss/
outDir=/work/ashley.ware/data/ACAP/enigma/tbss/ROI/part2/FA
rm subjectList-FA.csv
for subjid in $(ls /work/ashley.ware/data/ACAP/enigma/tbss/FA-individ/); do
  echo ${subjid},${outDir}/${subjid}_ROIout_avg.csv >> subjectList-FA.csv
done

Be sure to have your BIDS participants.tsv file avaliable.

cd /work/ashley.ware/BIDS/ACAP
tr '\t' ',' < participants.tsv > /work/ashley.ware/data/ACAP/enigma/tbss/table.csv

Combine all.

cd /work/ashley.ware/data/ACAP/enigma/tbss/
table=/work/ashley.ware/data/ACAP/enigma/tbss/table.csv
subjectIDcol=participant_id
subjectList=/work/ashley.ware/data/ACAP/enigma/tbss/subjectList-FA.csv
outTable=/work/ashley.ware/data/ACAP/enigma/tbss/ROI/FA.csv
Ncov=0
covariates=""
Nroi="all"
rois="all"

module load R
R --no-save --slave --args ${table} ${subjectIDcol} ${subjectList} ${outTable} ${Ncov} ${covariates} ${Nroi} ${rois} <  ~/apps/ROIextraction_info/combine_subject_tables.R  

20.4 Sync Data

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

Your FA results are located at /Volumes/bobo/data/ACAP/enigma/tbss/ROI/FA.csv.