transform coordinate system of sensor [usage] [new_pick, new_Qpick, new_type] = ... meg_change_coordinate(org_pick, org_Qpick, org_type, posfile) [input] org_pick : <required> [Nchannel x 3] sensor coordinate org_Qpick : <optional> [Nchannel x 3] sensor vector [] org_type : <optional> <<string>> coordinate type of org_pick posfile : <optional> <<file>> POS-MAT file [''] : if this is empty, org_pick and org_Qpick are not transformed. [output] new_pick : transformed sensor coordinate [Nchannel x 3] new_Qpick : transformed sensor vector [Nchannel x 3] new_type : new coordinate type e.g. 'SPM_Right_m' [note] [history] 2008-03-13 (Sako) initial version 2009-04-15 (Sako) modified serious bug of calling vb_affine_trans for Qpick 2009-08-10 (Sako) added to check coord types between current and trans_after Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [new_pick, new_Qpick, new_type] = ... 0002 vb_meg_transform_coordinate(org_pick, org_Qpick, org_type, posfile) 0003 % transform coordinate system of sensor 0004 % [usage] 0005 % [new_pick, new_Qpick, new_type] = ... 0006 % meg_change_coordinate(org_pick, org_Qpick, org_type, posfile) 0007 % [input] 0008 % org_pick : <required> [Nchannel x 3] sensor coordinate 0009 % org_Qpick : <optional> [Nchannel x 3] sensor vector [] 0010 % org_type : <optional> <<string>> coordinate type of org_pick 0011 % posfile : <optional> <<file>> POS-MAT file [''] 0012 % : if this is empty, org_pick and org_Qpick are not transformed. 0013 % [output] 0014 % new_pick : transformed sensor coordinate [Nchannel x 3] 0015 % new_Qpick : transformed sensor vector [Nchannel x 3] 0016 % new_type : new coordinate type e.g. 'SPM_Right_m' 0017 % [note] 0018 % 0019 % [history] 0020 % 2008-03-13 (Sako) initial version 0021 % 2009-04-15 (Sako) modified serious bug of calling vb_affine_trans for Qpick 0022 % 2009-08-10 (Sako) added to check coord types between current and trans_after 0023 % 0024 % Copyright (C) 2011, ATR All Rights Reserved. 0025 % License : New BSD License(see VBMEG_LICENSE.txt) 0026 0027 % --- CHECK ARGUMENTS --- % 0028 if ~exist('org_pick', 'var'), org_pick = []; end 0029 if ~exist('org_Qpick', 'var'), org_Qpick = []; end 0030 if ~exist('org_type', 'var'), org_type = ''; end 0031 if ~exist('posfile', 'var'), posfile = []; end 0032 [org_pick, org_Qpick, trans_mri, new_type] = ... 0033 inner_check_arguments(org_pick, org_Qpick, org_type, posfile); 0034 0035 % --- MAIN PROCEDURE --------------------------------------------------------- % 0036 % 0037 if isempty(trans_mri) 0038 % does not translate 0039 new_pick = org_pick; 0040 new_Qpick = org_Qpick; 0041 return; 0042 end 0043 0044 new_pick = vb_affine_trans(org_pick, trans_mri); 0045 0046 if ~isempty(org_Qpick) 0047 % only rotate 0048 new_Qpick = vb_affine_trans(org_Qpick, trans_mri, 1); 0049 else 0050 new_Qpick = []; 0051 end 0052 return; 0053 % 0054 % --- END OF MAIN PROCEDURE -------------------------------------------------- % 0055 0056 % --- INNER FUNCTIONS -------------------------------------------------------- % 0057 % 0058 % --- inner_check_arguments() 0059 % 0060 function [pick, Qpick, trans_mri, new_type] = ... 0061 inner_check_arguments(pick, Qpick, old_type, posfile) 0062 func_ = mfilename; 0063 0064 trans_mri = []; 0065 % new_coord_type = type; 0066 0067 if isempty(pick) 0068 error('(%s)org_pick is a required parameter', func_); 0069 end 0070 0071 if isempty(Qpick) 0072 % require no action for now 0073 end 0074 0075 if isempty(posfile) 0076 trans_mri = []; 0077 new_type = old_type; 0078 0079 elseif exist(posfile, 'file') ~= 2 0080 error('(%s)cannot find posfile : %s', func_, posfile); 0081 0082 else 0083 0084 [trans_mri, type_bef, type_aft] = vb_posfile_get_transinfo(posfile); 0085 if strcmp(old_type, type_aft) 0086 trans_mri = []; 0087 new_type = old_type; 0088 else 0089 new_type = type_aft; 0090 end 0091 end 0092 return 0093 % 0094 % --- end of inner_check_arguments() 0095 % 0096 % --- END OF INNER FUNCTIONS ------------------------------------------------- % 0097 0098 % --- END OF FILE --- %