Home > vbmeg > functions > device > acqdata > vb_megposfile_trans_coord.m

vb_megposfile_trans_coord

PURPOSE ^

translate YOKOGAWA coordinates by using transmat information from megposfile

SYNOPSIS ^

function [pick, Qpick] = vb_megposfile_trans_coord(megposfile, pick, Qpick)

DESCRIPTION ^

 translate YOKOGAWA coordinates by using transmat information from megposfile
 [usage]
   [pick, Qpick] = vb_megposfile_trans_coord(megposfile, pick, Qpick)
 [input]
   megposfile : <required> <<file>> megpos file
         pick : <required> 3D-coordinates of sensor [N x 3]
        Qpick : <optional> 3D-coordinates of vector [N x 3] []
 [output]
    pick : translated pick  [N x 3]
   Qpick : translated Qpick [N x 3]
 [note]
   if megposfile is empty, translation is not executed
 [history]
   2007-07-05 (Sako) initial version

 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 [pick, Qpick] = vb_megposfile_trans_coord(megposfile, pick, Qpick)
0002 % translate YOKOGAWA coordinates by using transmat information from megposfile
0003 % [usage]
0004 %   [pick, Qpick] = vb_megposfile_trans_coord(megposfile, pick, Qpick)
0005 % [input]
0006 %   megposfile : <required> <<file>> megpos file
0007 %         pick : <required> 3D-coordinates of sensor [N x 3]
0008 %        Qpick : <optional> 3D-coordinates of vector [N x 3] []
0009 % [output]
0010 %    pick : translated pick  [N x 3]
0011 %   Qpick : translated Qpick [N x 3]
0012 % [note]
0013 %   if megposfile is empty, translation is not executed
0014 % [history]
0015 %   2007-07-05 (Sako) initial version
0016 %
0017 % Copyright (C) 2011, ATR All Rights Reserved.
0018 % License : New BSD License(see VBMEG_LICENSE.txt)
0019 
0020 % --- CHECK ARGUMENTS --- %
0021 if ~exist('megposfile', 'var') megposfile = []; end
0022 if ~exist('pick', 'var') pick = []; end
0023 if ~exist('Qpick', 'var') Qpick = []; end
0024 [transmat, pick, Qpick] = inner_check_arguments(megposfile, pick, Qpick);
0025 
0026 % --- MAIN PROCEDURE --------------------------------------------------------- %
0027 %
0028 func_ = 'vb_megposfile_trans_coord';
0029 
0030 if isempty(transmat)
0031   % does not translate
0032   return;
0033 end
0034 
0035 pick  = vb_affine_trans(pick, transmat.meg_to_mri);
0036 
0037 if ~isempty(Qpick)
0038   % only rotate
0039   Qpick = vb_affine_trans(Qpick, transmat.meg_to_mri, 1);
0040 end
0041 
0042 return;
0043 %
0044 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0045 
0046 % --- INNER FUNCTIONS -------------------------------------------------------- %
0047 %
0048 % --- inner_check_arguments()
0049 %
0050 function [trans_mat, pick, Qpick] = ...
0051   inner_check_arguments(megposfile, pick, Qpick)
0052 func_ = 'vb_megposfile_trans_coord';
0053 
0054 trans_mat = [];
0055 
0056 if isempty(megposfile)
0057   % require no action
0058 else
0059   if exist(megposfile, 'file') ~= 2
0060     error('(%s)cannot find megpos file : %s', func_, megposfile);
0061   end
0062   
0063   load(megposfile, 'trans_mat');
0064 
0065   if isempty(trans_mat)
0066     error('(%s)megpos file does not have trans_mat attribute', func_);
0067   end
0068   
0069   if ~isfield(trans_mat, 'meg_to_mri')
0070     error('(%s)meg_to_mri is a required field of trans_mat', func_);
0071   end
0072 end
0073 
0074 if isempty(pick)
0075   error('(%s)pick is a required parameter', func_);
0076 end
0077 
0078 if isempty(Qpick)
0079   % required no action
0080   % there are some cases that Qpick is not needed
0081 end
0082 %
0083 % --- end of inner_check_arguments()
0084 %
0085 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0086 
0087 %%% END OF FILE %%%

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