Home > vbmeg > functions > job > vb_job_leadfield_extra.m

vb_job_leadfield_extra

PURPOSE ^

Lead field matrix for extra dipole (Biot-Savart)

SYNOPSIS ^

function vb_job_leadfield_extra(varargin)

DESCRIPTION ^

 Lead field matrix for extra dipole (Biot-Savart)
 
 [syntax]
 vb_job_leadfield_extra(extra_basis_parm)
 vb_job_leadfield_extra(proj_root,extra_basis_parm)    [old style]

 [input]
 proj_root       : <<string>> VBMEG project root directory. 
 extra_basis_parm: <<struct>> Parameters for leadfield calculation.
 --- fields of extra_basis_parm
  .meg_file  : <<string>> Load 'pick' and 'Vcenter' from this file.
  .mps_file  : <<string>> Extra dipole model file (.mps.mat)
  .basis_file: <<string>> Leadfield matrix is saved as this filename. 
  .sensortype: <optional> <<string>> This value is compared with
               MEGinfo.ChannelInfo.Type.
 ---

 [output]
 Leadfield file for extra-dipole (.basis.mat) is created. It have the
 same file with that for cortical surface model. 

 [example]
 >> proj_root = 'your_project_root_directory';
 >> extra_basis_parm.meg_file   = './testdata/sbj_test_UR.meg.mat';
 >> extra_basis_parm.mps_file   = './testdata/sbj_test_UR_eyes.mps.mat';
 >> extra_basis_parm.basis_file = './testdata/sbj_test_UR_eyes.basis.mat';
 >> vb_job_leadfield_extra(proj_root,extra_basis_parm);

 [history]
 2008-06-27 Taku Yoshioka
 2008-10-15 Taku Yoshioka
  Support '.sensortype' parameter
 2011-02-28 taku-y
  [debug] 'basis_file' is interpreted as a relative path from
  'proj_root'. 

 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 vb_job_leadfield_extra(varargin)
0002 % Lead field matrix for extra dipole (Biot-Savart)
0003 %
0004 % [syntax]
0005 % vb_job_leadfield_extra(extra_basis_parm)
0006 % vb_job_leadfield_extra(proj_root,extra_basis_parm)    [old style]
0007 %
0008 % [input]
0009 % proj_root       : <<string>> VBMEG project root directory.
0010 % extra_basis_parm: <<struct>> Parameters for leadfield calculation.
0011 % --- fields of extra_basis_parm
0012 %  .meg_file  : <<string>> Load 'pick' and 'Vcenter' from this file.
0013 %  .mps_file  : <<string>> Extra dipole model file (.mps.mat)
0014 %  .basis_file: <<string>> Leadfield matrix is saved as this filename.
0015 %  .sensortype: <optional> <<string>> This value is compared with
0016 %               MEGinfo.ChannelInfo.Type.
0017 % ---
0018 %
0019 % [output]
0020 % Leadfield file for extra-dipole (.basis.mat) is created. It have the
0021 % same file with that for cortical surface model.
0022 %
0023 % [example]
0024 % >> proj_root = 'your_project_root_directory';
0025 % >> extra_basis_parm.meg_file   = './testdata/sbj_test_UR.meg.mat';
0026 % >> extra_basis_parm.mps_file   = './testdata/sbj_test_UR_eyes.mps.mat';
0027 % >> extra_basis_parm.basis_file = './testdata/sbj_test_UR_eyes.basis.mat';
0028 % >> vb_job_leadfield_extra(proj_root,extra_basis_parm);
0029 %
0030 % [history]
0031 % 2008-06-27 Taku Yoshioka
0032 % 2008-10-15 Taku Yoshioka
0033 %  Support '.sensortype' parameter
0034 % 2011-02-28 taku-y
0035 %  [debug] 'basis_file' is interpreted as a relative path from
0036 %  'proj_root'.
0037 %
0038 % Copyright (C) 2011, ATR All Rights Reserved.
0039 % License : New BSD License(see VBMEG_LICENSE.txt)
0040 
0041 if length(varargin) == 1
0042   proj_root = [];
0043   extra_basis_parm = varargin{1};
0044 elseif length(varargin) == 2
0045   proj_root = varargin{1};
0046   extra_basis_parm = varargin{2};
0047 end
0048 
0049 
0050 proj_root = vb_rm_trailing_slash(proj_root);
0051 
0052 % Filename
0053 mpsfile = fullfile(proj_root, extra_basis_parm.mps_file);
0054 megfile = fullfile(proj_root, extra_basis_parm.meg_file);
0055 
0056 % Prepare extra dipole information
0057 load(mpsfile,'Pointlist');
0058 extra_pos = [];
0059 extra_direction = [];
0060 for i=1:length(Pointlist)
0061   % Three dipoles at each position
0062   extra_pos = [extra_pos; Pointlist{i}.point];
0063   extra_pos = [extra_pos; Pointlist{i}.point];
0064   extra_pos = [extra_pos; Pointlist{i}.point];
0065   extra_direction = [extra_direction; 1 0 0];
0066   extra_direction = [extra_direction; 0 1 0];
0067   extra_direction = [extra_direction; 0 0 1];
0068 end
0069 
0070 % Load MEG sensor
0071 [pick, Qpick, Wsensor, V0] = vb_load_sensor(megfile);
0072 % Wsensor(m,n) = n-th coil weight for m-th channel
0073 
0074 % Select channel (2008-10-15 Taku Yoshioka)
0075 if isfield(extra_basis_parm,'sensortype')
0076   sensortype = extra_basis_parm.sensortype;
0077   if ~isempty(sensortype), 
0078     MEGinfo = vb_load_measurement_info(megfile);
0079     ix_sensor = find(MEGinfo.ChannelInfo.Type==sensortype);
0080     ix_sensor2 = [ix_sensor; ix_sensor+length(ix_sensor)];
0081     pick = pick(ix_sensor2,:);
0082     Qpick = Qpick(ix_sensor2,:);
0083     Wsensor = Wsensor(ix_sensor,ix_sensor2);
0084   end
0085 end
0086 
0087 % Make extra dipole leadfield
0088 B = vb_dipole_magnetic(extra_pos, extra_direction, pick, Qpick );
0089 basis = B * Wsensor';
0090 
0091 % Save data
0092 vb_fsave(fullfile(proj_root, extra_basis_parm.basis_file), ...
0093          'extra_basis_parm','basis','Pointlist');

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