Home > vbmeg > functions > leadfield > vb_job_leadfield_meg_harmonics.m

vb_job_leadfield_meg_harmonics

PURPOSE ^

actual worker function for MEG SPHERICAL HARMINICS

SYNOPSIS ^

function [basis, basis_parm] =vb_job_leadfield_meg_harmonics(proj_root, basis_parm)

DESCRIPTION ^

 actual worker function for MEG SPHERICAL HARMINICS
 [usage]
   [basis, basis_parm] = vb_job_leadfield_meg_harmonics(proj_root, basis_parm)
 [input]
    proj_root : <required> project root directory
   basis_parm : <required> <<struct>>
              :  data set in which the specification of calculation is defined
 [output]
   none
 [note]
   <<prior conditions>>
     1) proj_root is valid
     2) basis_parm is commonly valid
 [history]
   2007-01-26 (Sako) initial version
   2010-01-29 (Sako) replaced vb_load_meg_info with vb_load_measurement_info

 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 [basis, basis_parm] = ...
0002   vb_job_leadfield_meg_harmonics(proj_root, basis_parm)
0003 % actual worker function for MEG SPHERICAL HARMINICS
0004 % [usage]
0005 %   [basis, basis_parm] = vb_job_leadfield_meg_harmonics(proj_root, basis_parm)
0006 % [input]
0007 %    proj_root : <required> project root directory
0008 %   basis_parm : <required> <<struct>>
0009 %              :  data set in which the specification of calculation is defined
0010 % [output]
0011 %   none
0012 % [note]
0013 %   <<prior conditions>>
0014 %     1) proj_root is valid
0015 %     2) basis_parm is commonly valid
0016 % [history]
0017 %   2007-01-26 (Sako) initial version
0018 %   2010-01-29 (Sako) replaced vb_load_meg_info with vb_load_measurement_info
0019 %
0020 % Copyright (C) 2011, ATR All Rights Reserved.
0021 % License : New BSD License(see VBMEG_LICENSE.txt)
0022 
0023 % --- CHECK ARGUMENTS --- %
0024 [proj_root, basis_parm] = inner_check_arguments(proj_root, basis_parm);
0025 
0026 % --- MAIN PROCEDURE --------------------------------------------------------- %
0027 %
0028 
0029 % pre-processing
0030 [Basis_mode, pick, Qpick, Wsensor, V0, V, xx] = ...
0031   vb_lf_preprocess(proj_root, basis_parm);
0032 
0033 % Load head file
0034 head_file   = [proj_root filesep basis_parm.head_file];
0035 load([head_file], 'Vhead', 'Fhead', 'XXhead');
0036     
0037 % Center of Head
0038 if basis_parm.DEBUG == ON,
0039     % Setting for DEBUG to check Leadfield calculation
0040     Hcenter = [0 0 0];
0041 else
0042     Hcenter = mean(Vhead);
0043 end
0044     
0045 % Change center of coordinate
0046 Vhead = [Vhead(:,1)-Hcenter(1), Vhead(:,2)-Hcenter(2), Vhead(:,3)-Hcenter(3)];
0047 V     = [    V(:,1)-Hcenter(1),     V(:,2)-Hcenter(2),     V(:,3)-Hcenter(3)];
0048 pick  = [ pick(:,1)-Hcenter(1),  pick(:,2)-Hcenter(2),  pick(:,3)-Hcenter(3)];
0049 
0050 % Calculate current direction according to 'Basis_mode'
0051 [V,xx] = vb_current_vector(V, xx, Basis_mode);
0052 
0053 fprintf('# of vertices = %d\n',size(Vhead,1));
0054     
0055 % load meg file
0056 meg_file = [proj_root filesep basis_parm.meg_file];
0057 MEGinfo = vb_load_measurement_info(meg_file);
0058     
0059 if ~isfield(MEGinfo,'SPHinfo') | basis_parm.Recalc == ON,
0060        
0061     % average radius from center of head
0062     Rmax = vb_average_radius(Hcenter, Vhead);
0063 
0064     % function order
0065     func_order = basis_parm.func_order;
0066         
0067     % Calculate spherical harmonics coefficient
0068     SPHinfo.harmo_coef = ...
0069             vb_spherical_harmo_coef(Vhead, XXhead, func_order, Rmax, pick, Qpick);
0070 
0071     % Save SPHinfo to MEGinfo
0072     SPHinfo.func_order = func_order;
0073     SPHinfo.radius     = Rmax;
0074   SPHinfo.head_file  = basis_parm.head_file;
0075     MEGinfo.SPHinfo    = SPHinfo;
0076 
0077     vb_save(meg_file, 'MEGinfo');
0078 else
0079     % Saved result
0080     SPHinfo = MEGinfo.SPHinfo;
0081 end
0082     
0083 %  MEG Spherical harmonics expansion
0084 fprintf('--- MEG Spherical Harmonics expansion ');
0085 N    = SPHinfo.func_order;
0086 Rmax = SPHinfo.radius;
0087 A    = SPHinfo.harmo_coef;
0088 
0089 BB = vb_spherical_harmo_magnetic_field(V, xx, N, Rmax, pick, Qpick, A);
0090     
0091 basis = BB * Wsensor';
0092 
0093 %
0094 % --- MAIN PROCEDURE --------------------------------------------------------- %
0095 
0096 
0097 % --- INNER FUNCTIONS -------------------------------------------------------- %
0098 %
0099 function [proj_root, basis_parm] = inner_check_arguments(proj_root, basis_parm)
0100 if ~isfield(basis_parm, 'func_order'),
0101     % Order of spherical harmonics function
0102     basis_parm.func_order = 35;
0103 end
0104 
0105 % if you have other check points, you can do them here ...
0106 
0107 return;
0108 %
0109 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0110 
0111 %%% END OF FILE %%%

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