#! /bin/bash
# load up images, rotate them, and crop
basePath="/home/projects/APS/xctRecon/2017_03"
#===========================================
# RANGE
# comment list lines and uncomment to do a range
reconStart=21
reconFinish=21
for  ((i=$reconStart; i<=$reconFinish; i++))

#===========================================
# LIST
# comment range lines and uncomment to do a set list
#reconList=(25)
#reconFinish=${reconList[${#reconList[@]}-1]}
#for i in ${reconList[@]}

#===========================================
# main body of loop. Do not edit below this.
do
    expNum=${i}
    expNumIn=$(printf %03d $expNum)
    projNum=$(printf %04d $expNum)
    # Make the paths and a directory to place the output in
    inPath="${basePath}/Exp$expNumIn/matBin"
    outPath="${basePath}/Exp$expNumIn/matBin_crop"
    if [ ! -e "$outPath" ]; then mkdir "${outPath}"; fi
			
    # Run the job
    qsub -N rotateAndCrop_exp$expNumIn -F "$inPath $outPath $expNumIn" /home/projects/APS/xctRecon/rotateAndCrop/run_matlab_batch.sh
    # Pause slightly before submitting the next job
    if [ "$expNum" -ne "$reconFinish" ]; then sleep 0.2; fi
done	
exit 0	
