fbs filename adaption, default fbs radius, delete unneded m-files
Christoph Budziszewski

Christoph Budziszewski commited on 2009-04-02 16:26:51
Zeige 7 geänderte Dateien mit 23 Einfügungen und 139 Löschungen.


git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@171 83ab2cfd-5345-466c-8aeb-2b2739fb922d
... ...
@@ -1,7 +0,0 @@
1
-function s = boolToYesNoString(bool)
2
-    if bool
3
-        s = 'yes';
4
-    else
5
-        s = 'no';
6
-    end
7
-end
8 0
\ No newline at end of file
... ...
@@ -1,55 +0,0 @@
1
-function coordinateStruct = computeCoordinates(imageStruct)
2
-%imageStruct.(someName).images
3
-%imageStruct.(someName).roiImages
4
-coordinateStruct = struct;
5
-
6
-subjectCellList = fieldnames(imageStruct);
7
-
8
-for subject = 1:length(subjectCellList)
9
-    subjectFieldName = cell2mat(subjectCellList(subject));
10
-    % ROI Image Coordinates
11
-    V  = imageStruct.(subjectFieldName).images;
12
-    Vm = imageStruct.(subjectFieldName).roiImages;
13
-    coordinateStruct.(subjectFieldName) = ...
14
-        computeRoiImageCoordinates(V,Vm);
15
-    % Parsed Voxel Definitions
16
-    coordinateStruct.(subjectFieldName) = ...
17
-        appendManualVoxelCoordinates(coordinateStruct.(subjectFieldName),V);
18
-    
19
-end
20
-end
21
-
22
-function coordinates = appendManualVoxelCoordinates(coordinateStruct,V)
23
-    coordinates =coordinateStruct;
24
-end
25
-
26
-function coordinates = computeRoiImageCoordinates(V,Vm)
27
-    nVolImage = length(V);
28
-    nRoiImage = length(Vm);
29
-    
30
-    coordinates = cell(nVolImage,1);
31
- 
32
-    for iVolImage = 1:nVolImage
33
-        coordinates{iVolImage} = [];
34
-        for jRoiImage = 1:nRoiImage
35
-            [x,y,z] = computeCoordinateVector(V(iVolImage),Vm(jRoiImage));
36
-            coordinates{iVolImage} = [coordinates{iVolImage}; x, y, z];
37
-        end
38
-    end
39
-end
40
-
41
-function [x,y,z] = computeCoordinateVector(VolumeImage,RoiImage)
42
-            x = []; y = []; z = [];
43
-            [x1 y1] = ndgrid(1:VolumeImage.dim(1),1:VolumeImage.dim(2));
44
-            for p = 1:VolumeImage.dim(3) % resample mask RoiImage in space of VolumeImage
45
-                B = spm_matrix([0 0 -p 0 0 0 1 1 1]);
46
-                M = inv(B*inv(VolumeImage.mat)*RoiImage.mat);
47
-                msk = find(spm_slice_vol(RoiImage,M,VolumeImage.dim(1:2),0));
48
-                if ~isempty(msk)
49
-                    z1 = p*ones(size(msk(:)));
50
-                    x = [x; x1(msk(:))];
51
-                    y = [y; y1(msk(:))];
52
-                    z = [z; z1];
53
-                end;
54
-            end;
55
-end
... ...
@@ -1,40 +0,0 @@
1
-function decode = fbs_calculateDecodePerformance(header,psth,svmopts)
2
-
3
-RANDOMIZE_DATAPOINTS = header.svmrnd;
4
-
5
-timeline = header.timeline;
6
-timeline.frameShiftStart = header.frameShift.frameShiftStart;
7
-timeline.frameShiftEnd   = header.frameShift.frameShiftEnd;
8
-timeline.decodeDuration  = header.frameShift.decodeDuration;
9
-
10
-timeLineStart  = timeline.frameShiftStart;
11
-timeLineEnd    = timeline.frameShiftEnd;
12
-
13
-timePointArgs.pst           = psth;
14
-timePointArgs.labelMap      = LabelMap(header.classDef.labelCells,header.classDef.conditionCells);
15
-timePointArgs.eventList     = header.classDef.eventMatrix;
16
-
17
-timePointMatrix = buildTimePointMatrix(timeline,timePointArgs);
18
-
19
-decodePerformance = [];
20
-for index = 1:timeLineEnd-timeLineStart+1
21
-
22
-    svmdata      = timePointMatrix{index}(:,2:size(timePointMatrix{index},2));
23
-    svmlabel     = timePointMatrix{index}(:,1);
24
-
25
-    if RANDOMIZE_DATAPOINTS
26
-        rndindex  = randperm(length(svmlabel));
27
-        svmdata   = svmdata(rndindex,:);
28
-        svmlabel  = svmlabel(rndindex);
29
-    end
30
-
31
-    decodePerformance = [decodePerformance; svm_single_crossval(svmlabel,svmdata,svmopts)];
32
-    
33
-    
34
-end
35
-
36
-decode  = decodePerformance;
37
-end
38
-
39
-
40
-
... ...
@@ -1,7 +0,0 @@
1
-function id = fbs_coordtable_getIndex(table,coord)
2
-if table.containsKey(coord)
3
-    id = table.get(coord);
4
-else
5
-     error('FBS:getLabel:noSuchValue','this Mapping does not contain a Value %d',condition);
6
-end
7
-end
8 0
\ No newline at end of file
... ...
@@ -1,20 +0,0 @@
1
-function voxellist = generateVoxelList(center, radius)
2
-%     cx = ROICenter(1);
3
-%     cy = ROICenter(2);
4
-%     cz = ROICenter(3);
5
-    
6
-    voxellist = [];
7
-    
8
-    cx = center(1);
9
-    cy = center(2);
10
-    cz = center(3);
11
-
12
-    for z=cz-radius+1:cz+radius-1
13
-        for y=(cy-radius+1):(cy+radius-1)
14
-            for x=(cx-radius+1):(cx+radius-1)
15
-                voxellist = [voxellist [x;y;z]];
16
-            end
17
-        end
18
-    end
19
-
20
-end
21 0
\ No newline at end of file
... ...
@@ -1,6 +1,9 @@
1 1
 function output =  runFBSImageMaskMode(header,subjectdata,fbsargs)
2 2
 addpath('NIFTI_20090325');
3 3
 
4
+savePath = fullfile('output',sprintf('%s',date))
5
+mkdir(savePath);
6
+
4 7
 args = header.args;
5 8
 
6 9
 subjects = subjectdata;
... ...
@@ -108,16 +111,24 @@ for s = 1:nSubjects
108 111
     
109 112
     % tmp = spm_imatrix(V(kImage).mat); %
110 113
     % vdim = tmp(7:9); % Voxel-Size
111
-    vdim = [3,3,3.5];
114
+    
115
+
112 116
     
113 117
     mask_image = load_nii(subjects{s}.roiFile.fname);
114 118
     
119
+    vdim = mask_image.hdr.dime.pixdim(2:4);
120
+    if mask_image.hdr.dime.pixdim(1) == 1
121
+        vdim = vdim .* [-1 1 1];
122
+    end
123
+
124
+    display(sprintf('starting timesliceing'));
125
+    
115 126
     for timeShift = 1:timeLineEnd-timeLineStart+1
116 127
     % center timepoint && relative shift
117 128
     frameStart  = floor(-globalStart+1+timeShift - 0.5*decodeDuration);
118 129
     frameEnd    = min(ceil(frameStart+decodeDuration + 0.5*decodeDuration),-globalStart+globalEnd);
119 130
 
120
-        img3D = zeros(size(mask_image)); %output image
131
+        img3D = zeros(size(mask_image)); %output image prepare
121 132
 
122 133
         for iVoxel = 1:nVoxel % linear structure avoids 3D-Loop.
123 134
             % get surrounding coordinate-IDs within radius
... ...
@@ -151,21 +162,23 @@ for s = 1:nSubjects
151 162
             x = coord(1);
152 163
             y = coord(2);
153 164
             z = coord(3);
154
-            img3D(x,y,z) = decode/100; %damn percentage
155
-%             mask_image.img(x,y,z) = decode/100;
165
+            
166
+            img3D(x,y,z) = ((decode/100)-0.5)*2; % range [-1:1]
156 167
 
157 168
         end  %for each voxel
158 169
 
159
-        nii = make_nii(img3D,vdim,mask_image.hdr.hist.originator(1:3),16,'decode performance'); %default origin
160
-        save_nii(nii,fullfile('output',sprintf('TESTFILE%g',timeShift)));
161
-%         save_nii(mask_image,sprintf('MTESTFILE%g',timeShift));
170
+        nii = make_nii(img3D,vdim,mask_image.hdr.hist.originator(1:3),16,sprintf('decode performance, time relative to onset: %g to %g sec',frameStart,frameEnd));
171
+        save_nii(nii,fullfile(savePath,sprintf('%s-%03g',subjects{s}.name,timeShift)));
162 172
     
163 173
     end %for each timeslice
164 174
     display('rastering done');
165
-    elapsed{s}.decode = toc;
166 175
 
167
-    clear pst; %save memory!
176
+    elapsed{s}.decode = toc;
168 177
     assignin('base','timing',elapsed);
178
+
179
+    %save memory!
180
+    clear pst; 
181
+    clear mask_image;
169 182
 end
170 183
 
171 184
 end
... ...
@@ -14,7 +14,7 @@ DEFAULT.voxelstring     = 'M1 l + 3 \nM1 r + 3\n';
14 14
 DEFAULT.svmoptstring    = '-s 0 -t 0 -c 1';
15 15
 DEFAULT.svmnfold        = '6';
16 16
 DEFAULT.svmrnd          = 1;
17
-DEFAULT.searchlightradius = 0;
17
+DEFAULT.searchlightradius = 3;
18 18
 
19 19
 
20 20
 DEFAULT.wd  = fullfile('d:','Analyze','Choice','24pilot');
21 21