Home > marsbar > examples > batch > er_model_spm2.m

er_model_spm2

PURPOSE ^

SPM2 batch script wrapper for ER data

SYNOPSIS ^

function SPM = er_model_spm2(sess_dir, sesses, ana_dir)

DESCRIPTION ^

 SPM2 batch script wrapper for ER data
 FORMAT SPM = er_model_spm2(sess_dir, sesses)

 sess_dir        - directory containing session directories
 sesses          - string or cell array of session directory names
 ana_dir         - analysis directory
 
 Returns
 SPM             - SPM model structure after configuration
 
 The script is specific to this design...

 $Id: er_model_spm2.m,v 1.1.1.1 2004/08/14 00:07:52 matthewbrett Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function SPM = er_model_spm2(sess_dir, sesses, ana_dir)
0002 % SPM2 batch script wrapper for ER data
0003 % FORMAT SPM = er_model_spm2(sess_dir, sesses)
0004 %
0005 % sess_dir        - directory containing session directories
0006 % sesses          - string or cell array of session directory names
0007 % ana_dir         - analysis directory
0008 %
0009 % Returns
0010 % SPM             - SPM model structure after configuration
0011 %
0012 % The script is specific to this design...
0013 %
0014 % $Id: er_model_spm2.m,v 1.1.1.1 2004/08/14 00:07:52 matthewbrett Exp $
0015 
0016 if nargin < 1
0017   error('Need directory containing session subdirectories');
0018 end
0019 if nargin < 2
0020   error('Need directory names for sessions');
0021 end
0022 if nargin < 3
0023   ana_dir = pwd;
0024 end
0025 
0026 if ischar(sesses), sesses = cellstr(sesses); end
0027 nsessions = length(sesses);
0028 
0029 pwd_store = pwd;
0030 cd(ana_dir);
0031 
0032 % load SPM defaults
0033 if ~exist('defaults', 'var')
0034   global defaults;
0035   spm_defaults; 
0036 end
0037 
0038 % Specify some design stuff
0039 SPM.xY.RT          =  2.02726;                              % seconds
0040 
0041 % Specify design
0042 %===========================================================================
0043 % global normalization: OPTOINS:'Scaling'|'None'
0044 %---------------------------------------------------------------------------
0045 SPM.xGX.iGXcalc    = 'None';
0046 
0047 % low frequency confound: high-pass cutoff (secs) [Inf = no filtering]
0048 %---------------------------------------------------------------------------
0049 SPM.xX.K(1).HParam    = 60;
0050 
0051 % intrinsic autocorrelations: OPTIONS: 'none'|'AR(1) + w'
0052 %-----------------------------------------------------------------------
0053 SPM.xVi.form       = 'AR(1) + w';
0054 
0055 % basis functions and timing parameters
0056 %---------------------------------------------------------------------------
0057 % OPTIONS:'hrf'
0058 %         'hrf (with time derivative)'
0059 %         'hrf (with time and dispersion derivatives)'
0060 %         'Fourier set'
0061 %         'Fourier set (Hanning)'
0062 %         'Gamma functions'
0063 %         'Finite Impulse Response'
0064 %---------------------------------------------------------------------------
0065 SPM.xBF.name       = 'hrf (with time derivative)';
0066 SPM.xBF.length     = 24;                % length in seconds
0067 SPM.xBF.order      = 1;                 % order of basis set
0068 SPM.xBF.T          = 16;                % number of time bins per scan
0069 SPM.xBF.T0         = 1;                 % first time bin (see slice timing)
0070 SPM.xBF.UNITS      = 'scans';           % OPTIONS: 'scans'|'secs' for onsets
0071 SPM.xBF.Volterra   = 1;                 % OPTIONS: 1|2 = order of convolution
0072 
0073 condnames = {'vis_stim'};
0074 nconds = length(condnames);
0075 
0076 % specify filter for filenames
0077 Filter             = 's*.img';
0078 
0079 PP = ''; stimons = [];
0080 for ss = 1:nsessions
0081   % directory containing scans
0082   fildir = fullfile(sess_dir, sesses{ss});
0083 
0084   % Condition stuff - onset times for visual stimulus
0085   condir = fullfile(fildir, 'onsets');
0086   condfile = spm_get('Files', condir, 'flash*.txt');
0087   condons = spm_load(condfile);
0088   tmp = condons(:,2); % get stimulus column
0089   tmp(tmp < 0) = 0; % correct negative onsets
0090   stimons{1} = tmp;  
0091 
0092   for cno = 1:nconds
0093     SPM.Sess(ss).U(cno).name      =condnames(cno);
0094     SPM.Sess(ss).U(cno).P(1).name = 'none'; % Parametric modulation
0095     SPM.Sess(ss).U(cno).ons = stimons{cno};
0096     SPM.Sess(ss).U(cno).dur = 0;
0097   end
0098     
0099   % file selection
0100   P         = spm_get('files',fildir,Filter);
0101   SPM.nscan(ss) = size(P,1);
0102   
0103   % covariates
0104   SPM.Sess(ss).C.C    = [];       % [n x c double] covariates
0105   SPM.Sess(ss).C.name = {};       % [1 x c cell]   names
0106 
0107   % set files
0108   PP           = strvcat(PP, P);
0109 
0110 end
0111 
0112 % set files
0113 SPM.xY.P           = PP;
0114 
0115 % Configure design matrix
0116 SPM = spm_fmri_spm_ui(SPM);
0117 
0118 % Return to original directory
0119 cd(pwd_store);

Generated on Wed 11-May-2022 15:34:44 by m2html © 2003-2019