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 = 'SPL l + [ 0, 0, 0] \nSPL r + [ 0, 0, 0]\n'; DEFAULT.svmoptstring = '-s 0 -t 0 -c 1'; DEFAULT.svmnfold = '6'; DEFAULT.searchlightradius = 3; DEFAULT.wd = fullfile('d:','Analyze','Choice','24pilot'); % Initialize and hide the GUI as it is being constructed. frameWidth=450; frameHeight=600; 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','w'); model = struct; model.baseDir = DEFAULT.wd; model.txtBaseDir = createLabel(frame,[0 0.97 1 0.03],model.baseDir); set(model.txtBaseDir,'BackgroundColor','w'); pFirstStep = uipanel(frame,'Title','Preprocessing','Position',[0 0.25 1 0.720]); set(pFirstStep,'BackgroundColor','w'); set(pFirstStep,'Units','normalized'); model.selectedSubject = DEFAULT.selectedSubject; model = createFirstStepPanel(model,pFirstStep,DEFAULT); %Classification Step secondStepBaseColor = 'w'; pSecondStep = uipanel(frame,'Title','Classification','Position',[0 0 1 0.25]); set(pSecondStep,'BackgroundColor',secondStepBaseColor); model = createSecondStepPanel(model,pSecondStep,DEFAULT,secondStepBaseColor); savemenu = uimenu(frame,'Label','Save/Load'); uimenu(savemenu,'Label','Save','Callback',{@mcb_save,model}); uimenu(savemenu,'Label','Load','Callback',{@mcb_load,model}); uimenu(frame,'Label','change Study','Callback',{@mcb_cd,model},'Enable','off'); set(frame,'Visible','on'); % fill with data model = scanDirs(model); assignin('base','model',model); 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 model = createSecondStepPanel(model,parent,DEFAULT,basecolor) pSVM = uipanel(parent,'Units','normalized','Position',[0 0.0 0.5 1]); set(pSVM,'Title','SVM Classification'); set(pSVM,'BackgroundColor',basecolor); model.txtSVMopts = createTextField(pSVM,[0 0.75 1 0.25],DEFAULT.svmoptstring); set(model.txtSVMopts,'HorizontalAlignment','left'); model.txtSVMnfold = createTextField(pSVM,[0.0 0.50 0.5 0.25],DEFAULT.svmnfold); createLabel(pSVM,[0.5 0.50 0.5 0.25 ],'-Fold CrossVal'); pSOM = uipanel(parent,'Units','normalized','Position',[0.5 0.0 0.5 1]); 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'); btnRunSVM = uicontrol(pSVM,'String','run SVM Crossvalidation',... 'Units','normalized',... 'Position',[0 0.25 1 0.25]); set(btnRunSVM,'Callback',{@cbRunSVM,model}); % set here, because of model. set(btnRunSVM,'Enable','off'); btnRunXSVM = uicontrol(pSVM,'String','run SVM X-Subject validation',... 'Units','normalized',... 'Position',[0 0.0 1 0.25]); set(btnRunXSVM,'Callback',{@cbRunXSVM,model}); % set here, because of model. set(btnRunXSVM,'Enable','off'); btnRunSOM = uicontrol(pSOM,'String','run SOM Crossvalidation',... 'Units','normalized',... 'Position',[0.0 0.25 1 0.25]); set(btnRunSOM,'Callback',{@cbRunSOM,model}); % set here, because of model. 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,'Callback',{@cbRunXSOM,model}); % set here, because of model. set(btnRunXSOM,'Enable','off'); 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,'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('