export SVN_REVISION=82
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/MCR/v80/bin/glnxa64:.
export MCR_DIRECTORY=/usr/local/MCR/v80
export INSTALL_PREFIX=`expr /usr/local/prototype_matlab/V"$SVN_REVISION"`

export DATASET_HOME=/home/kmatho/data/STP_processed/171017_KM_Tcergh2bGFPfemale_processed/
export DATASET_PREFIX=171017_KM_Tcergh2bGFPfemale #no backslash here
IS_TWO_CHANNEL=1 # put 1 for 2chnl and 0 for 1chnl raw data #
export CH1_PARAMFILENAME=/mnt/sonas/Katie/STP/STP_raw/171017_KM_Tcergh2bGFPfemale_raw/171017_KM_Tcergh2bGFPfemale_ch1/Mosaic_487e45e0-3094-4916-b49a-c37426b64373.txt # get path to text file #
export CH2_TIF_DIR=/mnt/sonas/Katie/STP/STP_raw/171017_KM_Tcergh2bGFPfemale_raw/171017_KM_Tcergh2bGFPfemale_ch2/ # add forward slash #
export CH3_TIF_DIR=blank
export OFFSETPOSITION=0
export NTHREADS=12
export IMAGE_CORRECTION=1  # put 1 for image correction and 0 for skip image correction #
export IMAGE_CORRECTION_METHOD=0  # put 0 for Matlab type and 1 for Fiji type #
export STITCHING=1  # put 1 for stitching and 0 for skip stitching #
export RESIZING_PERCENTAGE=0.05
export FUSION_METHOD=3  # put 0 for minimum, 1 for maximum, 2 for average, 3 for blending, 4 for no blending #
export CH1_PREFIX=ch1
export CH2_PREFIX=ch2
export SECTION_STARTNUMBER=1
export SECTION_ENDNUMBER=260
export CLIPWIDTHNORTH=15
export CLIPWIDTHSOUTH=15
export CLIPWIDTHEAST=15
export CLIPWIDTHWEST=15
export OVERLAP_PERCENTAGE=12
export STAGE_POSITIONS=0


mkdir Log
export TIF_CONVERSION_EXE=`expr "$INSTALL_PREFIX"/bin/run_readMasterParamFile3D.sh`
echo "tif format conversion"
$TIF_CONVERSION_EXE $MCR_DIRECTORY $CH1_PARAMFILENAME $CH2_TIF_DIR $CH3_TIF_DIR $DATASET_HOME $SECTION_STARTNUMBER $SECTION_ENDNUMBER $CLIPWIDTHNORTH $CLIPWIDTHSOUTH $CLIPWIDTHEAST $CLIPWIDTHWEST $OVERLAP_PERCENTAGE $IMAGE_CORRECTION $IMAGE_CORRECTION_METHOD $RESIZING_PERCENTAGE $STITCHING $FUSION_METHOD $STAGE_POSITIONS $OFFSETPOSITION $NTHREADS
if [ $IS_TWO_CHANNEL -eq 1 ]
then
rm -R tifFiles_$CH2_PREFIX
rm -R corrTifFiles_$CH2_PREFIX
rm -R tifFiles_$CH1_PREFIX
rm -R corrTifFiles_$CH1_PREFIX
cd warping
mv $CH2_PREFIX.tif "$DATASET_PREFIX"_"$CH2_PREFIX"_p05.tif
mv $CH1_PREFIX.tif "$DATASET_PREFIX"_"$CH1_PREFIX"_p05.tif
else
rm -R tifFiles_$CH1_PREFIX
rm -R corrTifFiles_$CH1_PREFIX
cd warping
mv $CH1_PREFIX.tif "$DATASET_PREFIX"_"$CH1_PREFIX"_p05.tif
fi
cd $DATASET_HOME
mv *.txt *.mat $DATASET_HOME/Log

