#! /bin/csh -f

#
# diag-optseq
#
# Original Author: Doug Greve
# CVS Revision Info:
#    $Author: nicks $
#    $Date: 2007/01/09 22:41:17 $
#    $Revision: 1.2 $
#
# 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   DIAGOPTSEQ_VER = '$Id: diag-optseq,v 1.2 2007/01/09 22:41:17 nicks Exp $';
echo "$DIAGOPTSEQ_VER"

if($#argv == 0) then
  set OutDir = ./tmp-diag-data
else
  set OutDir = $argv[1];
endif

mkdir -p $OutDir
cd $OutDir

set Ntp = 128
set NpercondList = (128 64 32 16)
set TER = 1;
set TR = 2
set TW = 20
set Nruns = 5;
set Seed = 53
set Nsearch = 100
set Nnnc = $#NpercondList
@ Nc = $Nnnc + 1;

rm -f eff.dat
foreach Nper ( $NpercondList )

  echo -------------- Nper $Nper ---------------------
  set OutPrefix = par-$Nper
  set Npercond = ($Nper)

  if(1) then
    optseq -Ntp $Ntp -npercond $Npercond -TR $TR -TER $TER -tw $TW \
           -nruns $Nruns -seed $Seed -nsearch $Nsearch -o $OutPrefix

    set rt = $status
    if($rt)then
      echo "ERROR: optseq exited with error code $rt"
      exit $rt;
    endif
  endif

  set Eff = `seqefficiency -p $OutPrefix-001.dat -TR $TR -TW $TW -Ntp $Ntp`;
  echo $Nper $Eff | tee -a eff.dat
end

exit 0;
