Browse code

subject list from filesystem, image mask list from filesystem

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

Christoph Budziszewski authored on 13/02/2009 14:57:00
Showing 7 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,14 @@
1
+function imageMask = imageMaskNames(subjectDir)
2
+
3
+filter = '^.*\.hdr$';
4
+[files, dirs] = spm_select('List', fullfile(subjectDir,'a'), filter);
5
+
6
+for i = 1:length(files)
7
+%     rfiles = regexpi(files(i,:),'^.*.-','match')
8
+    files(i,:);
9
+    token{i} = strtok(files(i,:),'-');
10
+end
11
+
12
+imageMask = unique(token);
13
+
14
+end
0 15
\ No newline at end of file
1 16
new file mode 100644
... ...
@@ -0,0 +1,10 @@
1
+function dirnames = listDirNames(wd)
2
+dirlist = listDirs(wd);
3
+ndirs = numel(dirlist);
4
+dirnames = cell(1,ndirs);
5
+
6
+for i = 1:ndirs
7
+    dirnames{i}=dirlist{i}.name;
8
+end
9
+
10
+end
0 11
\ No newline at end of file
... ...
@@ -4,7 +4,7 @@ switch action
4 4
     case 'COORD-LOOKUP-TABLE'
5 5
         runCoordTable(timeline,parameterModel);
6 6
     case 'ROI-IMAGE-MASK'
7
-        runROIImageMaskMode(parameterModel);
7
+        runROIImageMaskMode(timeline,parameterModel);
8 8
         disp('DONE');
9 9
     case 'FULL-BRAIN'
10 10
         error('SVMCrossVal:main:notImplemented','Feature not yet implemented');
... ...
@@ -1,11 +1,12 @@
1 1
 function runCoordTable(timeline,varargin)
2
+        paramModel = varargin{1};
3
+        
4
+global SVMCROSSVAL_CROSSVAL_METHOD_DEF;
5
+global SVMCROSSVAL_VOXEL_SELECTION_MODE_DEF;
2 6
 
3
-global CROSSVAL_METHOD_DEF;
4
-global VOXEL_SELECTION_MODE_DEF;
5 7
 
6
-        paramModel = varargin{1};
7 8
         %PROJECT_BASE_PATH = 'D:\Analyze\Stimolos';
8
-        PROJECT_BASE_PATH = 'D:\Analyze\Choice\24pilot';
9
+        PROJECT_BASE_PATH = paramModel.baseDir;
9 10
         PROJECT_RESULT_PATH = 'results\SPM.mat';
10 11
 
11 12
 
... ...
@@ -23,9 +24,9 @@ global VOXEL_SELECTION_MODE_DEF;
23 24
         % common params
24 25
         calculateParams  = struct;
25 26
         
26
-%         calculateParams.CROSSVAL_METHOD_DEF = CROSSVAL_METHOD_DEF;
27
-        calculateParams.CROSSVAL_METHOD      = CROSSVAL_METHOD_DEF.svmcrossval;
28
-        calculateParams.VOXEL_SELECTION_MODE = VOXEL_SELECTION_MODE_DEF.roiImage;
27
+%         calculateParams.SVMCROSSVAL_CROSSVAL_METHOD_DEF = SVMCROSSVAL_CROSSVAL_METHOD_DEF;
28
+        calculateParams.CROSSVAL_METHOD      = SVMCROSSVAL_CROSSVAL_METHOD_DEF.svmcrossval;
29
+        calculateParams.VOXEL_SELECTION_MODE = SVMCROSSVAL_VOXEL_SELECTION_MODE_DEF.roiImage;
29 30
         calculateParams.PROJECT_BASE_PATH    = PROJECT_BASE_PATH;
30 31
         calculateParams.PROJECT_RESULT_PATH  = PROJECT_RESULT_PATH;
31 32
         
... ...
@@ -54,7 +55,7 @@ global VOXEL_SELECTION_MODE_DEF;
54 55
 
55 56
         plotParams                   = struct;
56 57
         
57
-%         plotParams.CROSSVAL_METHOD_DEF = CROSSVAL_METHOD_DEF;
58
+%         plotParams.SVMCROSSVAL_CROSSVAL_METHOD_DEF = SVMCROSSVAL_CROSSVAL_METHOD_DEF;
58 59
         plotParams.CROSSVAL_METHOD     = calculateParams.CROSSVAL_METHOD;
59 60
         
60 61
         plotParams.nClasses          = length(calculateParams.classList);
... ...
@@ -1,4 +1,4 @@
1
-function runROIImageMaskMode(parameterModel)
1
+function runROIImageMaskMode(timeline,parameterModel)
2 2
         loadParams.StudyID = 'CHOICE24';
3 3
         loadParams.use_smoothed_image_hack = 1;
4 4
         loadParams.subjectCellArray = getSubjectIDString(parameterModel);
5 5
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+function model = scanDirs(model)
2
+disp('scan dir');
3
+subjectNames = listDirNames(model.baseDir);
4
+
5
+set(model.subjectSelector,'String',subjectNames);
6
+set(model.subjectSelector,'UserData',subjectNames);
7
+set(model.subjectSelector,'Value',model.selectedSubject);
8
+
9
+subjectNames(model.selectedSubject)
10
+imageMask = imageMaskNames(fullfile(model.baseDir,cell2mat(subjectNames(model.selectedSubject))));
11
+
12
+set(model.imageTypeSelection,'String',imageMask);
13
+set(model.imageTypeSelection,'UserData',imageMask);
14
+
15
+
16
+end
0 17
\ No newline at end of file
... ...
@@ -1,6 +1,6 @@
1 1
 function ui_main(varargin)
2 2
 
3
-DEFAULT.selectedSubject = 1;
3
+DEFAULT.selectedSubject = 2;
4 4
 DEFAULT.smoothed        = 1;
5 5
 DEFAULT.multisubject    = 'single';
6 6
 DEFAULT.pststart        = -15;
... ...
@@ -16,6 +16,8 @@ DEFAULT.svmoptstring    = '-s 0 -t 0 -c 1';
16 16
 DEFAULT.svmnfold        = '6';
17 17
 DEFAULT.searchlightradius = 3;
18 18
 
19
+DEFAULT.wd  = fullfile('d:','Analyze','Choice','24pilot');
20
+
19 21
 %  Initialize and hide the GUI as it is being constructed.
20 22
     frameWidth=450;
21 23
     frameHeight=600;
... ...
@@ -33,9 +35,11 @@ DEFAULT.searchlightradius = 3;
33 35
     set(pFirstStep,'BackgroundColor','w');
34 36
     set(pFirstStep,'Units','normalized');
35 37
     
36
-
37
-    model = createFirstStepPanel(pFirstStep,DEFAULT);
38
-    assignin('base','model',model);
38
+    model = struct;
39
+    model.baseDir = DEFAULT.wd;
40
+    model.selectedSubject = DEFAULT.selectedSubject;
41
+    model = createFirstStepPanel(model,pFirstStep,DEFAULT);
42
+    
39 43
     
40 44
     %Classification Step
41 45
     secondStepBaseColor = 'w';
... ...
@@ -43,13 +47,24 @@ DEFAULT.searchlightradius = 3;
43 47
     set(pSecondStep,'BackgroundColor',secondStepBaseColor);
44 48
 
45 49
     
46
-    model2 = createSecondStepPanel(pSecondStep,DEFAULT,model,secondStepBaseColor);
47
-    assignin('base','model2',model2);
50
+    model = createSecondStepPanel(model,pSecondStep,DEFAULT,secondStepBaseColor);
48 51
 
49 52
     set(frame,'Visible','on');
53
+
54
+    % fill with data
55
+    model = scanDirs(model);
56
+    assignin('base','model',model);
57
+    
58
+
59
+end
60
+
61
+function model = cbSetBaseDir(model,newDir)
62
+model.baseDir = newDir;
50 63
 end
51 64
 
52
-function model = createSecondStepPanel(parent,DEFAULT,model1,basecolor)
65
+
66
+
67
+function model = createSecondStepPanel(model,parent,DEFAULT,basecolor)
53 68
     
54 69
 pSVM = uipanel(parent,'Units','normalized','Position',[0 0.0 0.5 1]);
55 70
     set(pSVM,'Title','SVM Classification');
... ...
@@ -75,34 +90,31 @@ pSOM = uipanel(parent,'Units','normalized','Position',[0.5 0.0 0.5 1]);
75 90
         set(model.txtSOMnfold,'Enable','off');
76 91
     createLabel(pSOM,[0.5 0.50 0.5 0.25 ],'-Fold CrossVal');
77 92
 
78
-
79
-    
80
-    
81 93
     btnRunSVM = uicontrol(pSVM,'String','run SVM Crossvalidation',...
82 94
         'Units','normalized',...
83 95
         'Position',[0 0.25 1 0.25]);
84
-    set(btnRunSVM,'Callback',{@cbRunSVM,model1,model}); % set here, because of model.
96
+    set(btnRunSVM,'Callback',{@cbRunSVM,model}); % set here, because of model.
85 97
     
86 98
     btnRunXSVM = uicontrol(pSVM,'String','run SVM X-Subject validation',...
87 99
         'Units','normalized',...
88 100
         'Position',[0 0.0 1 0.25]);
89
-    set(btnRunXSVM,'Callback',{@cbRunXSVM,model1,model}); % set here, because of model.
101
+    set(btnRunXSVM,'Callback',{@cbRunXSVM,model}); % set here, because of model.
90 102
     set(btnRunXSVM,'Enable','off');
91 103
     
92 104
     btnRunSOM = uicontrol(pSOM,'String','run SOM Crossvalidation',...
93 105
         'Units','normalized',...
94 106
     'Position',[0.0 0.25 1 0.25]);
95
-    set(btnRunSOM,'Callback',{@cbRunSOM,model1,model}); % set here, because of model.
107
+    set(btnRunSOM,'Callback',{@cbRunSOM,model}); % set here, because of model.
96 108
     set(btnRunSOM,'Enable','off');
97 109
 
98 110
     btnRunXSOM = uicontrol(pSOM,'String','run SOM X-Subject validation',...
99 111
         'Units','normalized',...
100 112
         'Position',[0.0 0.0 1 0.25]);
101
-    set(btnRunXSOM,'Callback',{@cbRunXSOM,model1,model}); % set here, because of model.
113
+    set(btnRunXSOM,'Callback',{@cbRunXSOM,model}); % set here, because of model.
102 114
     set(btnRunXSOM,'Enable','off');
103 115
 end
104 116
 
105
-function model = createFirstStepPanel(parent,DEFAULT)
117
+function model = createFirstStepPanel(model,parent,DEFAULT)
106 118
 
107 119
     main_grid = cell(2,4);
108 120
     main_grid{1,1} = [0 0.7 0.4 0.3];
... ...
@@ -115,13 +127,17 @@ function model = createFirstStepPanel(parent,DEFAULT)
115 127
     main_grid{2,3} = [0.5 0.1 0.5 0.4];
116 128
     
117 129
     %Subjects
118
-    subjectList = {'Subj1','Subj2','Subj3','Subj4'};
119
-    model.subjectSelector = uicontrol(parent,'Style','listbox',...
130
+    pSubject = uipanel(parent,'Units','normalized','Position',cell2mat(main_grid(1,1)));
131
+    set(pSubject,'Title','Subjects');
132
+    set(pSubject,'BackgroundColor','w');
133
+    
134
+    subjectList = {'DUMMY Subj1','DUMMY Subj2','DUMMY Subj3','DUMMY Subj4'};
135
+    model.subjectSelector = uicontrol(pSubject,'Style','listbox',...
120 136
                     'Min',1, 'Max',3,...
121 137
                     'String',subjectList,...
122 138
                     'UserData',subjectList,...
123 139
                     'Units','normalized',...
124
-                    'Position',cell2mat(main_grid(1,1)));
140
+                    'Position',[0 0 1 1]);
125 141
     set(model.subjectSelector,'BackgroundColor','w');
126 142
     
127 143
     %Classes
... ...
@@ -154,48 +170,48 @@ function model = createFirstStepPanel(parent,DEFAULT)
154 170
         grid_h = 0.16;
155 171
         grid_w = 0.3;
156 172
         
157
-        grid = cell([3 6]);
158
-        grid{2,1} = [0.0 0.83 grid_w grid_h];
159
-        grid{2,1} = [0.4 0.83 grid_w grid_h];
160
-        grid{3,1} = [0.7 0.83 grid_w grid_h];
173
+        tl_grid = cell([3 6]);
174
+        tl_grid{2,1} = [0.0 0.83 grid_w grid_h];
175
+        tl_grid{2,1} = [0.4 0.83 grid_w grid_h];
176
+        tl_grid{3,1} = [0.7 0.83 grid_w grid_h];
161 177
         
162
-        grid{1,2} = [0.0 0.66 grid_w grid_h];
163
-        grid{2,2} = [0.4 0.66 grid_w grid_h];
164
-        grid{3,2} = [0.7 0.66 grid_w grid_h];
178
+        tl_grid{1,2} = [0.0 0.66 grid_w grid_h];
179
+        tl_grid{2,2} = [0.4 0.66 grid_w grid_h];
180
+        tl_grid{3,2} = [0.7 0.66 grid_w grid_h];
165 181
 
166
-        grid{1,3} = [0.0 0.5 grid_w grid_h];
167
-        grid{2,3} = [0.4 0.5 grid_w grid_h];
168
-        grid{3,3} = [0.7 0.5 grid_w grid_h];
182
+        tl_grid{1,3} = [0.0 0.5 grid_w grid_h];
183
+        tl_grid{2,3} = [0.4 0.5 grid_w grid_h];
184
+        tl_grid{3,3} = [0.7 0.5 grid_w grid_h];
169 185
         
170
-        grid{1,4} = [0.0 0.33 grid_w grid_h];
171
-        grid{2,4} = [0.4 0.33 grid_w grid_h];
172
-        grid{3,4} = [0.7 0.33 grid_w grid_h];
186
+        tl_grid{1,4} = [0.0 0.33 grid_w grid_h];
187
+        tl_grid{2,4} = [0.4 0.33 grid_w grid_h];
188
+        tl_grid{3,4} = [0.7 0.33 grid_w grid_h];
173 189
 
174
-        grid{1,5} = [0.0 0.16 0.5 grid_h];
175
-        grid{2,5} = [0.5 0.16 grid_w grid_h];
176
-        grid{3,5} = [0.75 0.16 grid_w grid_h];
190
+        tl_grid{1,5} = [0.0 0.16 0.5 grid_h];
191
+        tl_grid{2,5} = [0.5 0.16 grid_w grid_h];
192
+        tl_grid{3,5} = [0.75 0.16 grid_w grid_h];
177 193
         
178
-        grid{1,6} = [0.0 0.0 0.5 grid_h];
179
-        grid{2,6} = [0.5 0.0 grid_w grid_h];
180
-        grid{3,6} = [0.75 0.0 grid_w grid_h];
181
-
182
-        lStart      = createLabel(pPSTH, cell2mat(grid(2,1)) ,'Start [sec]');
183
-        lEnd        = createLabel(pPSTH, cell2mat(grid(3,1)) ,'End [sec]');
184
-        lPSTH       = createLabel(pPSTH, cell2mat(grid(1,2)),'PSTH Range');
185
-        lBaseline   = createLabel(pPSTH, cell2mat(grid(1,3)),'Baseline');
186
-        lFrameShift = createLabel(pPSTH, cell2mat(grid(1,4)),'Frame Shift');
187
-        lFramsSize  = createLabel(pPSTH, cell2mat(grid(1,5)),'Frame Size');
188
-        lSearchligh = createLabel(pPSTH, cell2mat(grid(1,6)),'Searchlight Radius');
189
-
190
-
191
-        model.txtPSTHStart         = createTextField(pPSTH,cell2mat(grid(2,2)),DEFAULT.pststart);
192
-        model.txtPSTHEnd           = createTextField(pPSTH,cell2mat(grid(3,2)),DEFAULT.pstend);
193
-        model.txtBaselineStart     = createTextField(pPSTH,cell2mat(grid(2,3)),DEFAULT.baselinestart);
194
-        model.txtBaselineEnd       = createTextField(pPSTH,cell2mat(grid(3,3)),DEFAULT.baselineend);
195
-        model.txtFrameShiftStart   = createTextField(pPSTH,cell2mat(grid(2,4)),DEFAULT.frameshiftstart);
196
-        model.txtFrameShiftEnd     = createTextField(pPSTH,cell2mat(grid(3,4)),DEFAULT.frameshiftend);
197
-        model.txtFrameShiftDur     = createTextField(pPSTH,cell2mat(grid(2,5)),DEFAULT.frameshiftdur);
198
-        model.txtSearchlightRadius = createTextField(pPSTH,cell2mat(grid(2,6)),DEFAULT.searchlightradius);
194
+        tl_grid{1,6} = [0.0 0.0 0.5 grid_h];
195
+        tl_grid{2,6} = [0.5 0.0 grid_w grid_h];
196
+        tl_grid{3,6} = [0.75 0.0 grid_w grid_h];
197
+
198
+        lStart      = createLabel(pPSTH, cell2mat(tl_grid(2,1)) ,'Start [sec]');
199
+        lEnd        = createLabel(pPSTH, cell2mat(tl_grid(3,1)) ,'End [sec]');
200
+        lPSTH       = createLabel(pPSTH, cell2mat(tl_grid(1,2)),'PSTH Range');
201
+        lBaseline   = createLabel(pPSTH, cell2mat(tl_grid(1,3)),'Baseline');
202
+        lFrameShift = createLabel(pPSTH, cell2mat(tl_grid(1,4)),'Frame Shift');
203
+        lFramsSize  = createLabel(pPSTH, cell2mat(tl_grid(1,5)),'Frame Size');
204
+        lSearchligh = createLabel(pPSTH, cell2mat(tl_grid(1,6)),'Searchlight Radius');
205
+
206
+
207
+        model.txtPSTHStart         = createTextField(pPSTH,cell2mat(tl_grid(2,2)),DEFAULT.pststart);
208
+        model.txtPSTHEnd           = createTextField(pPSTH,cell2mat(tl_grid(3,2)),DEFAULT.pstend);
209
+        model.txtBaselineStart     = createTextField(pPSTH,cell2mat(tl_grid(2,3)),DEFAULT.baselinestart);
210
+        model.txtBaselineEnd       = createTextField(pPSTH,cell2mat(tl_grid(3,3)),DEFAULT.baselineend);
211
+        model.txtFrameShiftStart   = createTextField(pPSTH,cell2mat(tl_grid(2,4)),DEFAULT.frameshiftstart);
212
+        model.txtFrameShiftEnd     = createTextField(pPSTH,cell2mat(tl_grid(3,4)),DEFAULT.frameshiftend);
213
+        model.txtFrameShiftDur     = createTextField(pPSTH,cell2mat(tl_grid(2,5)),DEFAULT.frameshiftdur);
214
+        model.txtSearchlightRadius = createTextField(pPSTH,cell2mat(tl_grid(2,6)),DEFAULT.searchlightradius);
199 215
         
200 216
         % images
201 217
         pImage = uipanel(parent,'Title','Image Options','Position',cell2mat(main_grid(2,2)));
... ...
@@ -203,7 +219,7 @@ function model = createFirstStepPanel(parent,DEFAULT)
203 219
 
204 220
         createLabel(pImage,[0.0 0.5 1 0.5],'Select Image Base');
205 221
         
206
-        imageRegExList = {'swrf*.IMG','wrf*.IMG'};
222
+        imageRegExList = {'DUMMY swrf*.IMG','DUMMY wrf*.IMG'};
207 223
         model.imageTypeSelection = uicontrol(pImage,'Style','popupmenu',...
208 224
         'Units','normalized',...
209 225
         'Position',[0.0 0.0 1 0.5],...
... ...
@@ -229,7 +245,7 @@ function model = createFirstStepPanel(parent,DEFAULT)
229 245
         set(pNorm,'BackgroundColor','w');
230 246
         
231 247
         createLabel(pNorm,[0 0.75 1 0.25],'PST Normalization');
232
-        norm1Model = {'norm A','norm B'};
248
+        norm1Model = {'DUMMY norm A','DUMMY norm B'};
233 249
         model.selNormPST = uicontrol(pNorm,'Style','popupmenu',...
234 250
             'Units','normalized',...
235 251
             'Position',[0.0 0.5 1 0.25],...
... ...
@@ -239,7 +255,7 @@ function model = createFirstStepPanel(parent,DEFAULT)
239 255
          set(model.selNormPST,'BackgroundColor','w');   
240 256
         
241 257
         createLabel(pNorm,[0 0.25 1 0.25],'Class-Grouping Normalization');
242
-        norm2Model = {'norm X','norm Y'};
258
+        norm2Model = {'DUMMY norm X','DUMMY norm Y'};
243 259
         model.selNormClass = uicontrol(pNorm,'Style','popupmenu',...
244 260
             'Units','normalized',...
245 261
             'Position',[0.0 0.0 1 0.25],...
... ...
@@ -258,7 +274,8 @@ function model = createFirstStepPanel(parent,DEFAULT)
258 274
         
259 275
         btnRunButton2 = uicontrol(pButtons,'String','run full Brain Searchlight',...
260 276
             'Units','normalized','Position',[0.33 0 0.33 1]);
261
-        set(btnRunButton2,'Callback',{@cbRunFBS,model}); % set here, because of model.    
277
+        set(btnRunButton2,'Callback',{@cbRunFBS,model}); % set here, because of model.  
278
+        set(btnRunButton2,'Enable','off');
262 279
         
263 280
         btnRunButton3 = uicontrol(pButtons,'String','run ROI-Image processing',...
264 281
             'Units','normalized','Position',[0.66 0 0.33 1]);
... ...
@@ -268,17 +285,14 @@ end
268 285
 
269 286
 function cbRunCoordTable(src,evnt,model)
270 287
     display('RUN Coord-Table Mode');
271
-    assignin('base','model1',model);
272 288
     main('COORD-LOOKUP-TABLE',model);
273 289
 end
274 290
 function cbRunROIImage(src,evnt,model)
275 291
     display('RUN Image-Mask Mode');
276
-    assignin('base','model1',model);
277 292
     main('ROI-IMAGE-MASK', model);
278 293
 end
279 294
 function cbRunFBS(src,evnt,model)
280 295
     display('RUN Full Brain Searchlight Mode');
281
-    assignin('base','model1',model);
282 296
     display('not implemented.');
283 297
 end
284 298