% ts1_start.m
%
% Top-level script for analyzing data from selective attention to timbre
% experiment coded for the 2000 Summer Institute
%
% 06/16/00 Petr Janata

global dataroot spm_path SCAN_OFFSET

% List of functions to perform
%
% For each function flag, list subjects for which the function should be run.
% The subject indices refer to indices in the sinfo structure returned by
% get_ts1_sinfo
%

start_time = clock;

CONVERT_FORMAT = []; % 1:17

RUN_SPM_BATCH = 1;
batch_file = '/data1/matlab/ts1/ts1_batch.m';

diary_name = sprintf('ts1_diary_%s_%s', datestr(datenum(now),1), datestr(datenum(now),15));
%diary(diary_name);

NOTIFY = 0;

%indata_root = '/mnt/cdrom/';
indata_root = '/data1/ts1';
outdata_root = '/data1/ts1';
spm_root = '/data1/ts1/';

dataroot = spm_root;

spm_path = '/usr/local/matlab/toolbox/local/spm99/';

%
% Get info on all subjects
%

s = get_ts1_sinfo;

%
% Convert data from GE format into AVW
%

if CONVERT_FORMAT
  convert_format(s(CONVERT_FORMAT),indata_root,outdata_root, SCAN_OFFSET);
end

%
%  Run the SPM batch file
%

if RUN_SPM_BATCH
  spm_bch(batch_file);
end

diary off
elapsed_time = etime(clock,start_time)

if NOTIFY
  unix(['mail janata@dartmouth.edu -s "ts1_batch finished" < ' diary_name])
%  unix('mail babsi@dartmouth.edu -s "ts1_batch finished" < /dev/null')
end

