[res] = mne_transform_source_space_to(src,dest,trans) Transform source space data to the desired coordinate system src - The source space to transform dest - The id of the destination coordinate system (FIFFV_COORD_...) trans - The coordinate transformation structure to use
0001 function [res] = mne_transform_source_space_to(src,dest,trans) 0002 % 0003 % [res] = mne_transform_source_space_to(src,dest,trans) 0004 % 0005 % Transform source space data to the desired coordinate system 0006 % 0007 % src - The source space to transform 0008 % dest - The id of the destination coordinate system (FIFFV_COORD_...) 0009 % trans - The coordinate transformation structure to use 0010 % 0011 0012 % 0013 % 0014 % Author : Matti Hamalainen, MGH Martinos Center 0015 % License : BSD 3-clause 0016 % 0017 % Revision 1.4 2008/04/04 16:00:28 msh 0018 % Forgot to set the coordinate frame of the result correctly 0019 % 0020 % Revision 1.3 2006/05/03 18:53:06 msh 0021 % Approaching Matlab 6.5 backward compatibility 0022 % 0023 % Revision 1.2 2006/04/23 15:29:41 msh 0024 % Added MGH to the copyright 0025 % 0026 % Revision 1.1 2006/04/18 23:21:22 msh 0027 % Added mne_transform_source_space_to and mne_transpose_named_matrix 0028 % 0029 % 0030 0031 me='MNE:mne_transform_source_space_to'; 0032 0033 global FIFF; 0034 if isempty(FIFF) 0035 FIFF = fiff_define_constants(); 0036 end 0037 0038 if nargin ~= 3 0039 error(me,'Incorrect number of arguments'); 0040 end 0041 0042 if src.coord_frame == dest 0043 res = src; 0044 return; 0045 end 0046 0047 if trans.to == src.coord_frame && trans.from == dest 0048 trans = fiff_invert_transform(trans); 0049 elseif trans.from ~= src.coord_frame || trans.to ~= dest 0050 error(me,'Cannot transform the source space using this coordinate transformation'); 0051 end 0052 0053 t = trans.trans(1:3,:); 0054 res = src; 0055 res.coord_frame = dest; 0056 res.rr = (t*[ res.rr ones(res.np,1) ]')'; 0057 res.nn = (t*[ res.nn zeros(res.np,1) ]')'; 0058 0059 return; 0060 0061 end 0062 0063