private/calculateImageData.m
dec919c8
 function extr = calculateImageData(filenameList, voxelList, rad)
9478fa59
 
c54095b9
 V = filenameList;
9478fa59
 
 vox = voxelList;
c54095b9
 nVoxel = size(vox,1);
 nImage = numel(V);
9478fa59
 
dec919c8
 % rad = 0;
7a4d3666
 
c54095b9
 for kImage=1:nImage
e0049736
     roicenter = round(inv(V(kImage).mat)*[vox, ones(nVoxel,1)]');
     x = roicenter(1,:);
     y = roicenter(2,:);
     z = roicenter(3,:);
9478fa59
 
daadf09b
             tmp = spm_imatrix(V(kImage).mat);
             vdim = tmp(7:9);
             vxrad = ceil((rad*ones(nVoxel,3))./(ones(nVoxel,1)*vdim))';
9478fa59
 
e0049736
     for iVoxel = 1:nVoxel
07662323
 
e0049736
         if rad==0
c2dab886
             x = roicenter(1,iVoxel);
             y = roicenter(2,iVoxel);
             z = roicenter(3,iVoxel);
e0049736
         else
             [x y z] = ndgrid(-vxrad(1,iVoxel):sign(vdim(1)):vxrad(1,iVoxel), ...
                 -vxrad(2,iVoxel):sign(vdim(2)):vxrad(2,iVoxel), ...
                 -vxrad(3,iVoxel):sign(vdim(3)):vxrad(3,iVoxel));
             sel = (x./vxrad(1,iVoxel)).^2 + (y./vxrad(2,iVoxel)).^2 + ...
                 (z./vxrad(3,iVoxel)).^2 <= 1;
             x = roicenter(1,iVoxel)+x(sel(:));
             y = roicenter(2,iVoxel)+y(sel(:));
             z = roicenter(3,iVoxel)+z(sel(:));
         end;
 
 
         dat = spm_sample_vol(V(kImage), x, y, z,0);
daadf09b
         
         extr(kImage).dat(iVoxel,:)    = dat;
e0049736
         extr(kImage).mean(iVoxel)     = nanmean(dat);
c2dab886
         extr(kImage).nvx(iVoxel)      = numel(dat);
e0049736
     end;
c2dab886
 
 end;
9478fa59
 end