Test F3F Procedures Block-4A - AUTOREGISTER IMAGES - BATCH

##########################################################################
##                                                                      ##
##                               BLOCK 4A                               ##
##                         AUTOREGISTER - BATCH                         ##
##                                                                      ##
##########################################################################

## This block batch autoregisters images contained in lsupport/listImagesForRegistering

## Assumptions:
## User has invoked a Bourne-Again Shell (bash) on ormacsrv1.lpl.arizona.edu
## User is a member of the group OREX\spc
## User has set up a skeleton directory in the following format:
## /SPC_Test/F3G-Nav/
##                   base/
##                            IMAGEFILES/
##                            SHAPEFILES/
##                   lsupport/
##                            PICTLIST.TXT
##                   orig/
##                   results/
##                   test/
## User has completed the processing steps comprising Block 1A - TEST DIRECTORY
## SET-UP - ORIG
## User has additionally populated the orig/ dircteory with test-specific images as per 
## Block 2A / 2B
## User has populated lsupport/listImagesForRegistering with the correct subset of 
## images to register 
## User has registered images listed in lsupport/listImagesForRegistering as per 
## Block 3A 

## User inputs:
## testID: Name of the F3 test directory (for example, F3E-Limbs)
## dirID: Name of sub-directory in which to work (e.g. orig, or test)
## blockID: User-specified identifier for typescript textfile name 
##          (for example, Block-4A-Autoregister-Images-F3G-GenericImages)

# User inputs:
export testID=F3F-Photo
export dirID=orig
export blockID=Block-4A-Autoregister-Images-F3F-DSMapCamImages

# Set-Up
cd /SPC_Test/$testID/$dirID/
script

# Display user inputs
echo $testID
echo $dirID
echo $blockID

date
pwd
ls -l

# set-up batch autoregister files
cp lsupport/listImagesForAutoRegistering make_script.in
cat make_script.in
cp scripts/make_scriptA.seed .
cat make_scriptA.seed
make_scriptA
ls -l

# Batch autoregister images
ls -l /usr/local/bin/autoregister
nohup sh run_script.b &

# Monitor progress
ls -l *.INN *.OOT

# Check results
# Since none of the autoregister output is suppressed, early non-correlations will 
# be flagged by iterateEval.sh
sh support/iterateEval.sh
grep NOCORR evalOut.txt
# cat each OOT file
# OR, since make_scriptA.seed contains the commands to eliminate the image
# from low-correlating lmrks, arguably, there is nothing to check.

# Inspect display outputs
## DECISION:

## OPTION 1: Inspect display outputs on ormacsrv1
ls -l TESTFILES | cut -d '.' -f 1 | rev | cut -d \  -f 1 | rev > listTEST
while read line; do
echo "Displaying TESTFILES/$line"
/opt/local/bin/display TESTFILES/$line
done < listTEST 
rm listTEST
## END OF OPTION 1

##OPTION 2: Inspect display output on a different machine
rm ~/send/*
ls -l TESTFILES | cut -d '.' -f 1 | rev | cut -d \  -f 1 | rev > listTEST
while read line; do
echo $line
/opt/local/bin/convert TESTFILES/${line}.pgm ~/send/${line}.jpg
done < listTEST
rm listTEST
# images inspected on different machine
## END OF OPTION2

# Fix uncorrelated images
# Manually autoregister images and inspect output displays as required
# Since make_scriptA.seed contains the commands to eliminate the image
# from low-sorrleating lmrks, there will not be any uncorelated images to fix

# Save autoregister log files
mkdir -p /SPC_Test/$testID/$dirID/log/log-${blockID}
mv make_script.in make_scriptA.seed /SPC_Test/$testID/$dirID/log/log-${blockID}/
mv *.INN *.OOT run* eval* /SPC_Test/$testID/$dirID/log/log-${blockID}/

# Clean directory
sh rem_script.b
rm TESTFILES/*
rm nohup.out

# Block Complete
date
exit

# Save block log
if [ ! -d /SPC_Test/$testID/log ]; then
  mkdir /SPC_Test/$testID/log
fi

# OPTION 1: OVERWRITE TYPESCRIPT LOG
mv typescript /SPC_Test/$testID/log/log-typescript-${blockID}
# END OF OPTION 1

# OPTION 2: APPEND TYPESCRIPT LOG
cat typescript >> /SPC_Test/$testID/log/log-typescript-${blockID}
# END OF OPTION 2