% Compute first level for multiple subjects and sessions.
%
% Glad Mihai, 02.03.2012

clear, clc
%% Experiment folder
data_path = '/media/System/Glad/Matlab_Kurs';
stat_dir = 'statistical';    % all new folders should be created here

% subjects sessions
subjects = {'subject1',...
            'subject2'};
sessions = {
    'wasser',...
    'jaw'};

% use motion parameters as regressors? yes/no
tParams.motion_regress = 'yes';

%%
% timing parameters
tParams.units = 'scans';    % units of design: scans or seconds
tParams.TR = 2;             % repetition time in sec
tParams.mic_res = 34;       % microtime resolution, if # of slices > 16 use
                            % # of slices
tParams.mic_onset = 17;     % microtime onset should be set to the middle slice

% Swallow
conditions(1).name = 'Swallow TR = 2 s';
conditions(1).onsets = ((5:6:119))'; % since n x 1 vector. Start at t = 0!!!!
conditions(1).durations = 0;           % depends on tParams.interval, either in scans or seconds
conditions(1).vector = 1;           % contrast vector

% Jaw
conditions(2).name = 'Jaw Movements TR = 2 s';
conditions(2).onsets = ((5:6:119))'; % since n x 1 vector. Start at t = 0!!!!
conditions(2).durations = 0;           % depends on tParams.interval, either in scans or seconds
conditions(2).vector = 1;           % contrast vector

% print contrast options: unc, FWE
conOpt.whichCon = Inf;     % which contrasts should be printed, Inf: all found in SPM.mat
conOpt.threshType = 'FWE';  % which type of threshold: FWE, none
conOpt.thresh = 0.05;       % threshold
conOpt.extent = 0;          % extent (voxels)

%% initialise spm
spm('defaults', 'FMRI');

% set up matlabbatch and run job
first_level_job(data_path,stat_dir,subjects,sessions,conditions,tParams,conOpt);