#! /bin/sh

# Take 4 includes the pial surface as stop mask, rather than as a exclusion mask as in take 3
# Tke 4b is as take 4, but with opposite hemi avoid mask

Chimplate=/vols/Scratch/rmars/MrCat-dev/ref_other/Chimplate/ChimpYerkes29_AverageT1w_restore

for hemi in L; do

# for subj in Bo; do
for subj in Agatha Amanda Barbara Bo Brodie Callie Cheeta Christa Cissie Fiona Foxy Bo Frannie Jacqueline Jaimie Jewelle Leslie LilOne Liza Lulu Marietta Rebecca Rowena Sabrina Suwanee Sylvia Wenka; do

     bpxdir=/vols/Data/rbmars/Chimps/$subj/T1w/Diffusion_bpx_ARD.bedpostX
     strdir=/vols/Data/rbmars/Chimps/$subj
     outdir=/vols/Data/rbmars/Chimps/surface_fdt_matrix2/$subj/surfseed_${hemi}_15mm_take4b
     mkdir -p $outdir

     white=$strdir/MNINonLinear/fsaverage_LR20k/${subj}.${hemi}.white.20k_fs_LR.surf.gii
     pial=$strdir/MNINonLinear/fsaverage_LR20k/${subj}.${hemi}.pial.20k_fs_LR.surf.gii
     mt=$strdir/MNINonLinear/fsaverage_LR20k/${subj}.${hemi}.midthickness.20k_fs_LR.surf.gii
     
     whiteL=$strdir/MNINonLinear/fsaverage_LR20k/${subj}.L.white.20k_fs_LR.surf.gii
     whiteR=$strdir/MNINonLinear/fsaverage_LR20k/${subj}.R.white.20k_fs_LR.surf.gii
     pialL=$strdir/MNINonLinear/fsaverage_LR20k/${subj}.L.pial.20k_fs_LR.surf.gii
     pialR=$strdir/MNINonLinear/fsaverage_LR20k/${subj}.R.pial.20k_fs_LR.surf.gii

     o=" --xfm=$strdir/MNINonLinear/xfms/standard2acpc_dc --invxfm=$strdir/MNINonLinear/xfms/acpc_dc2standard"
     o=" $o --seed=$mt --omatrix2 --target2=${Chimplate}_brain_15mm -P 10000 --seedref=${Chimplate}_15mm --stop=${pialL} --avoid=${whiteR}"
     
     echo "$bpxdir $outdir $o"
     
     /vols/Data/rbmars/Chimps/scripts/quicktrack_gpu $bpxdir $outdir $o
    
 done
 done
 
 for hemi in R; do

# for subj in Bo; do
for subj in Agatha Amanda Barbara Bo Brodie Callie Cheeta Christa Cissie Fiona Foxy Bo Frannie Jacqueline Jaimie Jewelle Leslie LilOne Liza Lulu Marietta Rebecca Rowena Sabrina Suwanee Sylvia Wenka; do

     bpxdir=/vols/Data/rbmars/Chimps/$subj/T1w/Diffusion_bpx_ARD.bedpostX
     strdir=/vols/Data/rbmars/Chimps/$subj
     outdir=/vols/Data/rbmars/Chimps/surface_fdt_matrix2/$subj/surfseed_${hemi}_15mm_take4b
     mkdir -p $outdir

     white=$strdir/MNINonLinear/fsaverage_LR20k/${subj}.${hemi}.white.20k_fs_LR.surf.gii
     pial=$strdir/MNINonLinear/fsaverage_LR20k/${subj}.${hemi}.pial.20k_fs_LR.surf.gii
     mt=$strdir/MNINonLinear/fsaverage_LR20k/${subj}.${hemi}.midthickness.20k_fs_LR.surf.gii
     
     whiteL=$strdir/MNINonLinear/fsaverage_LR20k/${subj}.L.white.20k_fs_LR.surf.gii
     whiteR=$strdir/MNINonLinear/fsaverage_LR20k/${subj}.R.white.20k_fs_LR.surf.gii
     pialL=$strdir/MNINonLinear/fsaverage_LR20k/${subj}.L.pial.20k_fs_LR.surf.gii
     pialR=$strdir/MNINonLinear/fsaverage_LR20k/${subj}.R.pial.20k_fs_LR.surf.gii

     o=" --xfm=$strdir/MNINonLinear/xfms/standard2acpc_dc --invxfm=$strdir/MNINonLinear/xfms/acpc_dc2standard"
     o=" $o --seed=$mt --omatrix2 --target2=${Chimplate}_brain_15mm -P 10000 --seedref=${Chimplate}_15mm --stop=${pialR} --avoid=${whiteL}"
     
     echo "$bpxdir $outdir $o"
     
     /vols/Data/rbmars/Chimps/scripts/quicktrack_gpu $bpxdir $outdir $o
    
 done
 done
