Home > vbmeg > functions > gui > project_mgr_dir > project_mgr_callback.m

project_mgr_callback

PURPOSE ^

callback function for project_mgr gui

SYNOPSIS ^

function project_mgr_callback(fig, hObj)

DESCRIPTION ^

 callback function for project_mgr gui
 [USAGE]
    project_mgr_callback(<fig>, <hObj>);
 [IN]
     fig : figure handle of project_mgr gui.
    hObj : event 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:

SOURCE CODE ^

0001 function project_mgr_callback(fig, hObj)
0002 % callback function for project_mgr gui
0003 % [USAGE]
0004 %    project_mgr_callback(<fig>, <hObj>);
0005 % [IN]
0006 %     fig : figure handle of project_mgr gui.
0007 %    hObj : event 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 %
0015 % --- Previous check
0016 %
0017 if ~exist('fig', 'var') || isempty(fig) || ~ishandle(fig)
0018     error('invalid figure handle is specified.');
0019 end
0020 if ~exist('fig', 'var') || isempty(hObj)
0021     error('hObj is a required parameter.');
0022 end
0023 
0024 %
0025 % --- Main Procedure
0026 %
0027 
0028 % load data (@see project_mgr)
0029 data = guidata(fig);
0030 H = data.H; % component handles
0031 
0032 % % protect application screen
0033 % set(fig, 'HandleVisibility', 'off');
0034 
0035 switch(hObj)
0036     case H.history_listbox
0037         selected_line_no = get(H.history_listbox, 'Value');
0038         max_line_no = length(get(H.history_listbox, 'String'));
0039 
0040         % project is not loaded.
0041         if max_line_no == 0
0042             return;
0043         end
0044 
0045         % illigal selection check
0046         if (max_line_no < selected_line_no)
0047             selected_line_no = max_line_no;
0048         end
0049 
0050         % set parameter string
0051         [parm, parm_type] = project_file_mgr('get_parameter', selected_line_no);
0052         set(H.history_listbox, 'Value', selected_line_no);
0053         set(H.parameter_display_edit, 'String', vb_struct2str(parm));
0054         
0055         % set parm info to gui of check model.
0056         parm_info = [parm.time_stamp, ' ', parm_type];
0057         switch(parm_type)
0058             case 'brain_parm'
0059                 set(H.brain_parm_edit, 'String', parm_info);
0060                 data = project_mgr_set_ix_for_check_model(data, ...
0061                                            'brain_parm', selected_line_no);
0062             case 'fmri_parm'
0063                 set(H.fmri_parm_edit, 'String', parm_info);
0064                 data = project_mgr_set_ix_for_check_model(data, ...
0065                                            'fmri_parm', selected_line_no);
0066             case 'meg_parm'
0067                 set(H.meg_parm_edit, 'String', parm_info);
0068                 data = project_mgr_set_ix_for_check_model(data, ...
0069                                            'meg_parm', selected_line_no);
0070         end
0071         project_mgr_contextmenu_open(data);
0072     case {H.check_brain_model_push, H.check_brain_inflate_model_push}
0073         ix = project_mgr_get_ix_for_check_model(fig, 'brain_parm');
0074         if ix == 0
0075             errordlg('brain_parm is not selected.', 'error');
0076         else
0077             proj_root = get(H.project_root_edit, 'String');
0078             brain_parm = project_file_mgr('get_parameter', ix);
0079 
0080             if hObj == H.check_brain_model_push
0081                 % Check brain model by 3D & MRI image
0082 %                 vb_view_cortex_2d(brain_parm.analyze_file, ....
0083 %                                   fullfile(proj_root, brain_parm.brain_file));
0084                 vb_check_brain_model(proj_root, brain_parm);
0085             else
0086                 % Plot Inflate model
0087                 vb_check_inflate_model(proj_root, brain_parm);
0088             end
0089         end
0090     case H.check_fmri_parm_push
0091         ix = project_mgr_get_ix_for_check_model(fig, 'fmri_parm');
0092         if ix == 0
0093             errordlg('fmri_parm is not selected.', 'error');
0094         else
0095             proj_root = get(H.project_root_edit, 'String');
0096             fmri_parm = project_file_mgr('get_parameter', ix);
0097             % Check fMRI activity
0098             vb_check_fmri(proj_root, fmri_parm);
0099         end
0100     case H.check_meg_parm_push
0101         ix_brain = project_mgr_get_ix_for_check_model(fig, 'brain_parm');
0102         ix_meg   = project_mgr_get_ix_for_check_model(fig, 'meg_parm');
0103         if ix_brain == 0
0104             errordlg('brain_parm is not selected.', 'error');
0105         elseif ix_meg == 0
0106             errordlg('meg_parm is not selected.', 'error');
0107         else
0108             proj_root = get(H.project_root_edit, 'String');
0109             brain_parm = project_file_mgr('get_parameter', ix_brain);
0110             meg_parm = project_file_mgr('get_parameter',   ix_meg);
0111             % Check position of sensor and brain
0112             vb_job_check_sensor_on_brain(proj_root, brain_parm, meg_parm);
0113         end
0114     case {H.parm_name_checkbox, H.func_name_checkbox}
0115         project_mgr_view_update(fig);
0116     case H.add_parm_to_builder_push
0117         % Add selected parameter to selected batch file builder
0118         selected = get(H.history_listbox, 'Value');
0119         if selected > 0
0120             data = project_mgr_builder_open(data);
0121             [parm, parm_type] = project_file_mgr('get_parameter', selected);
0122             vb_batch_list_add_item(data.batch_fig, parm, parm_type);
0123         end
0124     case H.add_builder_push
0125         [data, name] = project_mgr_builder_add(data);
0126         guidata(fig, data);
0127         % update screen
0128         project_mgr_view_update_builders(fig);
0129         msgbox(sprintf('''%s'' was added.', name), 'Notice');
0130     case H.copy_builder_push
0131         [data, new_name] = project_mgr_builder_copy(data);
0132         guidata(fig, data);
0133         % update screen
0134         project_mgr_view_update_builders(fig);
0135         msgbox(sprintf('''%s'' was added.', new_name), 'Notice');
0136     case H.remove_builder_push
0137         % Confirm remove builder?
0138         idx = get(H.builder_popup, 'Value');
0139         rbuilder = data.batch_builders{idx};
0140         name     = vb_batch_mgr_get_name(rbuilder);
0141         res = questdlg(sprintf('Remove ''%s''?', name), 'Confirm', ...
0142                        'Yes', 'No', 'No');
0143         if strcmpi(res, 'no'), return; end
0144         [data, name] = project_mgr_builder_remove(data);
0145         guidata(fig, data);
0146         % update screen
0147         project_mgr_view_update_builders(fig);
0148         msgbox(sprintf('''%s'' was removed.', name), 'Notice');
0149     case H.open_builder_push
0150         data = project_mgr_builder_open(data);
0151     case H.export_mscript_push
0152         proj_root = get(H.project_root_edit, 'String');
0153         selected_line_no = get(H.history_listbox, 'Value');
0154 
0155         [parm, parm_type] = project_file_mgr('get_parameter', selected_line_no);
0156         if ~isempty(parm)
0157             project_mgr_export_as_script(proj_root, parm, parm_type);
0158         end
0159 end
0160 
0161 guidata(fig, data);
0162 
0163 % protect application screen end
0164 if ishandle(fig)
0165     set(fig, 'HandleVisibility', 'callback');
0166 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005