0001 function project_mgr_callback(fig, hObj)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
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
0026
0027
0028
0029 data = guidata(fig);
0030 H = data.H;
0031
0032
0033
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
0041 if max_line_no == 0
0042 return;
0043 end
0044
0045
0046 if (max_line_no < selected_line_no)
0047 selected_line_no = max_line_no;
0048 end
0049
0050
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
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
0082
0083
0084 vb_check_brain_model(proj_root, brain_parm);
0085 else
0086
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
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
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
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
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
0134 project_mgr_view_update_builders(fig);
0135 msgbox(sprintf('''%s'' was added.', new_name), 'Notice');
0136 case H.remove_builder_push
0137
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
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
0164 if ishandle(fig)
0165 set(fig, 'HandleVisibility', 'callback');
0166 end