07662323fba6e78914c6c57228dd116276b8a9ca
Christoph Budziszewski heavy CrossVal Toolbox deve...

Christoph Budziszewski authored 15 years ago

1) % filenameList (e.g. as in SPM.xY.VY)
2) % voxelList in [x y z], 1 coordinate per row, untransformed
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

3) 
Christoph Budziszewski heavy CrossVal Toolbox deve...

Christoph Budziszewski authored 15 years ago

4) function extr = calculateImageData(filenameList, voxelList, imageOpts)
5) TRANSFORM_METHOD = 'image';
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

6) 
Christoph Budziszewski refactored to arg-structs!...

Christoph Budziszewski authored 15 years ago

7) V = filenameList;
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

8) 
9) vox = voxelList;
Christoph Budziszewski refactored to arg-structs!...

Christoph Budziszewski authored 15 years ago

10) nVoxel = size(vox,1);
11) nImage = numel(V);
Christoph Budziszewski heavy CrossVal Toolbox deve...

Christoph Budziszewski authored 15 years ago

12) nRoiFiles = ;
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

13) 
Christoph Budziszewski refactored to arg-structs!...

Christoph Budziszewski authored 15 years ago

14) for kImage=1:nImage
Christoph Budziszewski heavy CrossVal Toolbox deve...

Christoph Budziszewski authored 15 years ago

15)     extr(kImage) = struct(...
16)         'dat',   repmat(NaN, [1 nVoxel]),...
17)         'mean',  repmat(NaN, [1 nVoxel]),...
18)         'sum',   repmat(NaN, [1 nVoxel]),...
19)         'nvx',   repmat(NaN, [1 nVoxel]),...
20)         'posmm', repmat(NaN, [3 nVoxel]),...
21)         'posvx', repmat(NaN, [3 nVoxel]));
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

22) 
Christoph Budziszewski refactored to arg-structs!...

Christoph Budziszewski authored 15 years ago

23)     switch TRANSFORM_METHOD
24)         case 'single'
25)             roicenter = round(inv(V(kImage).mat)*[vox, ones(nVoxel,1)]');
26)             x = roicenter(1,:);
27)             y = roicenter(2,:);
28)             z = roicenter(3,:);
29)         case 'image'
Christoph Budziszewski heavy CrossVal Toolbox deve...

Christoph Budziszewski authored 15 years ago

30)             x = []; y = []; z = [];
31)             for iRoiFile = 1:nRoiFiles
Christoph Budziszewski refactored to arg-structs!...

Christoph Budziszewski authored 15 years ago

32)                 [x1 y1] = ndgrid(1:V(k).dim(1),1:V(k).dim(2));
33)                 for p = 1:V(k).dim(3) % resample mask Vm(iRoiFile) in space of V(k)
34)                     B = spm_matrix([0 0 -p 0 0 0 1 1 1]);
35)                     M = inv(B*inv(V(k).mat)*Vm(iRoiFile).mat);
36)                     msk = find(spm_slice_vol(Vm(iRoiFile),M,V(k).dim(1:2),0));
37)                     if ~isempty(msk)
38)                         z1 = p*ones(size(msk(:)));
39)                         x = [x; x1(msk(:))];
40)                         y = [y; y1(msk(:))];
41)                         z = [z; z1];
42)                     end;
43)                 end;
44)             end
45)     end
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

46) 
Christoph Budziszewski heavy CrossVal Toolbox deve...

Christoph Budziszewski authored 15 years ago

47)     dat = spm_sample_vol(V(kImage), x, y, z,0);
48)     extr(kImage).dat(iVoxel)      = dat;
49)     extr(kImage).mean(iVoxel)     = nanmean(dat);
50)     extr(kImage).nvx(iVoxel)      = numel(dat);
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

51) end;
Christoph Budziszewski heavy CrossVal Toolbox deve...

Christoph Budziszewski authored 15 years ago

52)