0001 function [D, ic, status] = ui_event_types(D)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 [F hDone hList hEdit] = sf_start_window(D);
0022
0023
0024 waitfor(hDone,'UserData')
0025
0026
0027 ic = [];
0028 if ~ishandle(hDone)
0029 status = 0;
0030 else
0031 status = get(hDone, 'UserData');
0032 if status
0033
0034 status = status + get(hEdit, 'UserData');
0035 D = get(F, 'UserData');
0036 if ~isempty(event_types(D))
0037 ic = get(hList, 'Value');
0038 end
0039 end
0040 close(F);
0041 end
0042
0043 return
0044
0045 function [F, hDone, hList, hEdit] = sf_start_window(D)
0046
0047
0048
0049 w_tag = 'ui_event_types';
0050
0051
0052 close(findobj('Tag', w_tag))
0053
0054
0055 cb = ['et_D = get(findobj(''Tag'', ''' w_tag '''),''UserData''); '];
0056
0057
0058
0059 WS = spm('WinScale');
0060 FS = spm('FontSizes');
0061 PF = spm_platform('fonts');
0062 S0 = get(0,'ScreenSize');
0063
0064
0065 win_sz = [400 300];
0066 ratio_dor = (1 + sqrt(5))/2;
0067
0068
0069 n_buttons = 5;
0070 button_sz_x = 75;
0071 button_border = [12 12];
0072 button_sz = [button_sz_x button_sz_x / ratio_dor];
0073 button_x = win_sz(1) - button_sz(1) - button_border(1);
0074 l_b = button_border(2);
0075 h_b = win_sz(2) - button_border(2) - button_sz(2);
0076 gap_b = (h_b - l_b) / (n_buttons-1);
0077 buttons_y = l_b:gap_b:h_b;
0078
0079
0080 elist_border = button_border;
0081 elist_pos = elist_border;
0082 elist_sz(1) = button_x - elist_border(1)*2;
0083 elist_sz(2) = win_sz(2) - elist_border(2)*2;
0084
0085 F = figure('IntegerHandle','off',...
0086 'Tag', w_tag,...
0087 'UserData', D, ...
0088 'Name','Event type', ...
0089 'NumberTitle','off',...
0090 'Position',[S0(3)/2,S0(4)/2,0,0] + [-250,-200, win_sz].*WS,...
0091 'Resize','off',...
0092 'Color',[1 1 1]*.7,...
0093 'MenuBar','none',...
0094 'DefaultTextColor','k',...
0095 'DefaultTextFontName',PF.helvetica,...
0096 'DefaultTextFontSize',FS(10),...
0097 'DefaultAxesFontName',PF.helvetica,...
0098 'DefaultUicontrolBackgroundColor',[1 1 1]*.7,...
0099 'DefaultUicontrolFontName',PF.helvetica,...
0100 'DefaultUicontrolFontSize',FS(10),...
0101 'DefaultUicontrolInterruptible','on',...
0102 'Colormap',gray(64),...
0103 'Renderer','painters',...
0104 'Visible','on');
0105
0106
0107 hDone = uicontrol(F,...
0108 'Style','Pushbutton','String','OK',...
0109 'ToolTipString','OK - press after selecting selected events types',...
0110 'ForegroundColor','k',...
0111 'Tag','Done','UserData',-1,...
0112 'Callback',[cb 'ui_event_types_cb(et_D, ''OK'')'] ,...
0113 'Interruptible','off','BusyAction','Cancel',...
0114 'Position',[button_x buttons_y(1) button_sz].*WS);
0115
0116
0117 uicontrol(F,...
0118 'Style','Pushbutton','String','Cancel',...
0119 'ToolTipString','Cancel UI and return without changes',...
0120 'ForegroundColor','k',...
0121 'Tag','Cancel','UserData',-1,...
0122 'Callback',[cb 'ui_event_types_cb(et_D, ''Cancel'')'] ,...
0123 'Interruptible','off','BusyAction','Cancel',...
0124 'Position',[button_x buttons_y(2) button_sz].*WS);
0125
0126
0127 uicontrol(F,...
0128 'Style','Pushbutton','String','Delete',...
0129 'ToolTipString','Delete - press after selecting events type(s)',...
0130 'ForegroundColor','k',...
0131 'Tag','Delete','UserData',-1,...
0132 'Callback',[cb 'ui_event_types_cb(et_D, ''Delete'')'] ,...
0133 'Interruptible','off','BusyAction','Cancel',...
0134 'Position',[button_x buttons_y(3) button_sz].*WS);
0135
0136
0137 hEdit = uicontrol(F,...
0138 'Style','Pushbutton','String','Edit',...
0139 'ToolTipString','Edit - press after selecting an event type',...
0140 'ForegroundColor','k',...
0141 'Tag','eEdit','UserData',0,...
0142 'Callback',[cb 'ui_event_types_cb(et_D, ''Edit'')'] ,...
0143 'Interruptible','off','BusyAction','Cancel',...
0144 'Position',[button_x buttons_y(4) button_sz].*WS);
0145
0146
0147 uicontrol(F,...
0148 'Style','Pushbutton','String','New',...
0149 'ToolTipString','New - create new event type',...
0150 'ForegroundColor','k',...
0151 'Tag','New','UserData',-1,...
0152 'Callback',[cb 'ui_event_types_cb(et_D, ''New'')'] ,...
0153 'Interruptible','off','BusyAction','Cancel',...
0154 'Position',[button_x buttons_y(5) button_sz].*WS);
0155
0156
0157 et = event_types(D);
0158 if isfield(et, 'name')
0159 eNames = {et(:).name};
0160 else
0161 eNames = {};
0162 end
0163
0164 hList = uicontrol(F,'Style','ListBox','Tag','eList',...
0165 'ToolTipString',['Select events(s) - drag/shift-click',...
0166 '/ctrl-click to select multiple events'],...
0167 'String',eNames,...
0168 'Max',2,...
0169 'CallBack', '' ,...
0170 'Interruptible','off','BusyAction','Queue',...
0171 'BackgroundColor','w',...
0172 'Position',[elist_pos elist_sz].*WS);
0173
0174 return