function conn_batchexample_Setup; % example batch process for experiment SETUP. Edit the fields below % This example defines the information for the attention dataset (http://www.fil.ion.ucl.ac.uk/spm/data/attention/) % Information defined here includes: acquisition TR, number of subjects, % number of sessions per subject, location of functional and anatomical % volumes, location of ROI files, location of realignment parameters, and % definition of a single condition encompassing the entire session %% BATCH INFORMATION (edit this section) rootfolder=pwd; batch.filename=... % conn_* project file to be created/modified fullfile(rootfolder,'conn_attention.mat'); %% EXPERIMENT INFORMATION (edit this section) batch.Setup.isnew=1; % 0: modifies existing project; 1: creates new proejct batch.Setup.RT=3.22; % TR (in seconds) batch.Setup.nsubjects=1; % number of subjects % functional data files (cell array per subject and sessions): batch.Setup.functionals{nsub}{nses} is an array listing the (smoothed/normalized/realigned) functional file(s) for subject "nsub" and session "nses" files=dir(fullfile(rootfolder,'functional','wsnffM00587_*.img')); batch.Setup.functionals{1}{1}=[repmat([fullfile(rootfolder,'functional'),filesep],[length(files),1]),strvcat(files(:).name)]; % anatomical volumes (cell array per subject): batch.Setup.structurals{nsub} is an array pointing to the (normalized) anatomical volume for subject "nsub" batch.Setup.structurals{1}=fullfile(rootfolder,'structural','wnsM00587_0002.img'); % roi files (cell array per roi): batch.Setup.rois{nroi} is a string pointing to a (normalized) ROI file (if not specified all .nii & .img & .tal files in the conn/roi folder will be interpreted as ROI files) batch.Setup.rois={fullfile(fileparts(which('conn')),'rois','BA.img'), ... fullfile(fileparts(which('conn')),'utils','otherrois','V1.img'),... fullfile(fileparts(which('conn')),'utils','otherrois','V2.img'),... fullfile(fileparts(which('conn')),'utils','otherrois','V5.img'),... fullfile(fileparts(which('conn')),'utils','otherrois','PFC.img'),... fullfile(fileparts(which('conn')),'utils','otherrois','PPC.img') }; % condition names: cell array of strings (one per condition) batch.Setup.conditions.names={'Fix','Stat','Natt','Att'}; % batch.Setup.conditions.onsets{ncondition}{nsub}{nses} is an array of onset value(s) (in seconds) for condition "ncondition" subject "nsub" and sessions "nses" x=load(fullfile(rootfolder,'conditions.mat')); batch.Setup.conditions.onsets{1}{1}{1}=3.22*max(0,find(x.fix>[0;x.fix(1:end-1)])-2); batch.Setup.conditions.onsets{2}{1}{1}=3.22*max(0,find(x.stat>[0;x.stat(1:end-1)])-2); batch.Setup.conditions.onsets{3}{1}{1}=3.22*max(0,find(x.natt>[0;x.natt(1:end-1)])-2); batch.Setup.conditions.onsets{4}{1}{1}=3.22*max(0,find(x.att>[0;x.att(1:end-1)])-2); % batch.Setup.conditions.durations{ncondition}{nsub}{nses} is a value defining the duration of each block for condition "ncondition" subject "nsub" and sessions "nses" %(note: setting to "inf" is equivalent to setting this value to the total session time) " batch.Setup.conditions.durations{1}{1}{1}=32.2; batch.Setup.conditions.durations{2}{1}{1}=32.2; batch.Setup.conditions.durations{3}{1}{1}=32.2; batch.Setup.conditions.durations{4}{1}{1}=32.2; % names of temporal (first-level) covariates batch.Setup.covariates.names={'sessions'}; % cell array of strings (one per covariate and subject and condition): batch.Setup.covariates.files{ncovariate}{nsub}{nses} is an array pointing the a file defining the covariate "ncoviarate" for subject "nsub" and sessions "nses" (note: valid files are .txt or .mat files and should contain as many rows as scans for each given subject/session) X=kron(eye(4),ones(90,1));save(fullfile(rootfolder,'sessions.mat'),'X'); batch.Setup.covariates.files{1}{1}{1}=fullfile(rootfolder,'sessions.mat'); batch.Setup.done=1; % 0: only edits project fields (do not run Setup->'Done'); 1: run Setup->'Done' % 1: Performs initial steps (segmentation, data extraction, etc.) on the defined experiment (equivalent to pressing "Done" in the gui "Setup" window) % set to 0 if you prefer to further inspect/edit the experiment information in the gui before performing this step batch.Setup.overwrite='Yes'; % overwrite existing results if they exist (set to 'No' if you want to skip preprocessing steps for subjects/ROIs already analyzed; if in doubt set to 'Yes') % For example you would set this field to 'No' if you have already run this script and later you add a few more subjets and/or ROIs and want to run this modified script again without having the existing subjects unnecessarily reanalyzed. % note: removing some subjects needs to be done through the gui, if done through the batch you need to set overwrite to 'Yes' conn_batch(batch);