#!/bin/tcsh

### Script for Part 4 of AFNI Time Series Analysis videos
### - Create a regression matrix for a Block design
###   with 20 second duration, repeated every 30 seconds
### - But use TENTzero basis functions instead of BLOCK
### - plots result into files s4a.png and s4a.xmat.png

# create the matrix file (s4a.xmat.1D)

3dDeconvolve -nodata 150 2.0     \
             -polort -1          \
             -x1D s4a.xmat.1D    \
             -xjpeg s4a.xmat.png \
             -num_stimts 1       \
             -stim_times 1       \
              '1D: 0 30 60 90 120 150 180 210 240 270' \
              'TENTzero(0,26,14)'

# compute the sum of each row to get the
# time series of all regressors combined

3dTstat -sum -prefix stdout: s4a.xmat.1D > s4a.sum.1D

# plot the matrix columns and the sum regressor

1dplot -xaxis 0:150:15:2 -xlabel TR -png s4a.png               \
       -ynames TENT-01 TENT-02 TENT-03 TENT-04 TENT-05 TENT-06 \
               TENT-07 TENT-08 TENT-09 TENT-10 TENT-11 TENT-12 \
               Sum -                                           \
       s4a.xmat.1D s4a.sum.1D
