#!/bin/bash
#supply a seeds.txt and a targets.txt file located in each subject's folder in /YOUR_BEDPOST_DIR/CoRegistration/ that gives #path to a set of seeds and targets in patient diffusion space.
homepath=/YOUR_HOME(ALLsubjects)_DIRECTORY/
cd $homepath
transform3=/YOUR_RIGID_TRANSFORM_IITFA_to_MNI.mat
transform4=/YOUR_AFFINE_TRANSFORM_IITFA_to_MNI.mat
transform5=/YOUR_NONLINEAR_WARP_IITFA_to_MNI.nii.gz
for d in $homepath
waytotal)
#make a normalized paths file for brining to MNI space
fslmaths *$targetname*/fdt_paths.nii.gz -div $max_paths fdt_paths_normalized.nii.gz
mv *normalized* *$targetname*
#move folder into subject specific subdirectory
mv *$targetname* probtrax/specific_targets
##Waypoint calculation, using callosal exclusion, stop mask, B:A calculation, store waytotal as variable, move
resulting probtrax folder into appropriate directory
probtrackx2 -s bedpost_dir.bedpostX/merged -m bedpost_dir.bedpostX/nodif_brain_mask.nii.gz -x $a --
dir="$targetname"_"$seedname"_termmask --waypoints=$p --stop=$p --
avoid=CoRegistration/MNIvolumes_WarpedTo_SubjDiff/WM_Callosal_Body_MNI_Juelich_thresh40_DiffSpace.nii.gz -l -c 0.2
-S 2000 --steplength=0.5 -P 5000 --fibthresh=0.01 --distthresh=0.0 --sampvox=0.0 --opd -V 1
#save waytotal number into variable, move resulting probtrax folder into appropriate directory
waytotalB=$(head -n 1 *$targetname*/waytotal)
mv *$targetname* probtrax/specific_targets
#warp seed to target paths into MNI space
$ANTSPATH/antsApplyTransforms -d 3 -i probtrax/specific_targets/"$seedname"_"$targetname"_termmask/fdt_paths_normalized.nii.gz -r $reference -o
/YOUR_SUBJ_MNI_OUTPUTDIR/"$seedname"_"$targetname"_MNIpaths.nii.gz -t $transform5 -t
$transform4 -t $transform3 -t $transform2 -t $transform1 -v
#store waytotal values into signle textfile
echo $waytotalX >> /DATA_OUTPUT_FOLDER/waytotals.txt
echo $waytotalB >> $homepath/sbsnider/response_processing/waytotalsBtoA.txt
done <CoRegistration/targets.txt
done < CoRegistration/seeds.txt
cd $homepath
done