Hello,
I am trying to loop the VOI time-series extraction of a dataset.
The problem with the data set is that the subject numbers are not consecutive, so I am using the 'sprintf' function, adding two arguments: the first is the text that I want to be returned by the function, in this case, the folder names that start with sub-A2 have defined(SubNums). The second argument is what I want to be inserted into that text, which is the non-consecutive numbers (SubNums).
At the moment trying to use the 'sprintf' function like this is generating the following error
_____
Index exceeds the number of array elements (36).
Error in VOIextraction_bDCM_specification_LOOP (line 25)
cd(fullfile(data_path, sprintf('sub-A2%03d',SubNums(crun))));
______
This is the full batch script for reference
spm('Defaults','fMRI');% Open SPM, OPEN GOOD
spm('CreateIntWin','on');
spm_figure('Create','Graphics','Graphics','on');
spm_jobman('initcfg');
%data_path = fileparts(mfilename('D:\Work\RP_data\'));
data_path = 'D:\Work\RP_data\';
clear matlabbatch %Clears any other batches on the matlab command window or the GUI
nrun = 2;
SubNums = [2 3];
%SubNums:[2 3 4 5
% 6 7 8 9 10 11 13 14 15 16
% 17 19 20 21 24 25 27 28 29 30
% 32 33 34 35 36 37 38 39 40 41
% 42 46 47 49 50 51 52 53 55 56
% 57 58 59 61 62 63 64]
for crun = 1:nrun
cd(fullfile(data_path, sprintf('sub-A2%03d',SubNums(crun)), 'FirstLevel'));
%cd (sprintf('D:\\Work\\RP_data\\sub-A2%03d\\FirstLevel',SubNums(crun)));
%cd (data_path);
% EXTRACTING TIME SERIES: PAC
%--------------------------------------------------------------------------
matlabbatch{1}.spm.util.voi.spmmat = cellstr(fullfile(pwd,'SPM.mat'));
matlabbatch{1}.spm.util.voi.adjust = 1; % "effects of interest" F-contrast
matlabbatch{1}.spm.util.voi.session = 1; % session 1
matlabbatch{1}.spm.util.voi.name = 'PAC';
matlabbatch{1}.spm.util.voi.roi{1}.spm.spmmat = {''}; % using SPM.mat above
matlabbatch{1}.spm.util.voi.roi{1}.spm.contrast = 1; % "RC+" F-contrast
matlabbatch{1}.spm.util.voi.roi{1}.spm.threshdesc = 'none';
matlabbatch{1}.spm.util.voi.roi{1}.spm.thresh = 0.00001;
matlabbatch{1}.spm.util.voi.roi{1}.spm.extent = 0;
%matlabbatch{1}.spm.util.voi.roi{1}.spm.mask.contrast = 3; % "RC+" F-contrast
%matlabbatch{1}.spm.util.voi.roi{1}.spm.mask.thresh = 0.05;
%matlabbatch{1}.spm.util.voi.roi{1}.spm.mask.mtype = 0; %inclusive
matlabbatch{1}.spm.util.voi.roi{2}.sphere.centre = [-54 -28 10];
matlabbatch{1}.spm.util.voi.roi{2}.sphere.radius = 6;
matlabbatch{1}.spm.util.voi.roi{2}.sphere.move.fixed = 1;
matlabbatch{1}.spm.util.voi.expression = 'i1 & i2';
% EXTRACTING TIME SERIES: pSTG
%--------------------------------------------------------------------------
matlabbatch{2}.spm.util.voi.spmmat = cellstr(fullfile(pwd,'SPM.mat'));
matlabbatch{2}.spm.util.voi.adjust = 1; % "effects of interest" F-contrast
matlabbatch{2}.spm.util.voi.session = 1; % session 1
matlabbatch{2}.spm.util.voi.name = 'STG';
matlabbatch{2}.spm.util.voi.roi{1}.spm.spmmat = {''}; % using SPM.mat above
matlabbatch{2}.spm.util.voi.roi{1}.spm.contrast = 1; % "RC-" F-contrast
matlabbatch{2}.spm.util.voi.roi{1}.spm.threshdesc = 'none';
matlabbatch{2}.spm.util.voi.roi{1}.spm.thresh = 0.00001;
matlabbatch{2}.spm.util.voi.roi{1}.spm.extent = 0;
%matlabbatch{2}.spm.util.voi.roi{1}.spm.mask.contrast = 2; % "RC-" F-contrast
%matlabbatch{2}.spm.util.voi.roi{1}.spm.mask.thresh = 0.05;
%matlabbatch{2}.spm.util.voi.roi{1}.spm.mask.mtype = 0; % inclusive
matlabbatch{2}.spm.util.voi.roi{2}.sphere.centre = [-66 -28 8];
matlabbatch{2}.spm.util.voi.roi{2}.sphere.radius = 6;
matlabbatch{2}.spm.util.voi.roi{2}.sphere.move.fixed = 1;
matlabbatch{2}.spm.util.voi.expression = 'i1 & i2';
% EXTRACTING TIME SERIES: pIFG
%--------------------------------------------------------------------------
matlabbatch{3}.spm.util.voi.spmmat = cellstr(fullfile(pwd,'SPM.mat'));
matlabbatch{3}.spm.util.voi.adjust = 1; % "effects of interest" F-contrast
matlabbatch{3}.spm.util.voi.session = 1; % session 1
matlabbatch{3}.spm.util.voi.name = 'IFG';
matlabbatch{3}.spm.util.voi.roi{1}.spm.spmmat = {''}; % using SPM.mat above
matlabbatch{3}.spm.util.voi.roi{1}.spm.contrast = 1; % "Words" F-contrast
matlabbatch{3}.spm.util.voi.roi{1}.spm.threshdesc = 'none';
matlabbatch{3}.spm.util.voi.roi{1}.spm.thresh = 0.05;
matlabbatch{3}.spm.util.voi.roi{1}.spm.extent = 0;
%matlabbatch{3}.spm.util.voi.roi{1}.spm.mask.contrast = 2; % "Words" F-contrast
%matlabbatch{3}.spm.util.voi.roi{1}.spm.mask.thresh = 0.05;
%matlabbatch{3}.spm.util.voi.roi{1}.spm.mask.mtype = 0; % inclusive
matlabbatch{3}.spm.util.voi.roi{2}.sphere.centre = [-50 26 20];
matlabbatch{3}.spm.util.voi.roi{2}.sphere.radius = 6;
matlabbatch{3}.spm.util.voi.roi{2}.sphere.move.fixed = 1;
matlabbatch{3}.spm.util.voi.expression = 'i1 & i2';
spm_jobman('run',matlabbatch);
end
|