Ah, this very helpful. Our AFNI install is old at this point, so I think that is the first thing to update that. I lose region information during the resampling steps. My goal is to end up with a matrix subjects by region, so any suggestions that get to that are super helpful.
Here is my bash script, simplified:
#!/bin/bash
module load afni/17.3.06
cd <path>/noddi/dset/derivatives/
clear
for file in *; do
echo $file
s=${file//sub-/}
echo "You are processing subject $s"
3dcalc -a <path>/freesurfer_v6/$s/surf/SUMA/aparc.a2009s+aseg_rank_Alnd_Exp+orig -expr 'a' -prefix <path>/freesurfer_v6/$s/surf/SUMA/aparc.a2009s+aseg_rank_Alnd_Exp_short -datum short -overwrite
3dfractionize -template <path>/noddi/dset/derivatives/sub-"$s"/ses-S1/NODDI/NDI.nii.gz \
-input <path>/freesurfer_v6/$s/surf/SUMA/aparc.a2009s+aseg_rank_Alnd_Exp_short+orig \
-vote \
-clip 0.5 \
-preserve \
-prefix <path>/freesurfer_v6/$s/surf/SUMA/aparc.a2009s+aseg_rank_Alnd_Exp_noddi_frac+orig \
-overwrite
3dROIstats -numROI 194 -zerofill NA -mask <path>/freesurfer_v6/$s/surf/SUMA/aparc.a2009s+aseg_rank_Alnd_Exp_noddi_frac+orig \
<path>/noddi/dset/derivatives/sub-"$s"/ses-S1/NODDI/NDI.nii.gz > <path>/noddi/dset/derivatives/sub-"$s"/ses-S1/NODDI/NDI_a2009.txt
done
After this, I have an R script that brings everything into a subject by ROI matrix.