0001 function pa_leadfield_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 is specified.');
0019 end
0020 if ~exist('hObj', 'var')
0021 error('hObj is a required parameter.');
0022 end
0023
0024
0025
0026
0027 global vbmeg_inst;
0028 define = vbmeg_inst.const;
0029
0030
0031 data = guidata(fig);
0032 H = data.H;
0033
0034 switch( hObj )
0035 case H.prjroot_push
0036 dir = dir_dialog(get(H.prjroot_edit, 'String'));
0037 if dir ~= 0
0038 set(H.prjroot_edit, 'String', dir);
0039 end
0040 case H.megmat_file_edit
0041 pa_leadfield_util(fig, 'update_output_fname');
0042 pa_leadfield_util(fig, 'update_exec_push_status');
0043 case H.megmat_file_push
0044 proj_root = get(H.prjroot_edit, 'String');
0045 [dir fname cancelled] = pa_prjfile_select(proj_root,...
0046 {define.MEG2_EXTENSION, ...
0047 define.EEG_EXTENSION}, ...
0048 'Select MEG/EEG data');
0049 if ~cancelled
0050 megmat_file = [dir filesep fname{1}];
0051 set(H.megmat_file_edit, 'String', megmat_file);
0052 pa_leadfield_util(fig, 'update_output_fname');
0053
0054 [pick, Qpick, CoilWeight, Vcenter] = ...
0055 vb_load_sensor([proj_root, filesep, megmat_file]);
0056 set(H.center_head_edit, 'String', num2str(Vcenter, 3));
0057
0058 data.Vradius = 0.08;
0059 guidata(fig, data);
0060 end
0061 case H.brain_file_push
0062 proj_root = get(H.prjroot_edit, 'String');
0063 [dir fname canceled] = pa_prjfile_select(proj_root,...
0064 {define.BRAIN_EXTENSION},...
0065 'Select cortical model file');
0066 if ~canceled
0067 set(H.brain_file_edit, 'String', [dir filesep fname{1}]);
0068 pa_leadfield_util(fig, 'update_exec_push_status');
0069 end
0070 case H.area_file_push
0071 proj_root = get(H.prjroot_edit, 'String');
0072 [dir fname canceled] = pa_prjfile_select(proj_root, ...
0073 {define.AREA_EXTENSION}, ...
0074 'Select cortical area file');
0075 if ~canceled
0076 set(H.area_file_edit, 'String', [dir filesep fname{1}]);
0077 end
0078 case H.head_file_push
0079 proj_root = get(H.prjroot_edit, 'String');
0080 [dir fname canceled] = pa_prjfile_select(proj_root,...
0081 {'.head.mat'},...
0082 'Select head model file');
0083 if ~canceled
0084 set(H.head_file_edit, 'String', [dir filesep fname{1}]);
0085 pa_leadfield_util(fig, 'update_exec_push_status');
0086 end
0087 case H.save_dir_push
0088 proj_root = get(H.prjroot_edit, 'String');
0089 [dir canceled] = pa_prjdir_select(proj_root);
0090 if ~canceled
0091 set(H.save_dir_edit, 'String', dir);
0092 pa_leadfield_util(fig, 'update_output_fname');
0093 pa_leadfield_util(fig, 'update_exec_push_status');
0094 end
0095 case H.exec_push
0096 pa_leadfield_util(fig, 'exec_leadfield');
0097 case H.save_dir_edit
0098 pa_leadfield_util(fig, 'update_output_fname');
0099 pa_leadfield_util(fig, 'update_exec_push_status');
0100 case H.BemMode_popup
0101 bem_mode = pa_leadfield_util(fig, 'get_bem_mode');
0102 pa_leadfield_util(fig, 'set_bem_mode', bem_mode);
0103 pa_leadfield_util(fig, 'update_exec_push_status');
0104 case H.center_head_push
0105 pa_leadfield_make_center_sphere(fig);
0106 pa_leadfield_util(fig, 'update_exec_push_status');
0107 case {H.center_head_edit, H.conductivity_edit, ...
0108 H.sphere_radius_edit, H.head_file_edit}
0109 pa_leadfield_util(fig, 'update_exec_push_status');
0110 case H.leadfield_parm_push
0111 if ishandle(data.adv_fig)
0112 figure(data.adv_fig);
0113 else
0114 data.adv_fig = pa_leadfield_parm_gui_create(fig,data.basis_parm);
0115
0116 guidata(fig, data);
0117 end
0118 case H.check_push
0119 pa_leadfield_util(fig, 'check_model');
0120
0121
0122 case {H.figure, H.menu_close}
0123 pa_leadfield_close(fig);
0124 return;
0125 case H.menu_leadfield_calculation
0126 url = vb_users_manual_url('Leadfield calculation');
0127 vb_browser_show(url);
0128
0129 end