Home > functions > job > job_plot_currentmap_dir > job_plot_cmap_setting_dlg_callback.m

job_plot_cmap_setting_dlg_callback

PURPOSE ^

callback function for job_plot_cmap_setting_dlg.m

SYNOPSIS ^

function job_plot_cmap_setting_dlg_callback(H, hObj)

DESCRIPTION ^

 callback function for job_plot_cmap_setting_dlg.m
 [USAGE]
    job_plot_cmap_setting_dlg_callback(H);
 [IN]
       H : component handles
    hObj : action component handle
 [OUT]
    none

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function job_plot_cmap_setting_dlg_callback(H, hObj)
0002 % callback function for job_plot_cmap_setting_dlg.m
0003 % [USAGE]
0004 %    job_plot_cmap_setting_dlg_callback(H);
0005 % [IN]
0006 %       H : component handles
0007 %    hObj : action component handle
0008 % [OUT]
0009 %    none
0010 %
0011 % Copyright (C) 2011, ATR All Rights Reserved.
0012 % License : New BSD License(see VBMEG_LICENSE.txt)
0013 
0014 % disp(get(hObj, 'Tag')); % debug
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          % Show description
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         % get previous valid input
0098         prev = getappdata(hObj, 'prev');
0099         if isempty(prev), prev = 1; end
0100         % get maximum trial
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         % check input
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         % remember collect value for the next invalid input.
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 % change selection file type
0149 % [IN]
0150 %    H : component handles
0151 % type : = 1 : current file selection
0152 %        = 2 : time frequency file selection
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 % All component set invisible
0170 set([comp_current, comp_tf], 'Visible', 'off');
0171 
0172 if type == 1
0173     % Current file component visible
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     % Timefrequency file component visible
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 % change load mode(average or raw mode)
0194 % [IN]
0195 %    H : component handles
0196 % mode : 'ave' or 'raw'
0197 
0198 % uncheck both buttons
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 % get mode(average/raw) and trial number from GUI
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 % Show error dialog and set focus to an edit box
0229 h = errordlg('Specified file is invalid.', dlg_title);
0230 waitfor(h);
0231 uicontrol(hObj);

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005