nifti save functional, but latealization error (l/r flipped)
Christoph Budziszewski

Christoph Budziszewski commited on 2009-03-30 19:26:42
Zeige 1 geänderte Dateien mit 13 Einfügungen und 5 Löschungen.


git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@168 83ab2cfd-5345-466c-8aeb-2b2739fb922d
... ...
@@ -42,8 +47,8 @@ for s = 1:nSubjects
42 47
     [extr x y z] = calculateRoiImageData(volumes,subjects{s}.roiFile);
43 48
     elapsed.calcExtr = toc;
44 49
     
45
-clear volumes; %save memory ??
46
-disp('cleared volumes');
50
+% clear volumes; %save memory ??
51
+% disp('cleared volumes');
47 52
 tic
48 53
     
49 54
     nVoxel = size(extr(1).dat,1);
... ...
@@ -102,16 +107,19 @@ tic
102 107
     labelMap = timePointArgs.labelMap;
103 108
     eventList = pstopts.eventList;
104 109
     
105
-    img3D = [];
106 110
     % tmp = spm_imatrix(V(kImage).mat); %
107 111
     % vdim = tmp(7:9); % Voxel-Size
108 112
     vdim = [3,3,3.5];
109 113
     
114
+    mask_image = load_nii(subjects{s}.roiFile.fname);
115
+    
110 116
     for timeShift = 1:timeLineEnd-timeLineStart+1
111 117
     % center timepoint && relative shift
112 118
     frameStart  = floor(-globalStart+1+timeShift - 0.5*decodeDuration);
113 119
     frameEnd    = min(ceil(frameStart+decodeDuration + 0.5*decodeDuration),-globalStart+globalEnd);
114 120
 
121
+        img3D = zeros(size(mask_image)); %output image
122
+
115 123
         for iVoxel = 1:nVoxel % linear structure avoids 3D-Loop.
116 124
             % get surrounding coordinate-IDs within radius
117 125
             sphere = fbs_buildSphere(mapping,iVoxel,radius,vdim);
... ...
@@ -141,12 +149,17 @@ tic
141 149
             % save the decode value to the corresponding coordinate
142 150
 
143 151
             coord= mapping.indexToCoordMap.get(iVoxel);
144
-            img3D(coord',timeShift) = decode;
152
+            x = coord(1);
153
+            y = coord(2);
154
+            z = coord(3);
155
+            img3D(x,y,z) = decode/100; %damn percentage
156
+%             mask_image.img(x,y,z) = decode/100;
145 157
 
146 158
         end  %for each voxel
147 159
 
148
-        nii = make_nii(img3D,vdim,[],16,'decode'); %default origin
160
+        nii = make_nii(img3D,vdim,mask_image.hdr.hist.originator(1:3),16,'decode performance'); %default origin
149 161
         save_nii(nii,sprintf('TESTFILE%g',timeShift));
162
+%         save_nii(mask_image,sprintf('MTESTFILE%g',timeShift));
150 163
     
151 164
     end %for each timeslice
152 165
     display('rastering done');
153 166