private/ui_main.m
46b4e211
 function ui_main(varargin)
 
 %  Initialize and hide the GUI as it is being constructed.
     frameWidth=450;
2de68580
     frameHeight=450;
46b4e211
     
     frame = figure('Visible','off','Position',[0,0,frameWidth,frameHeight]);
aa0fb379
     movegui(frame,'center'); % get this thing visible on smaller displays.
48fb1827
     set(frame,'Name','NODalyze');
46b4e211
     set(frame,'NumberTitle','off');
     set(frame,'MenuBar','none');
4ac11e20
     set(frame,'Resize','on');
46b4e211
     set(frame,'Units','normalized');
f7802160
     set(frame,'Color','y');
46b4e211
 
2de68580
     task = struct;
accd38ff
 
9e39a52b
     model = struct;
accd38ff
     
9e39a52b
     model.txtBaseDir = createLabel(frame,[0 0.97 0.8 0.03],'');
     set(model.txtBaseDir,'BackgroundColor','w');
     set(model.txtBaseDir,'ForegroundColor','b');
     
     model.txtStudyID = createLabel(frame,[0.8 0.97 0.2 0.03],'');
     set(model.txtStudyID,'BackgroundColor','w');
     set(model.txtStudyID,'ForegroundColor','r');    
 
2de68580
     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');
9e39a52b
     model = createFirstStepPanel(model,task.preprocessing);
259bc793
     
2de68580
     % CLASSIFICATION
     task.classification = uipanel(frame,'Title','Classification','Position',[0 0.0 1 TASK_HEIGHT]);
     set(task.classification,'BackgroundColor','w');
9e39a52b
     model = createSecondStepPanel(model,task.classification);
2de68580
     
feeb21e9
     % PLOT
     task.plot = uipanel(frame,'Title','Plot','Position',[0 0.0 1 TASK_HEIGHT]);
     set(task.plot,'BackgroundColor','w');
9e39a52b
     model = createVisualStepPanel(model,task.plot);
feeb21e9
     
de857369
     % TASK SWITCH BUTTONS
fb860baf
     task.taskSwitch = uibuttongroup(frame,'Position',[0 1-0.13 1 0.10]);
     % controlls togglebuttons
2de68580
         set(task.taskSwitch,'BackgroundColor','w');
         set(task.taskSwitch,'Units','normalized');
     
fb860baf
         btnSwitchPreprocessing = uicontrol(task.taskSwitch,'Style','pushbutton',...
48fb1827
             'String','Image Processing',...
2de68580
             'Units','normalized','Position',[0.0 0.0 0.33 1]);
9e39a52b
         set(btnSwitchPreprocessing,'Callback',{@cbSwitchTask,'PRE',task}); 
2de68580
         set(btnSwitchPreprocessing,'Enable','on');
 
fb860baf
         btnSwitchClassify = uicontrol(task.taskSwitch,'Style','pushbutton',...
             'String','Decode',...
2de68580
             'Units','normalized','Position',[0.33 0.0 0.33 1]);
9e39a52b
         set(btnSwitchClassify,'Callback',{@cbSwitchTask,'CLASSIFY',task}); 
2de68580
         set(btnSwitchClassify,'Enable','on');
 
fb860baf
         btnSwitchPlot = uicontrol(task.taskSwitch,'Style','pushbutton',...
             'String','Plot',...
2de68580
             'Units','normalized','Position',[0.66 0.0 0.33 1]);
9e39a52b
         set(btnSwitchPlot,'Callback',{@cbSwitchTask,'PLOT',task}); 
2de68580
         set(btnSwitchPlot,'Enable','on');
 
9e39a52b
 
de857369
     % MENUS
9e39a52b
 
     savemenu = uimenu(frame,'Label','Save ...','Enable','on');
625fdcd6
         uimenu(savemenu,'Label','Save Parameter','Callback',{@mcb_save,'PARAMS',model},'Enable','on');
         uimenu(savemenu,'Label','Save ImageProcesseding Data','Callback',{@mcb_save,'IMAGEPROCESSING',model},'Enable','on');
         uimenu(savemenu,'Label','Load ImageProcesseding Data','Callback',{@mcb_load,'IMAGEPROCESSING',model},'Enable','on');
         uimenu(savemenu,'Label','Save Decode Data','Callback',{@mcb_save,'DECODE',model},'Enable','on');
         uimenu(savemenu,'Label','Load Decode Data','Callback',{@mcb_load,'DECODE',model},'Enable','on');
9760fd2f
         
9e39a52b
     studySelectMenu = uimenu(frame,'Label','Study ...','Enable','on');
         uimenu(studySelectMenu,'Label','*new Study*','Callback',{@mcb_new_study,studySelectMenu,model});
         fillStudyMenu(studySelectMenu,model);
         
48fb1827
     updateMenu = uimenu(frame,'Label','Update ...','Enable','on');
de857369
         uimenu(updateMenu,'Label','rescan subject dir','Callback',{@mcb_update_subjects,model});
         uimenu(updateMenu,'Label','rescan images','Callback',{@mcb_update_imagebase,model});
9e39a52b
         
 %     newStudyMenu = uimenu(frame,'Label','new Study','Enable','on');
259bc793
 
9e39a52b
     load_study([getPreviousStudyID '.mat'],model);
     cbSwitchTask(0,0,'PRE',task);
2de68580
     set(frame,'Visible','on');
 
85b70938
 end
259bc793
 
9e39a52b
 %%%%% ui elements
 function model = createFirstStepPanel(model,parent)
18f3b623
     norm1Model = {'none','mean','minmax'};
aa0fb379
     roiGroupMethodNames = {'none','mean','max','median'};
     roiGroupMethodFunctions = {@(in)in, @(in)nanmean(in),@(in)nanmax(in),@(in)nanmedian(in)};
46b4e211
 
4ac11e20
     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];
46b4e211
     
4ac11e20
     main_grid{2,1} = [0.4 0.7 0.6 0.3];
18f3b623
     main_grid{2,2} = [0.5 0.1 0.5 0.6];
 %     main_grid{2,3} = [0.5 0.1 0.5 0.4];
46b4e211
     
     %Subjects
259bc793
     pSubject = uipanel(parent,'Units','normalized','Position',cell2mat(main_grid(1,1)));
     set(pSubject,'Title','Subjects');
     set(pSubject,'BackgroundColor','w');
     
9e39a52b
 %     subjectNames = listDirNames(getBaseDir(model));
259bc793
     model.subjectSelector = uicontrol(pSubject,'Style','listbox',...
46b4e211
                     'Min',1, 'Max',3,...
                     'Units','normalized',...
259bc793
                     'Position',[0 0 1 1]);
feeb21e9
     set(model.subjectSelector, 'FontName', 'FixedWidth');
4ac11e20
     set(model.subjectSelector,'BackgroundColor','w');
9e39a52b
 
   
46b4e211
     %Classes
4ac11e20
     pClasses = uipanel(parent,'Units','normalized','Position',cell2mat(main_grid(1,2)));
46b4e211
     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');
9e39a52b
 
46b4e211
         
         model.txtClassDef = uicontrol(pClasses,'Style','edit',...
             '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');
4ac11e20
         set(model.txtClassDef, 'BackgroundColor', 'w');
46b4e211
 
 
     %Timeline
48fb1827
     pPSTH        = uipanel(parent,'Title','PST Options','Position',cell2mat(main_grid(2,1)));
46b4e211
     set(pPSTH,'BackgroundColor','w');
         
         grid_h = 0.16;
         grid_w = 0.3;
         
259bc793
         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];
46b4e211
         
259bc793
         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];
46b4e211
 
259bc793
         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];
46b4e211
         
259bc793
         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];
46b4e211
 
f625db4f
         tl_grid{1,5} = [0.0 0.16 grid_w grid_h];
         tl_grid{2,5} = [0.4 0.16 grid_w grid_h];
         tl_grid{3,5} = [0.7 0.16 grid_w grid_h];
46b4e211
         
259bc793
         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]');
48fb1827
         lPSTH       = createLabel(pPSTH, cell2mat(tl_grid(1,2)) ,'PST Range');
9e39a52b
         lBaseline   = createLabel(pPSTH, cell2mat(tl_grid(1,3)) ,'Baseline');
         lTRF        = createLabel(pPSTH, cell2mat(tl_grid(1,5)) ,'TR Factor');
48fb1827
         lTRSec      = createLabel(pPSTH, cell2mat(tl_grid(3,4)) ,'TR [sec]');
9e39a52b
 
         model.txtPSTHStart         = createTextField(pPSTH,cell2mat(tl_grid(2,2)),'');
         model.txtPSTHEnd           = createTextField(pPSTH,cell2mat(tl_grid(3,2)),'');
         model.txtBaselineStart     = createTextField(pPSTH,cell2mat(tl_grid(2,3)),'');
         model.txtBaselineEnd       = createTextField(pPSTH,cell2mat(tl_grid(3,3)),'');
         model.txtTrFactor          = createTextField(pPSTH,cell2mat(tl_grid(2,5)),'');
         model.labelTR              = createTextField(pPSTH,cell2mat(tl_grid(3,5)),'');
46b4e211
         
18f3b623
         % OPTIONS
         grid_h = 0.16;
         grid_wl = 0.4;
         grid_wo = 0.6;
46b4e211
         
18f3b623
         optGrid = cell([3 6]);
         optGrid{1,1} = [0.0 0.83 grid_wl grid_h];
         optGrid{2,1} = [0.4 0.83 grid_wo grid_h];
4ac11e20
         
18f3b623
         optGrid{1,2} = [0.0 0.66 grid_wl grid_h];
         optGrid{2,2} = [0.4 0.66 grid_wo grid_h];
 
48fb1827
         optGrid{1,3} = [0.0 0.5 1.0 grid_h];
 %         optGrid{2,3} = [0.4 0.5 grid_wo grid_h];
9e39a52b
         
18f3b623
         optGrid{1,4} = [0.0 0.33 grid_wl grid_h];
         optGrid{2,4} = [0.4 0.33 grid_wo grid_h];
 
48fb1827
         optGrid{1,5} = [0.0 0.16 1.0 grid_h];
 %         optGrid{2,5} = [0.4 0.16 grid_wo grid_h];
9e39a52b
         
18f3b623
         optGrid{1,6} = [0.0 0.0 grid_wl grid_h];
         optGrid{2,6} = [0.4 0.0 grid_wo grid_h];
9e39a52b
 
18f3b623
         % Options:Imagebase
         pOptions = uipanel(parent,'Title','Options','Position',cell2mat(main_grid(2,2)));
         set(pOptions,'BackgroundColor','w');
 
         createLabel(pOptions,cell2mat(optGrid(1,1)),'Image Base');
         model.imageTypeSelection = uicontrol(pOptions,'Style','popupmenu',...
         'Units','normalized',...
         'Position',cell2mat(optGrid(2,1)));
         set(model.imageTypeSelection,'BackgroundColor','w');
         
         %Options:normalizations
9e39a52b
         
48fb1827
         createLabel(pOptions,cell2mat(optGrid(1,2)),'PST normalization');
18f3b623
         model.selNormPST = uicontrol(pOptions,'Style','popupmenu',...
4ac11e20
             'Units','normalized',...
18f3b623
             'Position',cell2mat(optGrid(2,2)),...
4ac11e20
             'String',norm1Model,...
9e39a52b
             'UserData',norm1Model);
4ac11e20
          set(model.selNormPST,'BackgroundColor','w');   
         
18f3b623
         model.chkColBias = uicontrol(pOptions,'Style','checkbox',...
4ac11e20
             'Units','normalized',...
48fb1827
             'Position',cell2mat(optGrid(1,3)),...
             'String','Remove Column Bias within class',...
9e39a52b
             'Enable','on');
fb860baf
          set(model.chkColBias,'BackgroundColor','w');   
18f3b623
          
          %Options:spatialGrouping
 
48fb1827
          createLabel(pOptions,cell2mat(optGrid(1,4)),'Spatial Grouping');
18f3b623
          model.selRoiGrouping = uicontrol(pOptions,'Style','popupmenu',...
                 'Units','normalized',...
                 'Position',cell2mat(optGrid(2,4)),...
aa0fb379
                 'String',roiGroupMethodNames,...
                 'UserData',roiGroupMethodFunctions);
18f3b623
          set(model.selRoiGrouping,'BackgroundColor','w');
48fb1827
          
          %Options:VOI selection for FBS
          btnRunButton2 = uicontrol(pOptions,'String',sprintf('load VOI for Searchlight'),...
              'Units','normalized','Position',cell2mat(optGrid(1,5)));
          set(btnRunButton2,'Enable','on');
  
18f3b623
         
         % COORD TABLE
48fb1827
         pVoxel = uipanel(parent,'Title','Select ROIs','Position',cell2mat(main_grid(1,3)));
18f3b623
         set(pVoxel,'BackgroundColor','w');
         lVoxelDef = createLabel(pVoxel, [0 0.9 1 0.1],'<ROI Name> [+ radius (mm)];');
48fb1827
         model.txtVoxelDef = createTextField(pVoxel,[0 0.15 1 0.75],'');
18f3b623
         set(model.txtVoxelDef,'HorizontalAlignment','left');
         set(model.txtVoxelDef,'Max',20);
         set(model.txtVoxelDef,'Min',0);
         set(model.txtVoxelDef, 'FontName', 'FixedWidth');
4ac11e20
         
48fb1827
         btnROIlist = uicontrol(pVoxel,'String','show available ROIs','Units','normalized',...
             'Position',[0 0 1 0.15]);
f10dec01
         set(btnROIlist,'Enable','on');
48fb1827
         
4ac11e20
         %buttons
         pButtons = uipanel(parent,'Position',cell2mat(main_grid(1,4)));
         set(pButtons,'BackgroundColor','w');
46b4e211
         
48fb1827
         btnRunButton1 = uicontrol(pButtons,'String','start ROI-List processing',...
4ac11e20
             'Units','normalized','Position',[0 0 0.33 1]);
accd38ff
         set(btnRunButton1,'Enable','on');
48fb1827
 
         btnRunButton3 = uicontrol(pButtons,'String','start ROI-Image processing',...
             'Units','normalized','Position',[0.66 0 0.33 1]);
         set(btnRunButton3,'Enable','on');
46b4e211
         
         
48fb1827
         set(btnRunButton1,'Callback',{@cbRunPreprocessing,model,'COORD'}); % set here, because of model.
f10dec01
         set(btnRunButton2,'Callback',{@cbRunPreprocessing,model,'FBS'});   % set here, because of model.  
         set(btnRunButton3,'Callback',{@cbRunPreprocessing,model,'ROI'});   % set here, because of model.    
         set(btnROIlist,   'Callback',{@cbShowAvailableROIs,model});        % set here, because of model.  
48fb1827
    
85b70938
 end
 
9e39a52b
 function model = createSecondStepPanel(model,parent)
2de68580
 basecolor = 'w';
 
aa0fb379
 TimeframeGroupingStrings = {'none','mean'};%,'sum,'max','median'};
 TimeframeGroupingFunctions = {@(in)in,@(in)nanmean(in,2)};%,'sum',','max','median'};
 
18f3b623
 pTime = uipanel(parent,'Units','normalized','Position',[0.0 0.7 1 0.3]);
48fb1827
     set(pTime,'Title','Decode Timerange Options');
2de68580
     set(pTime,'BackgroundColor',basecolor);
18f3b623
     grid_h = 0.25;
feeb21e9
     grid_w = 0.3;
18f3b623
     time_grid = cell([3 4]);
     time_grid{1,1} = [0.0 0.75 grid_w grid_h];
     time_grid{2,1} = [0.4 0.75 grid_w grid_h];
     time_grid{3,1} = [0.7 0.75 grid_w grid_h];
     time_grid{1,2} = [0.0 0.50 grid_w grid_h];
     time_grid{2,2} = [0.4 0.50 grid_w grid_h];
     time_grid{3,2} = [0.7 0.50 grid_w grid_h];
     time_grid{1,3} = [0.0 0.25 grid_w grid_h];
     time_grid{2,3} = [0.4 0.25 grid_w grid_h];
     time_grid{3,3} = [0.7 0.0 grid_w grid_h];
     time_grid{1,4} = [0.0 0.0 grid_w grid_h];
     time_grid{2,4} = [0.4 0.0 grid_w grid_h];
     time_grid{3,4} = [0.7 0.0 grid_w grid_h];
     
feeb21e9
     lStart      = createLabel(pTime, cell2mat(time_grid(2,1)) ,'Start [sec]');
     lEnd        = createLabel(pTime, cell2mat(time_grid(3,1)) ,'End [sec]');
48fb1827
     lFrameShift = createLabel(pTime, cell2mat(time_grid(1,2)),'Time Range');
     lFramsSize  = createLabel(pTime, cell2mat(time_grid(1,3)),'Shifting Time Frame [sec]');
     lFramegroup = createLabel(pTime, cell2mat(time_grid(1,4)),'Time Frame Grouping');
feeb21e9
     
9e39a52b
     model.txtFrameShiftStart   = createTextField(pTime,cell2mat(time_grid(2,2)),'');
     model.txtFrameShiftEnd     = createTextField(pTime,cell2mat(time_grid(3,2)),'');
     model.txtFrameShiftDur     = createTextField(pTime,cell2mat(time_grid(2,3)),'');
c73e97a6
     
aa0fb379
 
18f3b623
     
     model.selTimeframeGrouping = uicontrol(pTime,'Style','popupmenu',...
         'Units','normalized',...
         'Position',cell2mat(time_grid(2,4)),...
aa0fb379
         'String',TimeframeGroupingStrings,...
         'UserData',TimeframeGroupingFunctions);
     set(model.selTimeframeGrouping,'Enable','on');
18f3b623
     
48fb1827
 pSVM = uipanel(parent,'Units','normalized','Position',[0 0.0 0.499 0.7]);
     set(pSVM,'Title','SVM Classification (libSVM)');
c73e97a6
     set(pSVM,'BackgroundColor',basecolor);
 
48fb1827
     grid_h = 0.125;
 
     svmgrid = cell([2 8]);
     svmgrid{1,1} = [0.0 0.875 1.0 grid_h];
     svmgrid{1,2} = [0.0 0.750 0.5 grid_h];
     svmgrid{2,2} = [0.5 0.750 0.5 grid_h];
     svmgrid{1,3} = [0.0 0.625 1   grid_h];
     svmgrid{1,4} = [0.0 0.5   1   grid_h];
     svmgrid{1,5} = [0.0 0.375 1   grid_h];
     svmgrid{1,6} = [0.0 0.250 0.5 grid_h];
     svmgrid{2,6} = [0.5 0.250 0.5 grid_h];
     svmgrid{1,7} = [0.0 0.125 0.5 grid_h];
     svmgrid{2,7} = [0.5 0.125 0.5 grid_h];
     svmgrid{1,8} = [0.0 0.0   1   grid_h];
c73e97a6
     
     
48fb1827
     model.txtSVMopts = createTextField(pSVM,cell2mat(svmgrid(1,1)),'');
     set(model.txtSVMopts,'HorizontalAlignment','left');
7984c76d
     
48fb1827
     model.txtSVMnfold = createTextField(pSVM,cell2mat(svmgrid(1,2)),'');
     createLabel(pSVM,cell2mat(svmgrid(2,2)),'-Fold CrossVal');
     
     btnRunSVM = uicontrol(pSVM,'String','run SVM within-Subject crossvalidation',...
22335072
         'Units','normalized',...
48fb1827
         'Position',cell2mat(svmgrid(1,3)));
22335072
     set(btnRunSVM,'Enable','on');
     
48fb1827
     btnRunXSVM = uicontrol(pSVM,'String','run SVM across-Subject crossvalidation',...
22335072
         'Units','normalized',...
48fb1827
         'Position',cell2mat(svmgrid(1,4)));
22335072
     set(btnRunXSVM,'Enable','on');
7984c76d
     
48fb1827
     lSearchligh = createLabel(pSVM, cell2mat(svmgrid(1,6)),'Searchlight Radius (mm)');
     model.txtSearchlightRadius = createTextField(pSVM,cell2mat(svmgrid(2,6)),'');
     
     lFBSTiming = createLabel(pSVM, cell2mat(svmgrid(1,7)),'Timepoints [sec] (opt.)');
     set(lFBSTiming,'TooltipString','e.g. ''-5 0 5 10 15''');
     model.txtSearchlightTimeline = createTextField(pSVM,cell2mat(svmgrid(2,7)),'');
 
     btnRunFBS = uicontrol(pSVM,'String','run Searchlight',...
         'Units','normalized',...
         'Position',cell2mat(svmgrid(1,8)));
     set(btnRunFBS,'Enable','on');
     
     
 pSOM = uipanel(parent,'Units','normalized','Position',[0.5 0.3 0.499 0.4]);
     set(pSOM,'Title','SOM Classification (somtoolbox2)');
c73e97a6
     set(pSOM,'BackgroundColor',basecolor);
 
17910a1f
     createLabel(pSOM,[0 0.75 0.3 0.20],'Size:');
18f3b623
     model.txtSomM = createTextField(pSOM,[0.3 0.75 0.25 0.16],'');
     somsizemal = createLabel(pSOM,[0.55 0.75 0.2 0.16],'x');
17910a1f
     set(somsizemal,'HorizontalAlignment','center');
18f3b623
     model.txtSomN = createTextField(pSOM,[0.75 0.75 0.25 0.16],'');
17910a1f
     latticeModel = {'rect','hexa'};
     model.selSomLattice = uicontrol(pSOM,'Style','popupmenu',...
         'Units','normalized',...
18f3b623
         'Position',[0.0 0.5 0.3 0.16],...
17910a1f
         'String',latticeModel,...
9e39a52b
         'UserData',latticeModel);
17910a1f
     set(model.selSomLattice,'BackgroundColor','w');
c73e97a6
 
18f3b623
     model.txtSOMnfold = createTextField(pSOM,[0.5 0.50 0.25 0.16],'');
     createLabel(pSOM,[0.75 0.5 0.25 0.16 ],'-Fold CrossVal');
c73e97a6
 
48fb1827
     btnRunSOM = uicontrol(pSOM,'String','run SOM within-Subject crossvalidation',...
c73e97a6
         'Units','normalized',...
22335072
         'Position',[0.0 0.25 1 0.25]);
916fe4f9
     set(btnRunSOM,'Enable','on');
c73e97a6
 
48fb1827
     btnRunXSOM = uicontrol(pSOM,'String','run SOM across-Subject crossvalidation',...
c73e97a6
         'Units','normalized',...
         'Position',[0.0 0.0 1 0.25]);
b0a2dbf1
     set(btnRunXSOM,'Enable','on');
aa21d53b
     
48fb1827
 % OPTIONS
 pOptions = uipanel(parent,'Units','normalized','Position',[0.5 0 0.5 0.3]);
     set(pOptions,'Title','Other Options');
     set(pOptions,'BackgroundColor',basecolor);
aa21d53b
     
48fb1827
     model.chkSVMrnd = uicontrol(pOptions,'Style','checkbox','Units','normalized','Position',[0 0.66 1 0.33]);
     set(model.chkSVMrnd,'String','Randomize Trial Order');
     set(model.chkSVMrnd,'BackgroundColor','w');
07e45407
 
22335072
 
 % 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'});
aa21d53b
     set(btnRunXSOM,'Callback',{@cbRunDecode,model,'XSOM'});
18bc821f
     set(btnRunFBS, 'Callback',{@cbRunDecode,model,'FBS'});
c73e97a6
 end
 
9e39a52b
 function model = createVisualStepPanel(model,parent)
18bc821f
 
643a1932
     grid_h = 0.125;
18bc821f
     grid_w = 0.5;
643a1932
     plot_grid = cell([3 8]);
18bc821f
     plot_grid{1,1} = [0.0 0.63 grid_w grid_h];
     plot_grid{1,2} = [0.0 0.33 grid_w grid_h];
     plot_grid{1,3} = [0.0 0.03 grid_w grid_h];
643a1932
     plot_grid{2,1} = [0.25 (1-1*grid_h) grid_w grid_h];
     plot_grid{2,2} = [0.25 (1-2*grid_h) grid_w grid_h];
     plot_grid{2,3} = [0.25 (1-3*grid_h) grid_w grid_h];
     plot_grid{2,4} = [0.25 (1-4*grid_h) grid_w grid_h];
     plot_grid{2,5} = [0.25 (1-5*grid_h) grid_w grid_h];
     plot_grid{2,6} = [0.25 (1-6*grid_h) grid_w grid_h];
     plot_grid{2,7} = [0.25 (1-7*grid_h) grid_w grid_h];
     plot_grid{2,8} = [0.25 (1-8*grid_h) grid_w grid_h];
18bc821f
 
643a1932
     
27ebd4d9
     pButtonPane = uipanel(parent,'Units','normalized','Position',[0 0.5 1 0.5]);
feeb21e9
 %     set(pButtonPane,'Title','Plot');
     set(pButtonPane,'BackgroundColor','w');
17910a1f
     
48fb1827
     btnPlot03 = uicontrol(pButtonPane,'String','Plot PSTH',...
17910a1f
         'Units','normalized',...
         'Position',cell2mat(plot_grid(2,1)));
     set(btnPlot03,'Callback',{@cbPlot,model,'psth'}); 
     set(btnPlot03,'Enable','on');
   
48fb1827
     btnPlot01 = uicontrol(pButtonPane,'String','Plot Decode Performance +/- SE',...
feeb21e9
         'Units','normalized',...
17910a1f
         'Position',cell2mat(plot_grid(2,2)));
27ebd4d9
     set(btnPlot01,'Callback',{@cbPlot,model,'simple'});
feeb21e9
     set(btnPlot01,'Enable','on');
27ebd4d9
     
48fb1827
     btnPlot02 = uicontrol(pButtonPane,'String','Plot Individual Performance and Mean +/- SE',...
27ebd4d9
         'Units','normalized',...
18bc821f
         'Position',cell2mat(plot_grid(2,3)));
27ebd4d9
     set(btnPlot02,'Callback',{@cbPlot,model,'x-subject-val'});
     set(btnPlot02,'Enable','on');
 
643a1932
     btnPlotT1 = uicontrol(pButtonPane,'String','Plot Trajectory (t vs A vs B)',...
         'Units','normalized',...
         'Position',cell2mat(plot_grid(2,4)));
     set(btnPlotT1,'Callback',{@cbPlot,model,'trajectory'});
     set(btnPlotT1,'Enable','on');
 
     btnPlotT2 = uicontrol(pButtonPane,'String','Plot Trajectory (A vs B vs C)',...
         'Units','normalized',...
         'Position',cell2mat(plot_grid(2,5)));
     set(btnPlotT2,'Callback',{@cbPlot,model,'trajectory3'});
     set(btnPlotT2,'Enable','on');
feeb21e9
 end
 
9e39a52b
 %%%%% ui callbacks
c73e97a6
 
f10dec01
 function cbShowAvailableROIs(src,evtl,model)
     ui_showAvailableROIs(model);
 end
 
9e39a52b
 function cbSwitchTask(src,evnt,task,taskpanel)
2de68580
 set(taskpanel.preprocessing,'Visible','off');
 set(taskpanel.classification,'Visible','off');
feeb21e9
 set(taskpanel.plot,'Visible','off');
2de68580
 switch task
     case 'PRE'
         set(taskpanel.preprocessing,'Visible','on');
4801799b
 
2de68580
     case 'CLASSIFY'
         set(taskpanel.classification,'Visible','on');
4801799b
 
2de68580
     case 'PLOT'
feeb21e9
         set(taskpanel.plot,'Visible','on');
2de68580
 end
9e39a52b
 % assignin('base','model',model);
2de68580
 end
 
85b70938
 function cbRunPreprocessing(src,evnt,model,task)
aaaeb6c5
 main(model,'pre',task);
 end
 
 function cbRunDecode(src,evnt,model,task)
 main(model,'decode',task);
85b70938
 end
 
feeb21e9
 function cbPlot(src,evnt,model,type)
 main(model,'plot',type);
 end
 
9e39a52b
 %%%%%%%%%% menu callbacks
feeb21e9
 
625fdcd6
 function mcb_save(src,evnt,token,model)
 switch token
     case 'PARAMS'
         studyID = get(model.txtStudyID,'String');
         saveStudy(studyID,model);
     case 'IMAGEPROCESSING'
         disp('save img data..');
         [FileName,PathName,FilterIndex] = uiputfile('*.mat','Save ImageProcessing Data') ;
         if(~strcmp(FileName,''))
             evalin('base', sprintf('save(''%s'',''%s'')',fullfile(PathName,FileName),'preprocessedData'));
             disp('saved');
         end
 %         [FileName,PathName,FilterIndex] = uigetfile('*.mat','Load ImageProcessing Data') 
 %         evalin('base', sprintf('load(%s,%s)',fullfile(PathName,FileName),'preprocessedData'));
     case 'DECODE'
         disp('save decode data..');
         [FileName,PathName,FilterIndex] = uiputfile('*.mat','Save Decode Data') ;
         if(~strcmp(FileName,''))
             evalin('base', sprintf('save(''%s'',''%s'')',fullfile(PathName,FileName),'decode'));
             disp('saved');
         end
 end
 end
 
 function mcb_load(src,evnt,token,model)
 switch token
     case 'IMAGEPROCESSING'
         disp('load img data..');
         [FileName,PathName,FilterIndex] = uigetfile('*.mat','Load ImageProcessing Data') ;
         if(~strcmp(FileName,''))
             evalin('base', sprintf('load(''%s'',''%s'')',fullfile(PathName,FileName),'preprocessedData'));
             disp('done');
         end
     case 'DECODE'
         disp('load decode data..');
         [FileName,PathName,FilterIndex] = uigetfile('*.mat','Load Decode Data') ;
         if(~strcmp(FileName,''))
             evalin('base', sprintf('load(''%s'',''%s'')',fullfile(PathName,FileName),'decode'));
             disp('done');
         end
 end
c73e97a6
 end
 
de857369
 function mcb_update_subjects(src,evnt,model)
 studyID = get(model.txtStudyID,'String');
 baseDir = getBaseDir(model);
 subjectNames = listDirNames(baseDir);
 
 set(model.subjectSelector,'String',subjectNames);
 set(model.subjectSelector,'UserData',subjectNames);
 set(model.subjectSelector,'Value',1);
 
 saveStudy(studyID,model);
 end
 
 function mcb_update_imagebase(src,evnt,model)
 studyID = get(model.txtStudyID,'String');
 
 subjectNames = getSubjectCellList(model);
 imageDir = fullfile(getBaseDir(model),cell2mat(subjectNames(1)));
 imageMask = imageMaskNames(imageDir);
 
 set(model.imageTypeSelection,'String',imageMask);
 set(model.imageTypeSelection,'UserData',imageMask);
 set(model.imageTypeSelection,'Value',1);
 
 saveStudy(studyID,model);
 end
 
 
9e39a52b
 function mcb_new_study(src,evnt,studymenu,uimodel)
de857369
 studyID = get(uimodel.txtStudyID,'String');
 saveStudy(studyID,uimodel);
 
9e39a52b
 display('CREATE STUDY');
     ui_createStudy(studymenu,uimodel);
c73e97a6
 end
 
 
 
46b4e211
 
9e39a52b