#! /bin/tcsh -ef

#
# morph_subject-lh
#
# REPLACE_WITH_ONE_LINE_SHORT_DESCRIPTION
#
# Original Author: REPLACE_WITH_FULL_NAME_OF_CREATING_AUTHOR
# CVS Revision Info:
#    $Author: nicks $
#    $Date: 2007/01/06 00:01:14 $
#    $Revision: 1.5 $
#
# Copyright (C) 2002-2007,
# The General Hospital Corporation (Boston, MA).
# All rights reserved.
#
# Distribution, usage and copying of this software is covered under the
# terms found in the License Agreement file named 'COPYING' found in the
# FreeSurfer source code root directory, and duplicated here:
# https://surfer.nmr.mgh.harvard.edu/fswiki/FreeSurferOpenSourceLicense
#
# General inquiries: freesurfer@nmr.mgh.harvard.edu
# Bug reports: analysis-bugs@nmr.mgh.harvard.edu
#



set version = '$Id: morph_subject-lh,v 1.5 2007/01/06 00:01:14 nicks Exp $';

set hemi = lh

if($#argv != 1) then
  echo "USAGE: morph_subject-$hemi subjid"
  echo $version
  exit 1;
endif

set subjdir =  $SUBJECTS_DIR/$1
if(! -e $subjdir) then
  echo "ERROR: $subjdir does not exist"
  exit 1;
endif

pushd $SUBJECTS_DIR/$1

touch NOTES
echo " "      >> NOTES
echo $0 $*    >> NOTES
echo $version >> NOTES
whoami        >> NOTES
date          >> NOTES
hostname      >> NOTES
popd

mkdir -p $SUBJECTS_DIR/$1/scripts
pushd $SUBJECTS_DIR/$1/scripts

#if (-e $SUBJECTS_DIR/$1/surf/$hemi.sphere == 0) \
#    mris_sphere -w 0 ../surf/$hemi.inflated ../surf/$hemi.sphere ;\
#endif

set StartDate = `date`;

#-----------------------------------------------------------------#
mris_sphere -w 0 ../surf/$hemi.inflated ../surf/$hemi.sphere

#-----------------------------------------------------------------#
mris_register -w 0 -curv \
    ../surf/$hemi.sphere \
    $FREESURFER_HOME/average/$hemi.average.tif \
    ../surf/$hemi.sphere.reg

#-----------------------------------------------------------------#
mris_register -w 0 -curv -reverse \
    ../surf/$hemi.sphere \
    $FREESURFER_HOME/average/rh.average.tif \
    ../surf/$hemi.rh.sphere.reg

#-----------------------------------------------------------------#
#morph_rgb-$hemi $1


#mris_register -w 0 ../surf/$hemi.sphere $FREESURFER_HOME/average/$hemi.average.tif ../surf/$hemi.sphere.dist_new

#-----------------------------------------------------------------#
map_central_sulcus $1 $hemi

echo "Started at: $StartDate"
echo "Ended at:   `date`"



exit 0;

#--------------- Ignore ------------------------#
set SVIT_DIR    = $SUBJECTS_DIR/$1/svit
if (-e $SVIT_DIR == 0) \
    mkdir $SVIT_DIR ;\
endif

set SLF = $SVIT_DIR/$hemi.sphere.reg.svit.log
mri-structvits -subject $1 -umask 0 \
    -hemi $hemi -outdir $SVIT_DIR -can sphere.reg | tee -a $SLF
if($status)then
  echo "ERROR: mri-structvits"
  exit 1;
endif
#mri-structvits -subject $1 -umask 0 \
#    -hemi $hemi -outdir $SVIT_DIR -can rh.sphere.reg | tee -a $SLF


