git.schokokeks.org
Repositories
Help
Report an Issue
SVMCrossVal.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
7614718
Branches
Tags
master
SVMCrossVal.git
private
ui_main.m
snapshot, working on fbs
Christoph Budziszewski
commited
7614718
at 2009-03-27 14:57:26
ui_main.m
Blame
History
Raw
function ui_main(varargin) DEFAULT.selectedSubject = 2; DEFAULT.pststart = -15; DEFAULT.pstend = 40; DEFAULT.baselinestart = -3; DEFAULT.baselineend = -1; DEFAULT.frameshiftstart = -5; DEFAULT.frameshiftend = 35; DEFAULT.frameshiftdur = 0; DEFAULT.classdefstring = 'left,\t[9,11,13]\nright,\t[10,12,14]'; DEFAULT.voxelstring = 'M1 l + 3 \nM1 r + 3\n'; DEFAULT.svmoptstring = '-s 0 -t 0 -c 1'; DEFAULT.svmnfold = '6'; DEFAULT.svmrnd = 1; DEFAULT.searchlightradius = 0; DEFAULT.wd = fullfile('d:','Analyze','Choice','24pilot'); % Initialize and hide the GUI as it is being constructed. frameWidth=450; frameHeight=450; frame = figure('Visible','off','Position',[0,0,frameWidth,frameHeight]); movegui(frame,'west'); % get this thing visible on smaller displays. set(frame,'Name','SVMCrossVal Decode Performance 4 SPM'); set(frame,'NumberTitle','off'); set(frame,'MenuBar','none'); % set(frame,'Color',get(0,'defaultUicontrolBackgroundColor')); set(frame,'Resize','on'); set(frame,'Units','normalized'); set(frame,'Color','y'); task = struct; model1 = struct; model1.baseDir = DEFAULT.wd; model1.txtBaseDir = createLabel(frame,[0 0.97 1 0.03],model1.baseDir); set(model1.txtBaseDir,'BackgroundColor','w'); set(model1.txtBaseDir,'ForegroundColor','b'); TASK_HEIGHT = 1-0.13; % PREPROCESSING task.preprocessing = uipanel(frame,'Title','Preprocessing','Position',[0 0.0 1 TASK_HEIGHT]); set(task.preprocessing,'BackgroundColor','w'); set(task.preprocessing,'Units','normalized'); model1.selectedSubject = DEFAULT.selectedSubject; model1 = createFirstStepPanel(model1,task.preprocessing,DEFAULT); % fill with data model1 = scanDirs(model1); % CLASSIFICATION model2 = struct; task.classification = uipanel(frame,'Title','Classification','Position',[0 0.0 1 TASK_HEIGHT]); set(task.classification,'BackgroundColor','w'); model2 = createSecondStepPanel(model2,task.classification,DEFAULT); % PLOT model3 = struct; task.plot = uipanel(frame,'Title','Plot','Position',[0 0.0 1 TASK_HEIGHT]); set(task.plot,'BackgroundColor','w'); model3 = createVisualStepPanel(model3,task.plot,DEFAULT); % TASK task.taskSwitch = uibuttongroup(frame,'Position',[0 1-0.13 1 0.10]); % controlls togglebuttons % set(task.taskSwitch,'Title','TASK'); set(task.taskSwitch,'BackgroundColor','w'); set(task.taskSwitch,'Units','normalized'); btnSwitchPreprocessing = uicontrol(task.taskSwitch,'Style','pushbutton',... 'String','ImageProcessing',... 'Units','normalized','Position',[0.0 0.0 0.33 1]); set(btnSwitchPreprocessing,'Callback',{@cbSwitchTask,'PRE',task}); set(btnSwitchPreprocessing,'Enable','on'); btnSwitchClassify = uicontrol(task.taskSwitch,'Style','pushbutton',... 'String','Decode',... 'Units','normalized','Position',[0.33 0.0 0.33 1]); set(btnSwitchClassify,'Callback',{@cbSwitchTask,'CLASSIFY',task}); set(btnSwitchClassify,'Enable','on'); btnSwitchPlot = uicontrol(task.taskSwitch,'Style','pushbutton',... 'String','Plot',... 'Units','normalized','Position',[0.66 0.0 0.33 1]); set(btnSwitchPlot,'Callback',{@cbSwitchTask,'PLOT',task}); set(btnSwitchPlot,'Enable','on'); % menu savemenu = uimenu(frame,'Label','Save/Load','Enable','off'); uimenu(savemenu,'Label','Save Preprocessing Parameter','Callback',{@mcb_save,model1},'Enable','off'); uimenu(savemenu,'Label','Load Preprocessing Parameter','Callback',{@mcb_load,model1},'Enable','off'); uimenu(savemenu,'Label','Save Decode Parameter','Callback',{@mcb_save,model2},'Enable','off'); uimenu(savemenu,'Label','Load Decode Parameter','Callback',{@mcb_load,model2},'Enable','off'); uimenu(savemenu,'Label','Save All','Callback',{@mcb_save,model1},'Enable','off'); uimenu(savemenu,'Label','Load All','Callback',{@mcb_load,model1},'Enable','off'); uimenu(frame,'Label','change Study','Callback',{@mcb_cd,model1},'Enable','off'); cbSwitchTask(0,0,'PRE',task); set(frame,'Visible','on'); assignin('base','model',model1); end function model = createFirstStepPanel(model,parent,DEFAULT) main_grid = cell(2,4); main_grid{1,1} = [0 0.7 0.4 0.3]; main_grid{1,2} = [0 0.5 0.5 0.2]; main_grid{1,3} = [0 0.1 0.5 0.4]; main_grid{1,4} = [0 0.0 1.0 0.1]; main_grid{2,1} = [0.4 0.7 0.6 0.3]; main_grid{2,2} = [0.5 0.5 0.5 0.2]; main_grid{2,3} = [0.5 0.1 0.5 0.4]; %Subjects pSubject = uipanel(parent,'Units','normalized','Position',cell2mat(main_grid(1,1))); set(pSubject,'Title','Subjects'); set(pSubject,'BackgroundColor','w'); subjectList = {'DUMMY Subj1','DUMMY Subj2','DUMMY Subj3','DUMMY Subj4'}; model.subjectSelector = uicontrol(pSubject,'Style','listbox',... 'Min',1, 'Max',3,... 'String',subjectList,... 'UserData',subjectList,... 'Units','normalized',... 'Position',[0 0 1 1]); set(model.subjectSelector, 'FontName', 'FixedWidth'); set(model.subjectSelector,'BackgroundColor','w'); %Classes pClasses = uipanel(parent,'Units','normalized','Position',cell2mat(main_grid(1,2))); set(pClasses,'Title','Class Definitions'); set(pClasses,'BackgroundColor','w'); lClassDef = uicontrol(pClasses,... 'Style','text',... 'String',sprintf('<Label>,\t <[Event, Event, ..]>;'),... 'Units','normalized',... 'Position',[0 0.8 1 0.2]); set(lClassDef,'BackgroundColor','w'); set(lClassDef,'HorizontalAlignment','left'); model.txtClassDef = uicontrol(pClasses,'Style','edit',... 'String',sprintf(DEFAULT.classdefstring),... 'Units','normalized',... 'Position',[0 0 1 0.8]); set(model.txtClassDef,'HorizontalAlignment','left'); set(model.txtClassDef,'Max',20); set(model.txtClassDef,'Min',0); set(model.txtClassDef, 'FontName', 'FixedWidth'); set(model.txtClassDef, 'BackgroundColor', 'w'); %Timeline pPSTH = uipanel(parent,'Title','PSTH Options','Position',cell2mat(main_grid(2,1))); set(pPSTH,'BackgroundColor','w'); grid_h = 0.16; grid_w = 0.3; tl_grid = cell([3 6]); tl_grid{2,1} = [0.0 0.83 grid_w grid_h]; tl_grid{2,1} = [0.4 0.83 grid_w grid_h]; tl_grid{3,1} = [0.7 0.83 grid_w grid_h]; tl_grid{1,2} = [0.0 0.66 grid_w grid_h]; tl_grid{2,2} = [0.4 0.66 grid_w grid_h]; tl_grid{3,2} = [0.7 0.66 grid_w grid_h]; tl_grid{1,3} = [0.0 0.5 grid_w grid_h]; tl_grid{2,3} = [0.4 0.5 grid_w grid_h]; tl_grid{3,3} = [0.7 0.5 grid_w grid_h]; tl_grid{1,4} = [0.0 0.33 grid_w grid_h]; tl_grid{2,4} = [0.4 0.33 grid_w grid_h]; tl_grid{3,4} = [0.7 0.33 grid_w grid_h]; tl_grid{1,5} = [0.0 0.16 0.5 grid_h]; tl_grid{2,5} = [0.5 0.16 grid_w grid_h]; tl_grid{3,5} = [0.75 0.16 grid_w grid_h]; tl_grid{1,6} = [0.0 0.0 0.5 grid_h]; tl_grid{2,6} = [0.5 0.0 grid_w grid_h]; tl_grid{3,6} = [0.75 0.0 grid_w grid_h]; lStart = createLabel(pPSTH, cell2mat(tl_grid(2,1)) ,'Start [sec]'); lEnd = createLabel(pPSTH, cell2mat(tl_grid(3,1)) ,'End [sec]'); lPSTH = createLabel(pPSTH, cell2mat(tl_grid(1,2)),'PSTH Range'); lBaseline = createLabel(pPSTH, cell2mat(tl_grid(1,3)),'Baseline'); model.txtPSTHStart = createTextField(pPSTH,cell2mat(tl_grid(2,2)),DEFAULT.pststart); model.txtPSTHEnd = createTextField(pPSTH,cell2mat(tl_grid(3,2)),DEFAULT.pstend); model.txtBaselineStart = createTextField(pPSTH,cell2mat(tl_grid(2,3)),DEFAULT.baselinestart); model.txtBaselineEnd = createTextField(pPSTH,cell2mat(tl_grid(3,3)),DEFAULT.baselineend); % images pImage = uipanel(parent,'Title','Image Options','Position',cell2mat(main_grid(2,2))); set(pImage,'BackgroundColor','w'); createLabel(pImage,[0.0 0.5 1 0.5],'Select Image Base'); imageRegExList = {'DUMMY f*.IMG','DUMMY swrf*.IMG','DUMMY wrf*.IMG'}; model.imageTypeSelection = uicontrol(pImage,'Style','popupmenu',... 'Units','normalized',... 'Position',[0.0 0.0 1 0.5],... 'String',imageRegExList,... 'UserData',imageRegExList,... 'Value',3); set(model.imageTypeSelection,'BackgroundColor','w'); % coordinate Table pVoxel = uipanel(parent,'Title','ROI','Position',cell2mat(main_grid(1,3))); set(pVoxel,'BackgroundColor','w'); lVoxelDef = createLabel(pVoxel, [0 0.9 1 0.1],'<ROI Name> [+ radius (mm)];'); model.txtVoxelDef = createTextField(pVoxel,[0 0 1 0.9],... sprintf(DEFAULT.voxelstring)); set(model.txtVoxelDef,'HorizontalAlignment','left'); set(model.txtVoxelDef,'Max',20); set(model.txtVoxelDef,'Min',0); set(model.txtVoxelDef, 'FontName', 'FixedWidth'); %normalizations pNorm = uipanel(parent,'Title','Normalization','Position',cell2mat(main_grid(2,3))); set(pNorm,'BackgroundColor','w'); createLabel(pNorm,[0 0.75 1 0.25],'psth norm4SVM'); norm1Model = {'none','mean','minmax'}; model.selNormPST = uicontrol(pNorm,'Style','popupmenu',... 'Units','normalized',... 'Position',[0.0 0.5 1 0.25],... 'String',norm1Model,... 'UserData',norm1Model,... 'Value',2); set(model.selNormPST,'BackgroundColor','w'); % createLabel(pNorm,[0 0.25 1 0.25],'Col Bias removal'); % norm2Model = {'on','off'}; model.chkColBias = uicontrol(pNorm,'Style','checkbox',... 'Units','normalized',... 'Position',[0.0 0.1 1 0.25],... 'String','column Bias removal',... 'Enable','on',... 'Value',1); set(model.chkColBias,'BackgroundColor','w'); %buttons pButtons = uipanel(parent,'Position',cell2mat(main_grid(1,4))); set(pButtons,'BackgroundColor','w'); btnRunButton1 = uicontrol(pButtons,'String','run coord-Table',... 'Units','normalized','Position',[0 0 0.33 1]); set(btnRunButton1,'Callback',{@cbRunPreprocessing,model,'COORD'}); % set here, because of model. set(btnRunButton1,'Enable','on'); btnRunButton2 = uicontrol(pButtons,'String',sprintf('use this settings for FBS'),... 'Units','normalized','Position',[0.33 0 0.33 1]); set(btnRunButton2,'Callback',{@cbRunPreprocessing,model,'FBS'}); % set here, because of model. set(btnRunButton2,'Enable','on'); btnRunButton3 = uicontrol(pButtons,'String','run ROI-Image processing',... 'Units','normalized','Position',[0.66 0 0.33 1]); set(btnRunButton3,'Callback',{@cbRunPreprocessing,model,'ROI'}); % set here, because of model. set(btnRunButton3,'Enable','on'); end function model = createSecondStepPanel(model,parent,DEFAULT) basecolor = 'w'; pTime = uipanel(parent,'Units','normalized','Position',[0.0 0.8 1 0.2]); set(pTime,'Title','Decode Timeframe Options'); set(pTime,'BackgroundColor',basecolor); grid_h = 0.3; grid_w = 0.3; time_grid = cell([3 3]); time_grid{1,1} = [0.0 0.63 grid_w grid_h]; time_grid{2,1} = [0.4 0.63 grid_w grid_h]; time_grid{3,1} = [0.7 0.63 grid_w grid_h]; time_grid{1,2} = [0.0 0.33 grid_w grid_h]; time_grid{2,2} = [0.4 0.33 grid_w grid_h]; time_grid{3,2} = [0.7 0.33 grid_w grid_h]; time_grid{1,3} = [0.0 0.03 grid_w grid_h]; time_grid{2,3} = [0.4 0.03 grid_w grid_h]; time_grid{3,3} = [0.7 0.03 grid_w grid_h]; lStart = createLabel(pTime, cell2mat(time_grid(2,1)) ,'Start [sec]'); lEnd = createLabel(pTime, cell2mat(time_grid(3,1)) ,'End [sec]'); lFrameShift = createLabel(pTime, cell2mat(time_grid(1,2)),'Frame Shift'); lFramsSize = createLabel(pTime, cell2mat(time_grid(1,3)),'Frame Size'); model.txtFrameShiftStart = createTextField(pTime,cell2mat(time_grid(2,2)),DEFAULT.frameshiftstart); model.txtFrameShiftEnd = createTextField(pTime,cell2mat(time_grid(3,2)),DEFAULT.frameshiftend); model.txtFrameShiftDur = createTextField(pTime,cell2mat(time_grid(2,3)),DEFAULT.frameshiftdur); pSVM = uipanel(parent,'Units','normalized','Position',[0 0.4 0.5 0.4]); set(pSVM,'Title','SVM Classification'); set(pSVM,'BackgroundColor',basecolor); model.txtSVMopts = createTextField(pSVM,[0 0.83 1 0.16],DEFAULT.svmoptstring); set(model.txtSVMopts,'HorizontalAlignment','left'); model.txtSVMnfold = createTextField(pSVM,[0.0 0.66 0.5 0.16],DEFAULT.svmnfold); createLabel(pSVM,[0.5 0.50 0.5 0.25 ],'-Fold CrossVal'); model.chkSVMrnd = uicontrol(pSVM,'Style','checkbox','Units','normalized','Position',[0.1 0.50 0.9 0.16]); set(model.chkSVMrnd,'String','Randomize Datapoints'); set(model.chkSVMrnd,'BackgroundColor','w'); set(model.chkSVMrnd,'Value',DEFAULT.svmrnd); btnRunSVM = uicontrol(pSVM,'String','run batchmode SVM Crossvalidation',... 'Units','normalized',... 'Position',[0 0.25 1 0.25]); set(btnRunSVM,'Enable','on'); btnRunXSVM = uicontrol(pSVM,'String','run SVM X-Subject validation',... 'Units','normalized',... 'Position',[0 0.0 1 0.25]); set(btnRunXSVM,'Enable','on'); pSOM = uipanel(parent,'Units','normalized','Position',[0.5 0.4 0.5 0.4]); set(pSOM,'Title','SOM Classification'); set(pSOM,'BackgroundColor',basecolor); model.txtSOMopts = createTextField(pSOM,[0 0.75 1 0.25],'4x3 rect'); set(model.txtSOMopts,'HorizontalAlignment','left'); set(model.txtSOMopts,'Enable','off'); model.txtSOMnfold = createTextField(pSOM,[0.0 0.50 0.5 0.25],DEFAULT.svmnfold); set(model.txtSOMnfold,'Enable','off'); createLabel(pSOM,[0.5 0.50 0.5 0.25 ],'-Fold CrossVal'); btnRunSOM = uicontrol(pSOM,'String','run SOM Crossvalidation',... 'Units','normalized',... 'Position',[0.0 0.25 1 0.25]); set(btnRunSOM,'Enable','off'); btnRunXSOM = uicontrol(pSOM,'String','run SOM X-Subject validation',... 'Units','normalized',... 'Position',[0.0 0.0 1 0.25]); set(btnRunXSOM,'Enable','off'); pSearchlight = uipanel(parent,'Units','normalized','Position',[0.0 0.1 1 0.3]); set(pSearchlight,'Title','Spatiotemporal FB classification'); set(pSearchlight,'BackgroundColor',basecolor); lSearchligh = createLabel(pSearchlight, [0 0.6 0.5 0.3],'Searchlight Radius'); model.txtSearchlightRadius = createTextField(pSearchlight,[0.5 0.6 0.5 0.3],DEFAULT.searchlightradius); btnRunFBS = uicontrol(pSearchlight,'String','run Spatiotemporal FB classification',... 'Units','normalized',... 'Position',[0.0 0.0 1 0.3]); set(btnRunFBS,'Enable','on'); % button callbacks set here, because of model. set(btnRunSVM, 'Callback',{@cbRunDecode,model,'SVM'}); set(btnRunXSVM,'Callback',{@cbRunDecode,model,'XSVM'}); set(btnRunSOM, 'Callback',{@cbRunDecode,model,'SOM'}); set(btnRunXSOM,'Callback',{@cbRunDecode,model,'XSOM'}); set(btnRunFBS,'Callback',{@cbRunDecode,model,'FBS'}); end function model = createVisualStepPanel(model,parent,DEFAULT) pButtonPane = uipanel(parent,'Units','normalized','Position',[0 0.5 1 0.5]); % set(pButtonPane,'Title','Plot'); set(pButtonPane,'BackgroundColor','w'); btnPlot01 = uicontrol(pButtonPane,'String','plot performance and SE',... 'Units','normalized',... 'Position',[0.0 0.0 0.5 0.25]); set(btnPlot01,'Callback',{@cbPlot,model,'simple'}); set(btnPlot01,'Enable','on'); btnPlot02 = uicontrol(pButtonPane,'String','plot subject performance and mean with SE',... 'Units','normalized',... 'Position',[0.5 0.0 0.5 0.25]); set(btnPlot02,'Callback',{@cbPlot,model,'x-subject-val'}); set(btnPlot02,'Enable','on'); % btnPlot03 = uicontrol(pButtonPane,'String','plot class performance and mean',... % 'Units','normalized',... % 'Position',[0.0 0.5 0.5 0.25]); % set(btnPlot03,'Callback',{@cbPlot,model,'class performance'}); % set(btnPlot03,'Enable','on'); end function cbSwitchTask(src,evnt,task,taskpanel) set(taskpanel.preprocessing,'Visible','off'); set(taskpanel.classification,'Visible','off'); set(taskpanel.plot,'Visible','off'); switch task case 'PRE' set(taskpanel.preprocessing,'Visible','on'); case 'CLASSIFY' set(taskpanel.classification,'Visible','on'); case 'PLOT' set(taskpanel.plot,'Visible','on'); end end function cbRunPreprocessing(src,evnt,model,task) main(model,'pre',task); end function cbRunDecode(src,evnt,model,task) main(model,'decode',task); end function cbPlot(src,evnt,model,type) main(model,'plot',type); end function model = mcb_cd(src,evnt,model) disp('CD'); directory_name = uigetdir(model.baseDir,'Select Study Base Directory ...'); model.baseDir = directory_name; model = scanDirs(model); end function mcb_save(src,evnt,model) disp('SAVE'); baseDir = model.baseDir; timeLine = getTimeLineParams(model); classDefString = getClassDefString(model); coordDefString = getCoordDefString(model); [file path] = uiputfile('*.mat','Save current Params ...',model.baseDir); save( fullfile(path,file),'baseDir','timeLine','classDefString','coordDefString') ; end function model = mcb_load(src,evnt,model) disp('LOAD'); [file path] = uigetfile('*.mat','Load Params ...',model.baseDir); l = load(fullfile(path,file)); % assignin('base','l',l); model = setTimeLineParams(model,l.timeLine); model = setClassDefString(model,l.classDefString); model = setCoordDefString(model,l.coordDefString); model.baseDir = l.baseDir; model = scanDirs(model); end function label = createLabel(parent, pos, labelText) label = uicontrol(parent,'Style','text','Units','normalized','String',labelText,'Position',pos); set(label,'HorizontalAlignment','left'); set(label,'BackgroundColor','w'); end function txt = createTextField(parent,pos,model) % textfieldcolor = [0.9 0.9 0.0]; textfieldcolor = 'w'; txt = uicontrol(parent,'Style','edit','Units','normalized','String',model,'Position',pos); set(txt,'BackgroundColor',textfieldcolor); end