
Before viewing the script, it may be necessary to open a new terminal window,
since afni should already be running from FT.results directory.  Leave the
terminal sitting under FT.results alone and open a new terminal window, then
'cd' to this same FT_analysis directory.

      % cd AFNI_data6/FT_analysis
      % ls

Of course the 'ls' command should show things like s01.ap.simple, proc.FT
and FT.results.

----------------------------------------------------------------------

Begin reviewing the processing script to verify what was done to the input data
to get the output data.

** Keep in mind that the processing steps reflect your own decisions.

This section is to get a feel for how the script is organized.

View the script with an editor or with the Unix less program, for example:

      % less proc.FT

   Recall the basic keystrokes for the 'less' program, as noted in the class
   handout afni00_unix.pdf:

        <arrows> : one line up or down
        <enter>  : one line down
        <space>  : one page down (the height of your terminal window)
        b        : 'back' up one page
        g        : 'go' to the beginning
        G        : 'go' to the end
        h        : show the 'help' menu (running 'less' on the help text)
        /        : search for some string
        n        : find 'next' occurence of search string, down
        N        : find 'next' occurence of search string, up
        q        : 'quit' from less (or from the 'help' menu)

A. General comments about the script
B. Top of script
C. First processing block: setup

----------------------------------------------------------------------

A. General comments about the script

   There is a lot of syntax here.  First note that the '#' character is used
   for comments (text lines that are not processed by the shell, they are to
   help the reader follow what the script is doing).

   Next, scroll through the script and note that there are many sections,
   separated by '# ================ TITLE =============' lines.  If the title
   starts with 'auto block', it means afni_proc.py automatically put that
   processing block in the script.  Otherwise, it is one that the user chose
   (keep in mind the default processing blocks: tshift, volreg, blur, mask,
   scale, regress).

B. Commands at the top of the script.

        #!/bin/tcsh -xef

   In case the script is executed via './proc.FT', this line (first line of a
   shell script) specifies with program to use for executing the script.  Note
   that the syntax between bash, tcsh, python, perl, etc. can differ quite a
   bit, so it is important to have a way to specify which syntax is intended.

        echo "auto-generated by afni_proc.py, Mon Jul 26 10:11:51 2010"
        echo "(version 2.33, July 22, 2010)"

   Recall that the 'echo' command just echo's text to the terminal window.
   So when this script is started, the user will know it was generated via
   afni_proc.py, the day and time, and which version of afni_proc.py was used.

        # execute via : 
        #   tcsh -xef proc.FT |& tee output.proc.FT

   Here the user is simply reminded how it might be run.  Again, these are
   comment lines that the script ignores because they start with '#'.  The very
   first line of the script is special (different) that way. 

C. First processing block: setup

   This automatic processing block is used for basic operation before the EPI
   data is touched.  The AFNI package is varified as being recent enough to
   execute this script, variables are assigned, output directories are created,
   the results directory is created and basic data files are copied over.

   The key lines to note:

        afni_history -check_date 19 Jul 2010

   For the common case where users run afni_proc.py on one machine, but end up
   executing the script on another, it is prudent to make sure AFNI is recent
   enough for executing the script (since the script might rely on changes made
   to programs on a certain date).

   This 'afni_history' command will compare the most recent history item with
   the specified date.  It is considered failure if the specified date is more
   recent than the items in afni_history.  In such a case, the script should
   terminate.

   Note that afni_history will return a non-zero value to $status in that case,
   which will be checked on the following line.  If the user is running the
   script via 'tcsh -xef' as suggested, the '-e' option will force the script
   to terminate before even the 'if ( $status ) then' line.

        set subj = FT

   So the subject variable '$subj' will have value 'FT', which will affect the
   name of the output directory and most created files.

        set output_dir = $subj.results

   This creates a variable '$output_dir' to have the value 'FT.results'.  That
   is the name of the output/results directory.

        if ( -d $output_dir ) then  ...

   If the results directory already exists, the script will complain and exit.
   Most AFNI programs do not like to delete or overwrite existing data.

        set runs = (`count -digits 2 1 3`)

   Make an array variable called '$runs', the value of which is the list of
   EPI runs ( 01 02 03 ).  Note the command enclosed in backward quotes ``
   (usually in the upper-left corner of the keyboard).  Recall that the shell
   will execute the command in those quotes and replace it with the output.
   So since the output of

                count -digits 2 1 3

   is

                01 02 03

   the 'set runs ...' command becomes the same as:

        set runs = ( 01 02 03 )

   This command will be used later in 'foreach run' loops.

   ------------------------------

        mkdir $output_dir
        mkdir $output_dir/stimuli

   Create the main output directory (FT.results) and a sub-directory called
   stimuli, where the stimulus timing files will go.

        cp FT/AV1_vis.txt FT/AV2_aud.txt $output_dir/stimuli

   Copy the stimulus timing files into that new directory.

        3dcopy FT/FT_anat+orig $output_dir/FT_anat

   Use 3dcopy to copy the anatomical dataset into the results directory.

