function subjectStruct  = runROIImageMaskMode(args)

subjects = args.subjects;
   
nSubjects = numel(subjects);
sessionlist = args.sessionList;
pstopts = args.psthOpts;
pstopts.eventList = args.eventList;
pstopts.sessionList = sessionlist;

disp(sprintf('batch processing  %g subjects.',nSubjects));

for s = 1:nSubjects
    subjectStruct{s}.dir = fullfile(args.basedir,cell2mat(subjects(s)));
    d = load(fullfile(subjectStruct{s}.dir,'results','SPM.mat'));
    subjectStruct{s}.des = d.SPM;
    subjectStruct{s}.name = cell2mat(subjects(s));
    subjectStruct{s}.roiFile = ui_selectRoiImage(...
        sprintf('Select ROI Files for %s',subjectStruct{s}.name),...
        fullfile(subjectStruct{s}.dir,'results','roi'));
end



for s = 1:nSubjects
    % load image data
   
    disp('fetching volume definitions, please wait');
    subjectStruct{s}.volumes = spm_vol(getImageFileList(subjectStruct{s}.dir,sessionlist,args.mask));

    disp('computing volume values, please wait');
    
    [extr x y z] = calculateRoiImageData(subjectStruct{s}.volumes,subjectStruct{s}.roiFile);
    
    nVoxel = size(extr(1).dat,1);

    % calculate psth
    pstopts.des = subjectStruct{s}.des;

    disp('computing psth');
    for iVoxel = 1:nVoxel
        [ x(iVoxel) y(iVoxel) z(iVoxel)]
        rawdata = [];
        for iImage = 1:length(extr);
            tmp = extr(iImage);
            rawdata = [rawdata tmp.dat(iVoxel)];
        end
        subjectStruct{s}.pst{iVoxel} = calculatePST(args.timeline,pstopts,rawdata);
    end
    disp('done');
end

% assignin('base',SVMCROSSVAL_SUBJECTSTRUCT_NAME,subjectStruct);

end