6985c69e8d9d17871756db748c1f69df79f2efa4
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

1) function spm_SVMCrossVal
2) 
3) 
4) %  Initialize and hide the GUI as it is being constructed.
5)     frameWidth=450;
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

6)     frameHeight=600;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

7)     frame = figure('Visible','off','Position',[0,0,frameWidth,frameHeight]);
8)     movegui(frame,'west'); % get this thing visible on smaller displays.
9)     
10)     set(frame,'Name','SVMCrossVal Decode Performance 4 SPM');
11)     set(frame,'NumberTitle','off');
12)     set(frame,'MenuBar','none');
13)     set(frame,'Color',get(0,'defaultUicontrolBackgroundColor'));
14)     set(frame,'Resize','off');
15)     set(frame,'Units','normalize');
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

16)     
17)     
18)     model.subjectMap = SubjectRoiMapping;
19)     nElementRows = 24;
20)     optionLineHeight = 1.0/nElementRows;
21)     controlElementHeight=optionLineHeight*(1.0/1.5)*frameHeight;
Christoph Budziszewski multi-subject support

Christoph Budziszewski authored 15 years ago

22)     pSubject     = uipanel(frame,'Title','Subject',          'Position',[0 optionLineHeight*19 frameWidth optionLineHeight*5]);
23)     pPSTH        = uipanel(frame,'Title','PSTH Options',     'Position',[0 optionLineHeight*14 frameWidth optionLineHeight*5]); 
24)     pCLASS       = uipanel(frame,'Title','Class Definitions','Position',[0 optionLineHeight*9  frameWidth optionLineHeight*5]); 
25)     pVOXEL       = uipanel(frame,'Title','Voxel Selector',   'Position',[0 optionLineHeight*3  frameWidth optionLineHeight*6]); 
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

26)     pSVM         = uipanel(frame,'Title','SVM Options',      'Position',[0 optionLineHeight*1  frameWidth optionLineHeight*2]); 
27)     btnRunButton = uicontrol(frame,'Tag','run','String','run decode-performance visualiser','Position',[2 optionLineHeight*0  frameWidth controlElementHeight*1.6]);
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

28) 
29) 
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

30)     % Subject
31)     firstColumn  =  5.00;
32)     firstRow     =  1.00 * controlElementHeight;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

33)     
Christoph Budziszewski multi-subject support

Christoph Budziszewski authored 15 years ago

34)     model.subjectSelector = uicontrol(pSubject,'Style','listbox',...
35)                     'Min',1, 'Max',3,...
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

36)                     'String',getSubjectCellList(model.subjectMap),...
Christoph Budziszewski multi-subject support

Christoph Budziszewski authored 15 years ago

37)                     'Value',5,...  % default selected item
38)                     'Position',[firstColumn firstRow 0.66*frameWidth controlElementHeight*6]);
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

39)     set(model.subjectSelector,'BackgroundColor','w');
Christoph Budziszewski killed unnecessary assignin...

Christoph Budziszewski authored 15 years ago

40)     
Christoph Budziszewski new LabelMap new svm groupi...

Christoph Budziszewski authored 15 years ago

41)     model.txtSmoothed = createTextField(pSubject,[0.68*frameWidth firstRow  0.25*frameWidth controlElementHeight],'1');
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

42) 
43)     % PSTH
44)     firstColumn  = 5.00;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

45)     secondColumn = 0.33*frameWidth;
46)     thirdColumn  = 0.66*frameWidth;
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

47) %     fourthColumn = 0.84*frameWidth;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

48)     
49)     firstRow    = 5.5*controlElementHeight;
50)     secondRow   = 4.5*controlElementHeight;
51)     thirdRow    = 3.5*controlElementHeight;
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

52)     fourthRow   = 2.5*controlElementHeight;
53)     fifthRow    = 1.0*controlElementHeight;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

54)     
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

55)     lStart      = createLabel(pPSTH, [secondColumn firstRow  0.33*frameWidth controlElementHeight],'Start [sec]');
56)     lEnd        = createLabel(pPSTH, [thirdColumn  firstRow  0.33*frameWidth controlElementHeight],'End [sec]');
57)     lPSTH       = createLabel(pPSTH, [firstColumn  secondRow 0.33*frameWidth controlElementHeight],'PSTH Range');
58)     lBaseline   = createLabel(pPSTH, [firstColumn  thirdRow  0.33*frameWidth controlElementHeight],'Baseline');
59)     lFrameShift = createLabel(pPSTH, [firstColumn  fourthRow 0.33*frameWidth controlElementHeight],'SVM Frame Shift');
60)     lFramsSize  = createLabel(pPSTH, [firstColumn  fifthRow  0.33*frameWidth controlElementHeight],'SVM Frame Size');
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

61)     
62)     
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

63)     model.txtBaselineStart   = createTextField(pPSTH,[secondColumn thirdRow  0.25*frameWidth controlElementHeight],'-22.0');
64)     model.txtBaselineEnd     = createTextField(pPSTH,[thirdColumn  thirdRow  0.25*frameWidth controlElementHeight],'-20.0');
65)     model.txtPSTHStart       = createTextField(pPSTH,[secondColumn secondRow 0.25*frameWidth controlElementHeight],'-25.0');
66)     model.txtPSTHEnd         = createTextField(pPSTH,[thirdColumn  secondRow 0.25*frameWidth controlElementHeight],' 20.0');
Christoph Budziszewski GUI parsing halfway done.

Christoph Budziszewski authored 15 years ago

67)     model.txtFrameShiftStart = createTextField(pPSTH,[secondColumn fourthRow 0.25*frameWidth controlElementHeight],'-20.0');
68)     model.txtFrameShiftEnd   = createTextField(pPSTH,[thirdColumn  fourthRow 0.25*frameWidth controlElementHeight],' 15.0');
69)     model.txtFrameShiftDur   = createTextField(pPSTH,[secondColumn fifthRow  0.25*frameWidth controlElementHeight],' 0');
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

70) 
71)                 
72)     %Classes
73)     nClassRows = 6;
74)     firstColumn  = 5.00;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

75)     
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

76)     firstRow    = (nClassRows-0.5)*controlElementHeight;
77)     secondRow   = (nClassRows-4.5)*controlElementHeight;
78) 
79)     lClassDef = createLabel(pCLASS, [firstColumn firstRow  0.66*frameWidth controlElementHeight],'<Label>,<[Event,Event,..]>,<SVM-Value>;');
80)     model.txtClassDef = createTextField(pCLASS,[firstColumn secondRow 0.98*frameWidth 4*controlElementHeight],sprintf('<,\t[ 9,11,13],\t-2 ;\n>,\t[10,12,14],\t-1;'));
81)     set(model.txtClassDef,'HorizontalAlignment','left');
82)     set(model.txtClassDef,'Max',20);
83)     set(model.txtClassDef,'Min',0);
Christoph Budziszewski class def parsing added str...

Christoph Budziszewski authored 15 years ago

84)     set(model.txtClassDef, 'FontName', 'FixedWidth')
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

85)     
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

86)     %Voxel
87)     nVoxelRows = 8;
88)     firstColumn  = 5.00;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

89)     
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

90)     firstRow    = (nVoxelRows-0.5)*controlElementHeight;
91)     secondRow   = (nVoxelRows-7.5)*controlElementHeight;
92) 
93)     lVoxelDef = createLabel(pVOXEL, [firstColumn firstRow  0.66*frameWidth controlElementHeight],'<ROI Name>,<ROI Modifier>;');
94)     model.txtVoxelDef = createTextField(pVOXEL,[firstColumn secondRow 0.98*frameWidth 6*controlElementHeight],...
Christoph Budziszewski class def parsing added str...

Christoph Budziszewski authored 15 years ago

95)         sprintf('M1 l,\t[ 0, 0, 0];\nM1 l,\t[ 1, 0, 0];\nM1 l,\t[ 0, 1, 0];\nM1 l,\t[ 0, 0, 1];\n'));
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

96)     set(model.txtVoxelDef,'HorizontalAlignment','left');
97)     set(model.txtVoxelDef,'Max',20);
98)     set(model.txtVoxelDef,'Min',0);
Christoph Budziszewski class def parsing added str...

Christoph Budziszewski authored 15 years ago

99)     set(model.txtVoxelDef, 'FontName', 'FixedWidth')
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

100)                 
101)     % SVM
102)     firstColumn  =  5.00;
103)     firstRow     =  1.00 * controlElementHeight;
104) 
105)     model.txtSVMopts = createTextField(pSVM,[firstColumn firstRow  0.66*frameWidth controlElementHeight],'-t 0 -s 0 -v 6');
Christoph Budziszewski killed unnecessary assignin...

Christoph Budziszewski authored 15 years ago

106)     set(model.txtSVMopts,'Enable','on'); %inactive
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

107)     set(model.txtSVMopts,'HorizontalAlignment','left');
108) 
109)     set(btnRunButton,'Callback',{@cbRunSVM,model}); % set here, because of model.    
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

110)     set(frame,'Visible','on');
111) end
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

112)     
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

113) function label = createLabel(parent,  pos, labelText)
114)     label = uicontrol(parent,'Style','text','String',labelText,'Position',pos);
115)     set(label,'HorizontalAlignment','left');
116)     set(label,'Units','characters');
117) %     set(label,'BackgroundColor','r');
118) end
119) 
120) function btn = createButton(parent,pos,tag,labelText,cbArgs)
121)     btn = uicontrol(parent,'Position',pos,'String',labelText,'tag',tag);
122)      set(btn,'Callback',{@cbParseVariable,cbArgs});
123) %     set(btn,'BackgroundColor','b');
124) end
125) 
126) function txt = createTextField(parent,pos,model)
127)     txt = uicontrol(parent,'Style','edit','String',model,'Position',pos);
128)     set(txt,'BackgroundColor','w');
129) end
130) 
131) function drpField = createDropDown(parent,pos,selectionModel)
132)  drpField = uicontrol(parent,'Style','popupmenu','Position',pos);
133)   set(drpField,'String',selectionModel.Strings);
134)   set(drpField,'BackgroundColor','w');
135) end
136) 
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

137) function sane = isSane(model)
138)     sane = 1;
139) end
140) 
141) 
142) function cbRunSVM(src,evnt,model)
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

143) 
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

144)     display('RUN');
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

145) 
146)     % TODO test parameter values
147)     
148)     if isSane(model)
149)         set(0,'userdata',model);
150) %         set(src,'Enable','off');
Christoph Budziszewski killed unnecessary assignin...

Christoph Budziszewski authored 15 years ago

151) %         assignin('base','guiParams',model);
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

152)         classify(model)
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

153) %         set(src,'Enable','on');
154)     else
155)         %todo error beep!
156)         error('spmtoolbox:SVMCrossVal:paramcheck','please verify all parameters');
157)     end
158)                                         
159) end
160) 
161) 
Christoph Budziszewski multi-subject support

Christoph Budziszewski authored 15 years ago

162) function save(model)
163) 
164) end
165) 
166) function model = load()
167) end
168)