Browse code

radius frontend enabled, fixed backend problems. radius working

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@162 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on 18/03/2009 14:50:47
Showing 6 changed files
... ...
@@ -1,27 +1,32 @@
1
-function [extr voxelcount] = calculateImageData(filenameList, voxelList, rad)
1
+function [extr voxelcount] = calculateImageData(filenameList, coordlist)
2
+
3
+vox = [];
4
+% radius = [];
5
+nCoords = size(coordlist,1);
6
+for iCoord = 1:nCoords
7
+   vox = [vox ; coordlist(iCoord).coord];
8
+%    radius = [radius , coordlist(iCoord).rad];
9
+end
10
+
2 11
 voxelcount = 0;
3 12
 
4 13
 V = filenameList;
5
-
6
-vox = voxelList;
7
-nVoxel = size(vox,1);
8 14
 nImage = numel(V);
9
-
10
-% rad = 0;
11
-
15
+nVoxel = nCoords;
12 16
 for kImage=1:nImage
13 17
     roicenter = round(inv(V(kImage).mat)*[vox, ones(nVoxel,1)]');
14
-    x = roicenter(1,:);
15
-    y = roicenter(2,:);
16
-    z = roicenter(3,:);
17
-
18
-    tmp = spm_imatrix(V(kImage).mat);
19
-    vdim = tmp(7:9);
20
-    vxrad = ceil((rad*ones(nVoxel,3))./(ones(nVoxel,1)*vdim))';
18
+%     x = roicenter(1,:);
19
+%     y = roicenter(2,:);
20
+%     z = roicenter(3,:);
21 21
 
22 22
     subvoxelcount = 0;
23 23
     for iVoxel = 1:nVoxel
24 24
 
25
+        rad = coordlist(iVoxel).rad;
26
+        tmp = spm_imatrix(V(kImage).mat);
27
+        vdim = tmp(7:9);
28
+        vxrad = ceil((rad*ones(nVoxel,3))./(ones(nVoxel,1)*vdim))';
29
+        
25 30
         if rad==0
26 31
             x = roicenter(1,iVoxel);
27 32
             y = roicenter(2,iVoxel);
... ...
@@ -1,19 +1,24 @@
1 1
 function scoords = getSubjectCoordinates(gcoords,map)
2 2
 m = java.util.HashMap ;
3 3
 
4
+%build lookuptable
4 5
 for i = 1:numel(map.names)
5 6
     key = cell2mat(map.names(i));
6 7
     val = map.coords(i,:);
7 8
     m.put(key,val);
8 9
 end
9 10
 
11
+% do the lookup
10 12
 scoords = [];
11
-
12 13
 for c = 1:numel(gcoords)
13 14
     key = strtrim(gcoords(c).name);
14 15
     val = m.get(key)';
15
-    mod = gcoords(c).mod;
16
-    scoords = [scoords; val+mod];
16
+%     mod = gcoords(c).mod;
17
+%     scoords = [scoords; val+mod];
18
+    co = struct;
19
+    co.coord = val;
20
+    co.rad = gcoords(c).rad;
21
+    scoords = [scoords; co];
17 22
 end
18 23
 
19 24
 end
20 25
\ No newline at end of file
... ...
@@ -45,7 +45,6 @@ switch task
45 45
         coordargs.eventList     = classDef.eventMatrix;
46 46
         coordargs.coords        = parseCoordinateTextField(model);
47 47
         coordargs.mask          = mask;
48
-        coordargs.radius        = getSearchlightRadius(model);
49 48
         coordargs.psthOpts      = psthOpts;
50 49
 
51 50
         
... ...
@@ -114,6 +113,9 @@ switch task
114 113
         assignin('base','decode',decode);
115 114
     case 'X-SOM'
116 115
         disp('not implemented')
116
+    case 'FBS'
117
+        disp('not implemented')
118
+        fbs.radius        = getSearchlightRadius(model);
117 119
         
118 120
 end
119 121
 
... ...
@@ -2,16 +2,23 @@ function voxelList = parseCoordinateTextField(model)
2 2
 s = get(model.txtVoxelDef,'String');
3 3
 rows = size(s,1);
4 4
 voxelList = [];
5
-    for i = 1:rows 
6
-        if all(isspace(s(i,:)))
7
-            continue;
8
-        end
9
-        line = s(i,:);
5
+for i = 1:rows
6
+    if all(isspace(s(i,:)))
7
+        continue;
8
+    end
9
+    line = s(i,:);
10
+    if (strfind(line,'+'))
11
+        % has radius
10 12
         [roi rem] = strtok(line,'+');
11
-        roimod = eval(str2mat(rem(2:end)));
12
-        coord.name = roi;
13
-        coord.mod = roimod;
14
-        voxelList = [voxelList; coord];
15
-
13
+        rad = eval(str2mat(rem(2:end)));
14
+    else
15
+        % radius set to 0
16
+        roi = line;
17
+        rad = 0;
16 18
     end
19
+    coord.name = roi;
20
+    coord.rad = rad;
21
+    voxelList = [voxelList; coord];
22
+
23
+end
17 24
 end
18 25
\ No newline at end of file
... ...
@@ -7,7 +7,6 @@ function subjectData = runCoordTable(args)
7 7
     subjects = args.subjects;
8 8
     nSubjects = numel(subjects);
9 9
     sessionlist = args.sessionList;
10
-    radius = args.radius;
11 10
     pstopts = args.psthOpts;
12 11
     
13 12
     disp(sprintf('batch processing %g subjects.',nSubjects));
... ...
@@ -26,7 +25,7 @@ function subjectData = runCoordTable(args)
26 25
         disp('fetching volume definitions, please wait');
27 26
         subjectStruct{s}.volumes = spm_vol(getImageFileList(subjectStruct{s}.dir,sessionlist,args.mask));
28 27
       
29
-        [extr nExtractedVoxel] = calculateImageData(subjectStruct{s}.volumes,subjectStruct{s}.coords,radius);
28
+        [extr nExtractedVoxel] = calculateImageData(subjectStruct{s}.volumes,subjectStruct{s}.coords);
30 29
          
31 30
         pstopts.des = subjectStruct{s}.des;
32 31
         pstopts.eventList = args.eventList;
... ...
@@ -10,7 +10,7 @@ DEFAULT.frameshiftstart = -5;
10 10
 DEFAULT.frameshiftend   = 35;
11 11
 DEFAULT.frameshiftdur   = 0;
12 12
 DEFAULT.classdefstring  = 'left,\t[9,11,13]\nright,\t[10,12,14]';
13
-DEFAULT.voxelstring     = 'SPL l + [ 0, 0, 0] \nSPL r + [ 0, 0, 0]\n';
13
+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;
... ...
@@ -200,14 +200,11 @@ function model = createFirstStepPanel(model,parent,DEFAULT)
200 200
         lPSTH       = createLabel(pPSTH, cell2mat(tl_grid(1,2)),'PSTH Range');
201 201
         lBaseline   = createLabel(pPSTH, cell2mat(tl_grid(1,3)),'Baseline');
202 202
 
203
-        lSearchligh = createLabel(pPSTH, cell2mat(tl_grid(1,5)),'Searchlight Radius');
204
-
205
-
206 203
         model.txtPSTHStart         = createTextField(pPSTH,cell2mat(tl_grid(2,2)),DEFAULT.pststart);
207 204
         model.txtPSTHEnd           = createTextField(pPSTH,cell2mat(tl_grid(3,2)),DEFAULT.pstend);
208 205
         model.txtBaselineStart     = createTextField(pPSTH,cell2mat(tl_grid(2,3)),DEFAULT.baselinestart);
209 206
         model.txtBaselineEnd       = createTextField(pPSTH,cell2mat(tl_grid(3,3)),DEFAULT.baselineend);
210
-        model.txtSearchlightRadius = createTextField(pPSTH,cell2mat(tl_grid(2,5)),DEFAULT.searchlightradius);
207
+
211 208
         
212 209
         % images
213 210
         pImage = uipanel(parent,'Title','Image Options','Position',cell2mat(main_grid(2,2)));
... ...
@@ -228,7 +225,7 @@ function model = createFirstStepPanel(model,parent,DEFAULT)
228 225
         % coordinate Table
229 226
         pVoxel = uipanel(parent,'Title','ROI','Position',cell2mat(main_grid(1,3)));
230 227
         set(pVoxel,'BackgroundColor','w');
231
-        lVoxelDef = createLabel(pVoxel, [0 0.9 1 0.1],'<ROI Name>+[offset];');
228
+        lVoxelDef = createLabel(pVoxel, [0 0.9 1 0.1],'<ROI Name> [+ radius (mm)];');
232 229
         model.txtVoxelDef = createTextField(pVoxel,[0 0 1 0.9],...
233 230
             sprintf(DEFAULT.voxelstring));
234 231
         set(model.txtVoxelDef,'HorizontalAlignment','left');
... ...
@@ -269,7 +266,7 @@ function model = createFirstStepPanel(model,parent,DEFAULT)
269 266
         set(btnRunButton1,'Callback',{@cbRunPreprocessing,model,'COORD'}); % set here, because of model.    
270 267
         set(btnRunButton1,'Enable','on');
271 268
         
272
-        btnRunButton2 = uicontrol(pButtons,'String','run full Brain Searchlight',...
269
+        btnRunButton2 = uicontrol(pButtons,'String','run full-brain Searchlight',...
273 270
             'Units','normalized','Position',[0.33 0 0.33 1]);
274 271
         set(btnRunButton2,'Callback',{@cbRunPreprocessing,model,'FBS'}); % set here, because of model.  
275 272
         set(btnRunButton2,'Enable','off');
... ...
@@ -355,12 +352,26 @@ pSOM = uipanel(parent,'Units','normalized','Position',[0.5 0.4 0.5 0.4]);
355 352
         'Units','normalized',...
356 353
         'Position',[0.0 0.0 1 0.25]);
357 354
     set(btnRunXSOM,'Enable','off');
355
+    
356
+pSearchlight = uipanel(parent,'Units','normalized','Position',[0.0 0.1 1 0.3]);
357
+    set(pSearchlight,'Title','Spatiotemporal FB classification');
358
+    set(pSearchlight,'BackgroundColor',basecolor);
359
+    
360
+    lSearchligh = createLabel(pSearchlight, [0 0.6 0.5 0.3],'Searchlight Radius');
361
+    model.txtSearchlightRadius = createTextField(pSearchlight,[0.5 0.6 0.5 0.3],DEFAULT.searchlightradius);
362
+    
363
+    btnRunFBS = uicontrol(pSearchlight,'String','run Spatiotemporal FB classification',...
364
+        'Units','normalized',...
365
+        'Position',[0.0 0.0 1 0.3]);
366
+    set(btnRunFBS,'Enable','off');
367
+    
358 368
 
359 369
 % button callbacks set here, because of model.
360 370
     set(btnRunSVM, 'Callback',{@cbRunDecode,model,'SVM'}); 
361 371
     set(btnRunXSVM,'Callback',{@cbRunDecode,model,'XSVM'}); 
362 372
     set(btnRunSOM, 'Callback',{@cbRunDecode,model,'SOM'});
363
-    set(btnRunXSOM,'Callback',{@cbRunDecode,model,'XSOM'}); 
373
+    set(btnRunXSOM,'Callback',{@cbRunDecode,model,'XSOM'});
374
+    set(btnRunFBS,'Callback',{@cbRunDecode,model,'FBS'});
364 375
 end
365 376
 
366 377
 function model = createVisualStepPanel(model,parent,DEFAULT)