master
Christoph Budziszewski stable version for conference.

Christoph Budziszewski authored 15 years ago

1) function [extr xx yy zz] = calculateRoiImageData(filenameList,roiImageList)
Christoph Budziszewski roi image working

Christoph Budziszewski authored 15 years ago

2) 
3) V = filenameList;
4) nImage = numel(V);
5) Vm = roiImageList;
6) nRoi = numel(Vm);
7) 
8) for kImage=1:nImage
9)     x = []; y = []; z = [];
10)     dat = [];
11)     for iRoiFile = 1:nRoi
12)         [x1 y1] = ndgrid(1:V(kImage).dim(1),1:V(kImage).dim(2));
13)         for p = 1:V(kImage).dim(3) % resample mask Vm(i) in space of V(k)
14)             B = spm_matrix([0 0 -p 0 0 0 1 1 1]);
15)             M = inv(B*inv(V(kImage).mat)*Vm(iRoiFile).mat);
16)             msk = find(spm_slice_vol(Vm(iRoiFile),M,V(kImage).dim(1:2),0));
17)             if ~isempty(msk)
18)                 z1 = p*ones(size(msk(:)));
19)                 x = [x; x1(msk(:))];
20)                 y = [y; y1(msk(:))];
21)                 z = [z; z1];
22)             end
23)         end
24)         dat = [dat spm_sample_vol(V(kImage), x, y, z,0)];
Christoph Budziszewski stable version for conference.

Christoph Budziszewski authored 15 years ago

25) 
26)         if kImage == 1 % sample coordinates from first image
27)             xx = x;
28)             yy = y;
29)             zz = z;
30)         end
31)