c54095b9ccdbc0ca2c1a01b6f81cf5f77ae15007
Christoph Budziszewski refactored to arg-structs!...

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

4) function extr = calculateImageData(filenameList, voxelList)
5) %function extr = calculateImageData(voxelList,des,smoothed)
6) % global USE_DRIVE_CHECK_HACK;
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

8) % dtype='PSTH';
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

10) % switch dtype 
11) %     case 'PSTH'
12) %         V=des.xY.VY;
13) %     case 'betas'
14) %         V=des.Vbeta;
15) % end;
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

17) % if USE_DRIVE_CHECK_HACK
18) % if V(1).fname(1)~='D'
19) %      for z=1:length(V) % Change Drive Letter - HACK!
20) %       	V(z).fname(1) = 'D';
21) %      end; 
22) % end
23) % end
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

25) % if (~smoothed)
26) %   for z=1:length(V) % Change smoothed Filename - HACK!
27) %       % D:....SUBJECTID\session\swfanders...
28) %       % D:....SUBJECTID\session\wfanders...
29) %       tmp = findstr(filesep,V(z).fname);
30) %       V(z).fname = strcat(V(z).fname(1:tmp(end)),V(z).fname(tmp(end)+2:end));
31) %   end;
32) % end
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

35) 
36) vox = voxelList;
Christoph Budziszewski refactored to arg-structs!...

Christoph Budziszewski authored 15 years ago

37) nVoxel = size(vox,1);
38) nImage = numel(V);
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

40) for kImage=1:nImage
41) 	extr(kImage) = struct(...
42)         'val',   repmat(NaN, [1 nVoxel]),...
43) 		'mean',  repmat(NaN, [1 nVoxel]),...
44) 		'sum',   repmat(NaN, [1 nVoxel]),...
45) 		'nvx',   repmat(NaN, [1 nVoxel]),...
46) 		'posmm', repmat(NaN, [3 nVoxel]),...
47) 		'posvx', repmat(NaN, [3 nVoxel]));
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

49)     switch TRANSFORM_METHOD
50)         case 'single'
51)             roicenter = round(inv(V(kImage).mat)*[vox, ones(nVoxel,1)]');
52)             x = roicenter(1,:);
53)             y = roicenter(2,:);
54)             z = roicenter(3,:);
55)         case 'image'
56)              x = []; y = []; z = [];
57)             for iRoiFile = 1:nRoiFiles 
58)                 [x1 y1] = ndgrid(1:V(k).dim(1),1:V(k).dim(2));
59)                 for p = 1:V(k).dim(3) % resample mask Vm(iRoiFile) in space of V(k)
60)                     B = spm_matrix([0 0 -p 0 0 0 1 1 1]);
61)                     M = inv(B*inv(V(k).mat)*Vm(iRoiFile).mat);
62)                     msk = find(spm_slice_vol(Vm(iRoiFile),M,V(k).dim(1:2),0));
63)                     if ~isempty(msk)
64)                         z1 = p*ones(size(msk(:)));
65)                         x = [x; x1(msk(:))];
66)                         y = [y; y1(msk(:))];
67)                         z = [z; z1];
68)                     end;
69)                 end;
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

71)             end
72)     end
73)     
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

75) 	for iVoxel = 1:nVoxel
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

76) 
77) %         if rad==0
Christoph Budziszewski refactored to arg-structs!...

Christoph Budziszewski authored 15 years ago

78)             x = roicenter(1,iVoxel);
79)             y = roicenter(2,iVoxel);
80)             z = roicenter(3,iVoxel);
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

81) %         else
Christoph Budziszewski refactored to arg-structs!...

Christoph Budziszewski authored 15 years ago

82) %             tmp = spm_imatrix(V(kImage).mat);
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

83) %             vdim = tmp(7:9);
Christoph Budziszewski refactored to arg-structs!...

Christoph Budziszewski authored 15 years ago

84) %             vxrad = ceil((rad*ones(1,3))./(ones(nVoxel,1)*vdim))';
85) %             [x y z] = ndgrid(-vxrad(1,iVoxel):sign(vdim(1)):vxrad(1,iVoxel), ...
86) %                       -vxrad(2,iVoxel):sign(vdim(2)):vxrad(2,iVoxel), ...
87) %                       -vxrad(3,iVoxel):sign(vdim(3)):vxrad(3,iVoxel));
88) %             sel = (x./vxrad(1,iVoxel)).^2 + (y./vxrad(2,iVoxel)).^2 + ...
89) %                   (z./vxrad(3,iVoxel)).^2 <= 1;
90) %             x = roicenter(1,iVoxel)+x(sel(:));
91) %             y = roicenter(2,iVoxel)+y(sel(:));
92) %             z = roicenter(3,iVoxel)+z(sel(:));
Christoph Budziszewski kleine änderungen code move

Christoph Budziszewski authored 15 years ago

93) %         end;
94) 
95) 
Christoph Budziszewski refactored to arg-structs!...

Christoph Budziszewski authored 15 years ago

96) 		dat = spm_sample_vol(V(kImage), x, y, z,0);
97)         extr(kImage).dat(iVoxel)      = dat;
98) 		extr(kImage).mean(iVoxel)     = nanmean(dat);
99)         extr(kImage).nvx(iVoxel)      = numel(dat);