0001 function project_mgr_contextmenu_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
0021
0022
0023
0024 drawnow;
0025
0026
0027 data = guidata(fig);
0028 H = data.H;
0029
0030
0031
0032
0033
0034 proj_root = get(H.project_root_edit, 'String');
0035
0036
0037
0038 selected_line_no = get(H.history_listbox, 'Value');
0039 max_line_no = length(get(H.history_listbox, 'String'));
0040 [parm, parm_type] = project_file_mgr('get_parameter', selected_line_no);
0041 func_type = vb_judge_function_name(parm, parm_type);
0042 switch(hObj)
0043 case H.submenu_launch_application
0044
0045 switch(func_type)
0046 case 'vb_job_brain'
0047 project_mgr_launch_module(fig, 'brain', parm);
0048 case 'vb_job_fmri'
0049 project_mgr_launch_module(fig, 'fmri', parm);
0050 case 'vb_job_meg'
0051 [Measurement, Device] = vb_meg_parm_get_measurement(parm);
0052 if strcmp(Measurement, 'MEG') && strcmp(Device, 'YOKOGAWA')
0053 project_mgr_launch_module(fig, 'yokogawa_meg', parm);
0054 elseif strcmp(Measurement, 'EEG') && strcmp(Device, 'BIOSEMI')
0055 project_mgr_launch_module(fig, 'biosemi_eeg', parm);
0056 else
0057 project_mgr_launch_module(fig, 'sbi_meg', parm);
0058 end
0059 case 'vb_job_leadfield'
0060 project_mgr_launch_module(fig, 'leadfield', parm);
0061 case 'vb_job_vb'
0062 project_mgr_launch_module(fig, 'bayes', parm);
0063 case 'vb_job_current'
0064 project_mgr_launch_module(fig, 'current', parm);
0065 case 'vb_job_head_3shell'
0066 project_mgr_launch_module(fig, 'spm_curry_head', parm);
0067 end
0068 case H.submenu_job_view_cortex
0069
0070 brain_file = [proj_root, '/', parm.brain_file];
0071 area_file = [proj_root, '/', parm.area_file];
0072 act_file = [proj_root, '/', parm.act_file];
0073
0074 brain_exist = exist(brain_file, 'file');
0075 act_exist = exist(area_file, 'file');
0076 area_exist = exist(act_file, 'file');
0077
0078 if ~act_exist
0079 errordlg('cannot launch job_view_cortex.', 'Cortical model file not found.');
0080 return;
0081 end
0082
0083 if act_exist && area_exist
0084
0085 job_view_cortex_init(brain_file, '--area', area_file, '--act', act_file);
0086 elseif ~act_exist && ~area_exist
0087
0088 job_view_cortex_init(brain_file);
0089 elseif act_exist && ~b_exist
0090
0091 job_view_cortex_init(brain_file, '--area', area_file);
0092 elseif ~a_exist && area_exist
0093
0094 job_view_cortex_init(brain_file, '--act', act_file);
0095 end
0096 case H.submenu_job_select_area
0097
0098 brain_file = [proj_root, '/', parm.brain_file];
0099 area_file = [proj_root, '/', parm.area_file];
0100 act_file = [proj_root, '/', parm.act_file];
0101
0102 brain_exist = exist(brain_file, 'file');
0103 act_exist = exist(area_file, 'file');
0104 area_exist = exist(act_file, 'file');
0105
0106 if ~brain_exist
0107 errordlg('cannot launch job_select_area', 'Cortical model file not found.');
0108 return;
0109 end
0110 if ~act_exist
0111 errordlg('cannot launch job_select_area', 'Cortical activity file not found.');
0112 return;
0113 end
0114 if ~area_exist
0115 errordlg('cannot launch job_select_area', 'Cortical area file not found.');
0116 return;
0117 end
0118 job_select_area(brain_file, area_file, act_file);
0119
0120 case H.submenu_job_edit_area
0121
0122 brain_file = [proj_root, '/', parm.brain_file];
0123 area_file = [proj_root, '/', parm.area_file];
0124 act_file = [proj_root, '/', parm.act_file];
0125
0126 brain_exist = exist(brain_file, 'file');
0127 act_exist = exist(act_file, 'file');
0128 area_exist = exist(area_file, 'file');
0129
0130 if ~brain_exist
0131 errordlg('cannot launch job_edit_area', 'Cortical model file not found.');
0132 return;
0133 end
0134 if ~act_exist
0135 errordlg('cannot launch job_edit_area', 'Cortical activity file not found.');
0136 return;
0137 end
0138 if ~area_exist
0139 errordlg('cannot launch job_edit_area', 'Cortical area file not found.');
0140 return;
0141 end
0142 job_edit_area(area_file, brain_file);
0143 case H.submenu_job_edit_act
0144
0145 brain_file = [proj_root, '/', parm.brain_file];
0146 act_file = [proj_root, '/', parm.act_file];
0147
0148 brain_exist = exist(brain_file, 'file');
0149 act_exist = exist(act_file, 'file');
0150
0151 if ~brain_exist
0152 errordlg('cannot launch job_edit_act', 'Cortical model file not found.');
0153 return;
0154 end
0155 if ~act_exist
0156 errordlg('cannot launch job_edit_act', 'Cortical activity file not found.');
0157 return;
0158 end
0159 job_edit_act(brain_file, act_file);
0160 case H.submenu_job_plot_meg
0161 proj_root = get(H.project_root_edit, 'String');
0162 [Measurement, Device] = vb_meg_parm_get_measurement(parm);
0163 if strcmp(Measurement, 'MEG')
0164 meg_file = [proj_root, '/', parm.meg_file];
0165 elseif strcmp(Measurement, 'EEG') && strcmp(Device, 'BIOSEMI')
0166 meg_file = [proj_root, '/', parm.output_file];
0167 end
0168 job_plot_meg(meg_file);
0169
0170 case H.submenu_job_plot_currentmap
0171
0172 result_file = [proj_root, '/', parm.bayesfile];
0173 load(result_file, 'bayes_parm');
0174
0175 brain_file = [proj_root, '/', bayes_parm.brainfile];
0176 current_file = [proj_root, '/', parm.currfile];
0177 brain_exist = exist(brain_file, 'file');
0178 current_exist = exist(current_file, 'file');
0179
0180 if ~brain_exist
0181 errordlg('cannot launch job_plot_currentmap', 'Cortical model file not found.');
0182 return;
0183 end
0184 if ~current_exist
0185 errordlg('cannot launch job_plot_currentmap', 'Current file not found.');
0186 return;
0187 end
0188 job_plot_currentmap(brain_file, current_file);
0189 end
0190 drawnow;
0191
0192 set(H.figure, 'HandleVisibility', 'callback');