0001 function job_plot_cmap_setting_dlg_callback(H, hObj)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 D = vb_define_extension;
0017
0018 switch(hObj)
0019 case H.data_file_current_radiobutton
0020 change_file_type(H, 1);
0021 case H.data_file_tf_radiobutton
0022 change_file_type(H, 2);
0023 case {H.tf_file_text, H.current_file_text, H.brain_file_text,...
0024 H.area_file_text, H.act_file_text, H.load_mode_text}
0025
0026 description = getappdata(hObj, 'description');
0027 set(H.description_edit, 'String', description);
0028 case H.brain_file_push
0029 [d_, f_] = vb_file_select(...
0030 {D.BRAIN_EXTENSION}, 'Select Cortical model file');
0031 if ~isempty(d_)
0032 set(H.brain_file_update_checkbox, 'Value', 1);
0033 job_plot_cmap_setting_dlg_set_file(...
0034 H, [d_ filesep, f_{1}], 'brain_file');
0035 end
0036 case H.brain_file_edit
0037 file = get(hObj, 'String');
0038 res = job_plot_cmap_setting_dlg_set_file(H, file, 'brain_file');
0039 if res == FAILURE
0040 inner_error_file_specified(hObj, 'Cortical model file');
0041 end
0042 case H.area_file_push
0043 [d_, f_] = vb_file_select(...
0044 {D.AREA_EXTENSION}, 'Select Cortical area file');
0045 if ~isempty(d_)
0046 set(H.area_file_update_checkbox, 'Value', 1);
0047 job_plot_cmap_setting_dlg_set_file(...
0048 H, [d_ filesep, f_{1}], 'area_file');
0049 end
0050 case H.area_file_edit
0051 file = get(hObj, 'String');
0052 res = job_plot_cmap_setting_dlg_set_file(H, file, 'area_file');
0053 if res == FAILURE
0054 inner_error_file_specified(hObj, 'Cortical area file');
0055 end
0056 case H.act_file_push
0057 [d_, f_] = vb_file_select(...
0058 {D.FMRI_EXTENSION}, 'Select Cortical activity file');
0059 if ~isempty(d_)
0060 set(H.act_file_update_checkbox, 'Value', 1);
0061 job_plot_cmap_setting_dlg_set_file(...
0062 H, [d_ filesep, f_{1}], 'act_file');
0063 end
0064 case H.act_file_edit
0065 file = get(hObj, 'String');
0066 res = job_plot_cmap_setting_dlg_set_file(H, file, 'act_file');
0067 if res == FAILURE
0068 inner_error_file_specified(hObj, 'Cortical act file');
0069 end
0070 case H.current_file_push
0071 [d_, f_] = vb_file_select(...
0072 {D.CURRENT_EXTENSION}, 'Select Current file');
0073 if ~isempty(d_)
0074 current_file = [d_, filesep, f_{1}];
0075 [mode, trial] = inner_get_current_file_settings(H);
0076 job_plot_cmap_setting_dlg_set_current_file(...
0077 H, current_file,...
0078 mode, trial);
0079 end
0080 case H.current_file_edit
0081 file = get(hObj, 'String');
0082 [mode, trial] = inner_get_current_file_settings(H);
0083 res = job_plot_cmap_setting_dlg_set_current_file(...
0084 H, file,...
0085 mode, trial);
0086 if res == FAILURE
0087 inner_error_file_specified(hObj, 'Current file');
0088 end
0089 case H.current_file_mode_average_radiobutton
0090 change_load_mode(H, 'ave');
0091 set(H.current_file_update_checkbox, 'Value', 1);
0092 case H.current_file_mode_raw_radiobutton
0093 change_load_mode(H, 'raw');
0094 set(H.current_file_update_checkbox, 'Value', 1);
0095 case H.current_file_mode_raw_edit
0096 change_load_mode(H, 'raw');
0097
0098 prev = getappdata(hObj, 'prev');
0099 if isempty(prev), prev = 1; end
0100
0101 max_trial = getappdata(H.max_trial_text, 'max');
0102 if isempty(max_trial), max_trial = 1; end
0103 trial = str2double(get(hObj, 'String'));
0104 trial = round(trial);
0105 set(hObj, 'String', num2str(trial));
0106
0107 if isnan(trial) || trial > max_trial || trial <= 0
0108 errordlg('Trial index is invalid.', 'Trial');
0109 set(hObj, 'String', num2str(prev));
0110 return;
0111 end
0112 if prev == trial, return; end
0113
0114 setappdata(hObj, 'prev', trial);
0115 set(H.current_file_update_checkbox, 'Value', 1);
0116
0117 case H.tf_file_push
0118 [d_, f_] = vb_file_select(...
0119 {'.tf.mat'}, 'Select Time frequency file');
0120 if ~isempty(d_)
0121 set(H.tf_file_update_checkbox, 'Value', 1);
0122 job_plot_cmap_setting_dlg_set_file(...
0123 H, [d_, filesep, f_{1}], 'tf_file');
0124 end
0125 case H.tf_file_edit
0126 file = get(hObj, 'String');
0127 res = job_plot_cmap_setting_dlg_set_file(H, file, 'tf_file');
0128 if res == FAILURE
0129 inner_error_file_specified(hObj, 'Time frequency file');
0130 end
0131 case H.ok_push
0132 set(H.figure, 'Visible', 'off');
0133 return;
0134 case H.cancel_push
0135 closereq;
0136 return;
0137 end
0138
0139 ret = job_plot_cmap_setting_dlg_is_requirement_filled(H.figure);
0140 if ret
0141 set(H.ok_push, 'Enable', 'on');
0142 else
0143 set(H.ok_push, 'Enable', 'off');
0144 end
0145
0146
0147 function change_file_type(H, type)
0148
0149
0150
0151
0152
0153
0154 comp_current = [H.current_file_text, ...
0155 H.current_file_edit, ...
0156 H.current_file_push, ...
0157 H.current_file_update_checkbox, ...
0158 H.load_mode_frame, ...
0159 H.load_mode_text, ...
0160 H.current_file_mode_average_radiobutton, ...
0161 H.current_file_mode_raw_radiobutton, ...
0162 H.current_file_mode_raw_edit, ...
0163 H.max_trial_text];
0164 comp_tf = [H.tf_file_text, ...
0165 H.tf_file_edit, ...
0166 H.tf_file_push, ...
0167 H.tf_file_update_checkbox];
0168
0169
0170 set([comp_current, comp_tf], 'Visible', 'off');
0171
0172 if type == 1
0173
0174 set(comp_current, 'Visible', 'on');
0175 set(H.data_file_current_radiobutton, 'Value', 1);
0176 set(H.data_file_tf_radiobutton, 'Value', 0);
0177 tbl = vb_define_description_table;
0178 desc = vb_table_query_value(tbl, 'jpcp_current');
0179 set(H.description_edit, 'String', ...
0180 sprintf(['*: required parameter(s).', desc]));
0181 else
0182
0183 set(comp_tf, 'Visible', 'on');
0184 set(H.data_file_current_radiobutton, 'Value', 0);
0185 set(H.data_file_tf_radiobutton, 'Value', 1);
0186 tbl = vb_define_description_table;
0187 desc = vb_table_query_value(tbl, 'jpcp_timefreq');
0188 set(H.description_edit, 'String', ...
0189 sprintf(['*: required parameter(s).', desc]));
0190 end
0191
0192 function change_load_mode(H, mode)
0193
0194
0195
0196
0197
0198
0199 comp = [H.current_file_mode_average_radiobutton,
0200 H.current_file_mode_raw_radiobutton];
0201 set(comp, 'Value', 0);
0202
0203 switch(mode)
0204 case 'ave'
0205 set(H.current_file_mode_average_radiobutton, ...
0206 'Value', 1, 'Enable', 'Inactive');
0207 set(H.current_file_mode_raw_radiobutton, 'Enable', 'on');
0208 case 'raw'
0209 set(H.current_file_mode_raw_radiobutton, ...
0210 'Value', 1, 'Enable', 'Inactive');
0211 set(H.current_file_mode_average_radiobutton, 'Enable', 'on');
0212 otherwise
0213 error('Unknown mode was specified.');
0214 end
0215
0216 function [mode, trial] = inner_get_current_file_settings(H)
0217
0218
0219 if get(H.current_file_mode_average_radiobutton, 'Value')
0220 mode = 'ave';
0221 else
0222 mode = 'raw';
0223 end
0224 trial = str2double(get(H.current_file_mode_raw_edit, 'String'));
0225
0226
0227 function inner_error_file_specified(hObj, dlg_title)
0228
0229 h = errordlg('Specified file is invalid.', dlg_title);
0230 waitfor(h);
0231 uicontrol(hObj);