function runROIImageMaskMode(parameterModel) loadParams.StudyID = 'CHOICE24'; loadParams.use_smoothed_image_hack = 1; loadParams.subjectCellArray = getSubjectIDString(parameterModel); imageStruct = loadImageFileNamesData(loadParams); assignin('base','imageStruct',imageStruct); % coordinateStruct = computeCoordinates(imageStruct); % assignin('base','coordinateStruct',coordinateStruct); end function extr = claculateRoiImageData(filenameList,roiImageList) V = filenameList; nImage = numel(V); Vm = roiImageList; nRoi = numel(Vm); for kImage=1:nImage x = []; y = []; z = []; for iRoiFile = 1:nRoi [x1 y1] = ndgrid(1:V(k).dim(1),1:V(k).dim(2)); for p = 1:V(k).dim(3) % resample mask Vm(i) in space of V(k) B = spm_matrix([0 0 -p 0 0 0 1 1 1]); M = inv(B*inv(V(k).mat)*Vm(iRoiFile).mat); msk = find(spm_slice_vol(Vm(iRoiFile),M,V(k).dim(1:2),0)); if ~isempty(msk) z1 = p*ones(size(msk(:))); x = [x; x1(msk(:))]; y = [y; y1(msk(:))]; z = [z; z1]; end end dat = spm_sample_vol(V(k), x, y, z,0); extr(kImage).dat(iRoiFile) = dat; end end end