Home > vbmeg > functions > job > job_view_leadfield_dir > job_view_leadfield.m

job_view_leadfield

PURPOSE ^

View spatial pattern of lead field in sensor space

SYNOPSIS ^

function job_view_leadfield(basisfile,brainfile,model)

DESCRIPTION ^

 View spatial pattern of lead field in sensor space

 --- Syntax
 job_view_leadfield(basisfile,brainfile,model)

 --- Input
 basisfile: Leadfield file (.basis.mat)
 brainfile: Cortex model file (.brain.mat)
 model    : 0 for original (folded), 1 for inflated display

 --- Example
 job_view_leadfield('./sbj1/basis/meg_visual_exp.basis.mat', ...
                    './sbj1/data/3D.brain.mat');

 --- Variables in vbmeg_inst.viewlf{n}
 .brainfile
 .model (indicating original or inflated display)
 .V (Vertex coordinate values for original cortical surface model)
 .Vinf (Vertex coordinate values for inflated cortical surface model)
 .F (Face information)
 .inf_C (Face color for inflated model)
 .xxA (Cortical area size for vertices)
 .Vtal (Standard brain coordinate values)
 .nextDD (Distance to the neighbouring vertices)
 .nextIX (Indices of the neighbouring vertices)
 .J (Activity pattern; lf norm, correlation)
 .plot_parm (Structure of plot parameters)

 .basisfile
 .basis_org (original lead field pattern)

 --- History
 2008-01-26 Taku Yoshioka

 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_view_leadfield(basisfile,brainfile,model)
0002 % View spatial pattern of lead field in sensor space
0003 %
0004 % --- Syntax
0005 % job_view_leadfield(basisfile,brainfile,model)
0006 %
0007 % --- Input
0008 % basisfile: Leadfield file (.basis.mat)
0009 % brainfile: Cortex model file (.brain.mat)
0010 % model    : 0 for original (folded), 1 for inflated display
0011 %
0012 % --- Example
0013 % job_view_leadfield('./sbj1/basis/meg_visual_exp.basis.mat', ...
0014 %                    './sbj1/data/3D.brain.mat');
0015 %
0016 % --- Variables in vbmeg_inst.viewlf{n}
0017 % .brainfile
0018 % .model (indicating original or inflated display)
0019 % .V (Vertex coordinate values for original cortical surface model)
0020 % .Vinf (Vertex coordinate values for inflated cortical surface model)
0021 % .F (Face information)
0022 % .inf_C (Face color for inflated model)
0023 % .xxA (Cortical area size for vertices)
0024 % .Vtal (Standard brain coordinate values)
0025 % .nextDD (Distance to the neighbouring vertices)
0026 % .nextIX (Indices of the neighbouring vertices)
0027 % .J (Activity pattern; lf norm, correlation)
0028 % .plot_parm (Structure of plot parameters)
0029 %
0030 % .basisfile
0031 % .basis_org (original lead field pattern)
0032 %
0033 % --- History
0034 % 2008-01-26 Taku Yoshioka
0035 %
0036 % Copyright (C) 2011, ATR All Rights Reserved.
0037 % License : New BSD License(see VBMEG_LICENSE.txt)
0038 
0039 %
0040 % Input parameter check
0041 %
0042 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0043 if nargin<3, model = 1; end
0044 if nargin<2, brainfile = []; end
0045 if nargin<1, basisfile = []; end
0046 
0047 inst_id = create_instance;
0048 if isempty(inst_id), return; end; 
0049 
0050 %
0051 % Create GUI and update plots
0052 %
0053 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0054 create_GUI(inst_id,basisfile,brainfile,model);
0055 job_view_lf_update_cortexpattern(inst_id);
0056 job_view_lf_update_sensorpattern(inst_id);
0057 
0058 %%%
0059 %%% Inner functions
0060 %%%
0061 
0062 %
0063 % Create instance of GUI
0064 % i: Instance ID of job_plot_currentmap
0065 %
0066 function inst_id = create_instance
0067 
0068 global vbmeg_inst
0069 
0070 if isfield(vbmeg_inst,'viewlf'),
0071   for inst_id=1:vbmeg_inst.const.VIEWLF_MAX
0072     if isempty(vbmeg_inst.viewlf{inst_id}), return; end;
0073   end
0074   fprintf(['The number of instances of ''job_view_leadfield''' ...
0075        ' GUIs reaches the maximum number.\n']);
0076   inst_id = [];
0077 elseif isfield(vbmeg_inst,'const'), 
0078   vbmeg_inst.viewlf = cell(vbmeg_inst.const.VIEWLF_MAX,1);
0079   inst_id = 1;
0080 else
0081   fprintf(['''vbmeg_inst'' was not correct. You have to invoke' ...
0082        '''vbmeg'' to create an instance of VBMEG.\n']); 
0083   inst_id = []; 
0084 end
0085 
0086 %
0087 % Create GUI
0088 %
0089 function create_GUI(inst_id,basisfile,brainfile,model)
0090 
0091 global vbmeg_inst;
0092 
0093 %
0094 % Initialize parameters
0095 %
0096 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0097 
0098 % Cortical surface model
0099 viewlf.brainfile = brainfile;
0100 viewlf.V = [];
0101 viewlf.Vinf = [];
0102 viewlf.F = [];
0103 viewlf.inf_C = [];
0104 viewlf.xxA = [];
0105 viewlf.nextDD = [];
0106 viewlf.nextIX = [];
0107 %viewlf.Vtal = [];
0108 %viewlf.J = [];
0109 
0110 % Lead field and sensor data
0111 viewlf.basisfile = [];
0112 viewlf.basis_org = [];
0113 viewlf.basis_org_smoothed = [];
0114 viewlf.pick = [];
0115 viewlf.MEGinfo = [];
0116   
0117 % Display parameters
0118 viewlf.ix_selected_vertex = 1;
0119 viewlf.Jmin_plot = -1;
0120 viewlf.Jmax_plot = 1;
0121 viewlf.Bmin_plot = -100;
0122 viewlf.Bmax_plot = 100;
0123 viewlf.sensor_type = 2;
0124 viewlf.plot_parm = vb_set_plot_parm;
0125 viewlf.plot_parm.index = [];
0126 viewlf.plot_parm.LRflag = 'LR';
0127 %viewlf.ix_selected_area = [];
0128 
0129 %
0130 % GUI open
0131 %
0132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0133 h_fig = open('job_view_leadfield.fig');
0134 set(h_fig,'HandleVisibility','on');
0135 drawnow; 
0136 set(h_fig,'Pointer','watch');
0137 
0138 % Input parameter
0139 viewlf.model_type = model;
0140 
0141 %
0142 % Handles of GUI components
0143 %
0144 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0145 % Figure and axis
0146 viewlf.h_fig = h_fig;
0147 viewlf.h_cortex = get_child_handle(h_fig,'plot_cortex');
0148 %viewlf.h_cbar_cortex = get_child_handle(h_fig,'cortex_colorbar');
0149 viewlf.h_sensor = get_child_handle(h_fig,'plot_sensor');
0150 %viewlf.h_cbar_sensor = get_child_handle(h_fig,'sensor_colorbar');
0151 
0152 % Editable text
0153 viewlf.ed1 = get_child_handle(h_fig,'vertex_index');
0154 viewlf.ed2 = get_child_handle(h_fig,'lf_power');
0155 viewlf.ed3 = get_child_handle(h_fig,'filter_radius');
0156 
0157 % Push button
0158 viewlf.pb1 = get_child_handle(h_fig,'left_button');
0159 viewlf.pb2 = get_child_handle(h_fig,'right_button');
0160 viewlf.pb3 = get_child_handle(h_fig,'top_button');
0161 viewlf.pb4 = get_child_handle(h_fig,'bottom_button');
0162 viewlf.pb5 = get_child_handle(h_fig,'rotate');
0163 viewlf.pb6 = get_child_handle(h_fig,'select_vertex');
0164 viewlf.pb7 = get_child_handle(h_fig,'print');
0165 
0166 % Radio button
0167 viewlf.rb1 = get_child_handle(h_fig,'model_type_original_rb');
0168 viewlf.rb2 = get_child_handle(h_fig,'model_type_inflate_rb');
0169 
0170 % Checkbox
0171 viewlf.cb1 = get_child_handle(h_fig,'left_brain');
0172 viewlf.cb2 = get_child_handle(h_fig,'right_brain');
0173 viewlf.cb3 = get_child_handle(h_fig,'fix_cortex_colorbar');
0174 viewlf.cb4 = get_child_handle(h_fig,'fix_sensor_colorbar');
0175 
0176 % Menu
0177 viewlf.load_cortex_menu ...
0178     = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0179                        'load_cortex_menu');
0180 viewlf.load_leadfield_menu ...
0181     = get_child_handle(get_child_handle(h_fig,'file_menu'),...
0182                        'load_leadfield_menu');
0183 viewlf.loaded_files_menu ...
0184     = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0185                        'loaded_files_menu');
0186 viewlf.close_menu ...
0187     = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0188                        'close_menu');
0189 
0190 % Set GUI values
0191 set(viewlf.ed1,'String','1');
0192 
0193 %
0194 % Callback functions
0195 %
0196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0197 inst_str = num2str(inst_id); 
0198 viewlf_str = ['vbmeg_inst.viewlf{' inst_str '}'];
0199 
0200 % Remove instance after window close
0201 command = ['global vbmeg_inst; '...
0202        'vbmeg_inst.viewlf{' inst_str '}=[];'];
0203 set(h_fig,'DeleteFcn',command);
0204 
0205 % Change vertex
0206 command = ['global vbmeg_inst;' ...
0207        viewlf_str '.ix_selected_vertex = ' ...
0208        'str2num(get(' viewlf_str '.ed1,''String''));' ...
0209            'job_view_lf_update_cortexpattern(' inst_str ');' ...
0210        'job_view_lf_update_sensorpattern(' inst_str ');'];
0211 set(viewlf.ed1,'Callback',command);
0212 
0213 % Change filter radius
0214 command = ['job_view_lf_change_filter_radius(' inst_str ');'];
0215 set(viewlf.ed3,'Callback',command);
0216 
0217 % Change angle
0218 command = ['job_view_lf_change_angle(' inst_str ',''left'');'];
0219 set(viewlf.pb1,'Callback',command);
0220 command = ['job_view_lf_change_angle(' inst_str ',''right'');'];
0221 set(viewlf.pb2,'Callback',command);
0222 command = ['job_view_lf_change_angle(' inst_str ',''top'');'];
0223 set(viewlf.pb3,'Callback',command);
0224 command = ['job_view_lf_change_angle(' inst_str ',''bottom'');'];
0225 set(viewlf.pb4,'Callback',command);
0226 
0227 % Rotation of cortex model
0228 command = ['job_view_lf_push_rotate_button(' inst_str ');']; 
0229 set(viewlf.pb5,'Callback',command);
0230 
0231 % Select vertex
0232 command = ['job_view_lf_selvertex(' inst_str ');'];
0233 set(viewlf.pb6,'Callback',command);
0234 
0235 % Print figure (not implemented yet)
0236 command = ['job_view_lf_print(' inst_str ');'];
0237 set(viewlf.pb7,'Callback',command);
0238 
0239 % Change filter radius
0240 %command = ['job_plot_cmap_update_filterradius(' inst_str ');' ...
0241 %           'job_plot_cmap_update_spatialpattern(' inst_str ');' ...
0242 %       'job_plot_cmap_update_timecourse(' inst_str ');'];
0243 %set(viewlf.ed5,'Callback',command);
0244 
0245 % Folded/Inflated model
0246 %model_type_group = [viewlf.model_type_inflate_rb,
0247 %                    viewlf.model_type_original_rb];
0248 model_type_group = [viewlf.rb1, viewlf.rb2];
0249 command = ['job_view_lf_change_modeltype(' inst_str ');'];
0250 set(model_type_group, 'Callback', command);
0251 set(model_type_group, 'Value',get(viewlf.rb1,'Min')); % both off
0252 if model == 0, set(viewlf.rb1,'Value',get(viewlf.rb1,'Max'));
0253 else set(viewlf.rb2,'Value',get(viewlf.rb2,'Max')); end
0254 
0255 % Left/Right brain
0256 command = ['job_view_lf_update_cortexpattern(' inst_str ');'];
0257 set(viewlf.cb1,'Callback',command);
0258 set(viewlf.cb2,'Callback',command);
0259 
0260 % Fix color scale
0261 command = ['job_view_lf_update_cortexpattern(' inst_str ');'];
0262 set(viewlf.cb3,'Callback',command);
0263 command = ['job_view_lf_update_sensorpattern(' inst_str ');'];
0264 set(viewlf.cb4,'Callback',command);
0265 
0266 % Cancel
0267 set(h_fig,'WindowButtonUpFcn','rotate3d off;');
0268 
0269 % Load cortical surface model
0270 command = ['[brain_dir,brain_file] = vb_file_select' ...
0271            '({''.brain.mat''},''Load cortical surface model'');' ...
0272            'if ~isempty(brain_file), ' ...
0273        'job_view_lf_load_cortex(' inst_str ',' ...
0274            '[brain_dir filesep brain_file{1}]); end'];
0275 set(viewlf.load_cortex_menu, 'Callback', command);
0276 
0277 % Load lead field data
0278 command = ['[basis_dir,basis_file] = vb_file_select' ...
0279            '({''.basis.mat''},''Load leadfield data'');' ...
0280            'if ~isempty(basis_file), ' ...
0281        'job_view_lf_load_leadfield(' inst_str ',' ...
0282            '[basis_dir filesep basis_file{1}]); end'];
0283 set(viewlf.load_leadfield_menu, 'Callback', command);
0284 
0285 % Show loaded files (not yet implemented)
0286 command = ['job_view_lf_show_loaded_files(' inst_str ');']; 
0287 set(viewlf.loaded_files_menu, 'Callback', command);
0288 
0289 % Close window
0290 command = 'close;';
0291 set(viewlf.close_menu,'Callback',command);
0292 
0293 %
0294 % Properties of axis for cortex plot
0295 %
0296 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0297 set(h_fig,'Renderer','zbuffer');
0298 set(h_fig,'CurrentAxes',viewlf.h_cortex);
0299 axis off;
0300 set(h_fig,'CurrentAxes',viewlf.h_sensor);
0301 axis off;
0302 %axis tight; % 2006/11/22 hayashi delete
0303 %axis equal; % These commands causes axes LimMode change(auto-->manual)
0304              % after MATLAB 7.0.1. and brain model is not displayed.
0305 
0306 %
0307 % Set instance
0308 %
0309 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0310 vbmeg_inst.viewlf{inst_id} = viewlf; 
0311 
0312 % Set pointer to arrow
0313 set(h_fig,'Pointer','arrow');
0314 
0315 %
0316 % Load cortical surface model
0317 %
0318 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0319 if ~isempty(brainfile),
0320   job_view_lf_load_cortex(inst_id,brainfile);
0321 end
0322 
0323 %
0324 % Load estimated current
0325 %
0326 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0327 if ~isempty(basisfile),
0328   job_view_lf_load_leadfield(inst_id,basisfile);
0329 end

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