possibly working version, coord-table approach.
Christoph Budziszewski

Christoph Budziszewski commited on 2009-02-06 11:55:55
Zeige 4 geänderte Dateien mit 56 Einfügungen und 39 Löschungen.


git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@126 83ab2cfd-5345-466c-8aeb-2b2739fb922d
... ...
@@ -32,12 +32,19 @@ function coordinates = computeRoiImageCoordinates(V,Vm)
32 32
     for iVolImage = 1:nVolImage
33 33
         coordinates{iVolImage} = [];
34 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)
35 42
             x = []; y = []; z = [];
36
-            [x1 y1] = ndgrid(1:V(iVolImage).dim(1),1:V(iVolImage).dim(2));
37
-            for p = 1:V(iVolImage).dim(3) % resample mask Vm(jRoiImage) in space of V(iVolImage)
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
38 45
                 B = spm_matrix([0 0 -p 0 0 0 1 1 1]);
39
-                M = inv(B*inv(V(iVolImage).mat)*Vm(jRoiImage).mat);
40
-                msk = find(spm_slice_vol(Vm(jRoiImage),M,V(iVolImage).dim(1:2),0));
46
+                M = inv(B*inv(VolumeImage.mat)*RoiImage.mat);
47
+                msk = find(spm_slice_vol(RoiImage,M,VolumeImage.dim(1:2),0));
41 48
                 if ~isempty(msk)
42 49
                     z1 = p*ones(size(msk(:)));
43 50
                     x = [x; x1(msk(:))];
... ...
@@ -45,7 +52,4 @@ function coordinates = computeRoiImageCoordinates(V,Vm)
45 52
                     z = [z; z1];
46 53
                 end;
47 54
             end;
48
-            coordinates{iVolImage} = [coordinates{iVolImage}; x, y, z];
49
-        end
50
-    end
51 55
 end
... ...
@@ -0,0 +1,22 @@
1
+function defineGlobals()
2
+%define global constants
3
+global SVMCROSSVAL_USE_DRIVE_CHECK_HACK;
4
+%enables subroutine to check if image path starts with 'D'
5
+SVMCROSSVAL_USE_DRIVE_CHECK_HACK                  = 1;  
6
+
7
+global SVMCROSSVAL_CROSSVAL_METHOD_DEF;
8
+% supported classification methods
9
+SVMCROSSVAL_CROSSVAL_METHOD_DEF.svmcrossval       = 'svm crossval';
10
+SVMCROSSVAL_CROSSVAL_METHOD_DEF.classPerformance  = 'svm class performance';
11
+SVMCROSSVAL_CROSSVAL_METHOD_DEF.crossSubject      = 'svm across subject testing';
12
+SVMCROSSVAL_CROSSVAL_METHOD_DEF.somTraining       = 'som Training';
13
+
14
+global SVMCROSSVAL_VOXEL_SELECTION_MODE_DEF;
15
+% supported voxel selection methods
16
+SVMCROSSVAL_VOXEL_SELECTION_MODE_DEF.manualGui    = 'manually defined in GUI';
17
+SVMCROSSVAL_VOXEL_SELECTION_MODE_DEF.roiImage     = 'use ROI image by pop-up image selector';
18
+
19
+global SVMCROSSVAL_SUBJECT_PREFIX;
20
+% internally used to prefix subject-ids starting with numbers.
21
+SVMCROSSVAL_SUBJECT_PREFIX                        = 'subject';
22
+end
0 23
\ No newline at end of file
... ...
@@ -1,22 +1,27 @@
1
-function retVal = main(action,parameterModel)
2
-
3
-% if nargs ~=2 
4
-%     error('SVMCrossVal:main:argument','wrong number of arguments');
5
-% end
6
-
7
-StudyID = 'CHOICE24';
8
-
1
+function main(action,parameterModel)
2
+timeline = getTimeLineParams(parameterModel);
3
+switch action
4
+    case 'COORD-LOOKUP-TABLE'
5
+        runCoordTable(timeline,parameterModel);
6
+    case 'ROI-IMAGE-MASK'
7
+        runROIImageMaskMode(parameterModel)
8
+    case 'FULL-BRAIN'
9
+        error('SVMCrossVal:main:notImplemented','Feature not yet implemented');
10
+    otherwise 
11
+        error('SVMCrossVal:main:actionError','Wrong ''action''. Use the GUI.');
12
+end
13
+end
9 14
 
10
-        loadParams.StudyID = StudyID;
15
+function runROIImageMaskMode(parameterModel)
16
+        loadParams.StudyID = 'CHOICE24';
11 17
         loadParams.use_smoothed_image_hack = 1;
12 18
         loadParams.subjectCellArray = getSubjectIDString(parameterModel);
13 19
 
14 20
         imageStruct = loadImageFileNamesData(loadParams);
15 21
         assignin('base','imageStruct',imageStruct);
16 22
         
17
-        coordinateStruct = computeCoordinates(imageStruct);
18
-        assignin('base','coordinateStruct',coordinateStruct);
19
-
23
+%         coordinateStruct = computeCoordinates(imageStruct);
24
+%         assignin('base','coordinateStruct',coordinateStruct);
20 25
 end
21 26
 
22 27
 % generate parameter structs for subroutines
... ...
@@ -1,25 +1,8 @@
1 1
 function spm_SVMCrossVal(varargin)
2 2
 
3
-%define global constants
4
-global SVMCROSSVAL_USE_DRIVE_CHECK_HACK;
5
-%enables subroutine to check if image path starts with 'D'
6
-SVMCROSSVAL_USE_DRIVE_CHECK_HACK                  = 1;  
7
-
8
-global SVMCROSSVAL_CROSSVAL_METHOD_DEF;
9
-% supported classification methods
10
-SVMCROSSVAL_CROSSVAL_METHOD_DEF.svmcrossval       = 'svm crossval';
11
-SVMCROSSVAL_CROSSVAL_METHOD_DEF.classPerformance  = 'svm class performance';
12
-SVMCROSSVAL_CROSSVAL_METHOD_DEF.crossSubject      = 'svm across subject testing';
13
-SVMCROSSVAL_CROSSVAL_METHOD_DEF.somTraining       = 'som Training';
14
-
15
-global SVMCROSSVAL_VOXEL_SELECTION_MODE_DEF;
16
-% supported voxel selection methods
17
-SVMCROSSVAL_VOXEL_SELECTION_MODE_DEF.manualGui    = 'manually defined in GUI';
18
-SVMCROSSVAL_VOXEL_SELECTION_MODE_DEF.roiImage     = 'use ROI image by pop-up image selector';
19
-
20
-global SVMCROSSVAL_SUBJECT_PREFIX;
21
-% internally used to prefix subject-ids starting with numbers.
22
-SVMCROSSVAL_SUBJECT_PREFIX                        = 'subject';
3
+SVMCROSSVAL_BASEDIR = fullfile('D:','Analyse','Choice');
4
+
5
+defineGlobals();
23 6
 
24 7
 switch nargin
25 8
 case 0
... ...
@@ -32,6 +15,9 @@ error('spm_SVMCrossVal:main','wrong nargin');
32 15
 end
33 16
 end
34 17
 
18
+function loadStudies(basedir)
19
+
20
+end
35 21
 
36 22
 
37 23
 
38 24