Home > vbmeg > external > mne > fiff_transform_eeg_chs.m

fiff_transform_eeg_chs

PURPOSE ^

SYNOPSIS ^

function [res, count] = fiff_transform_eeg_chs(chs,trans)

DESCRIPTION ^

 [res, count] = fiff_transform_eeg_chs(chs,trans)

 Move to another coordinate system in EEG channel channel info
 Count gives the number of channels transformed

 NOTE: Only the eeg_loc field is modified by this routine, not
 loc which remains to reflect the original data read from the fif file

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [res, count] = fiff_transform_eeg_chs(chs,trans)
0002 %
0003 % [res, count] = fiff_transform_eeg_chs(chs,trans)
0004 %
0005 % Move to another coordinate system in EEG channel channel info
0006 % Count gives the number of channels transformed
0007 %
0008 % NOTE: Only the eeg_loc field is modified by this routine, not
0009 % loc which remains to reflect the original data read from the fif file
0010 %
0011 %
0012 
0013 %
0014 %   Author : Matti Hamalainen, MGH Martinos Center
0015 %   License : BSD 3-clause
0016 %
0017 %
0018 %   Revision 1.7  2008/11/17 21:45:56  msh
0019 %   Fixed error in transforming the EEG location data to another coordinate frame
0020 %
0021 %   Revision 1.6  2006/05/03 18:53:05  msh
0022 %   Approaching Matlab 6.5 backward compatibility
0023 %
0024 %   Revision 1.5  2006/04/23 15:29:40  msh
0025 %   Added MGH to the copyright
0026 %
0027 %   Revision 1.4  2006/04/21 17:31:07  msh
0028 %   Added the examples.
0029 %   Modified the formatting of some informative output.
0030 %
0031 %   Revision 1.3  2006/04/18 20:44:46  msh
0032 %   Added reading of forward solution.
0033 %   Use length instead of size when appropriate
0034 %
0035 %   Revision 1.2  2006/04/17 15:01:34  msh
0036 %   More small improvements.
0037 %
0038 %   Revision 1.1  2006/04/17 11:52:15  msh
0039 %   Added coil definition stuff
0040 %
0041 %
0042 
0043 me='MNE:fiff_transform_eeg_chs';
0044 
0045 global FIFF;
0046 if isempty(FIFF)
0047    FIFF = fiff_define_constants();
0048 end
0049 
0050 if nargin ~= 2
0051     error(me,'Wrong number of arguments');
0052  end
0053 
0054 res = chs;
0055 if isempty(trans)
0056    return;
0057 end
0058 
0059 count=0;
0060 %
0061 %   Output unaugmented vectors from the transformation
0062 %
0063 t   = trans.trans(1:3,:);
0064 for k = 1:length(res)
0065     if res(k).kind == FIFF.FIFFV_EEG_CH
0066        if res(k).coord_frame == trans.from && ~isempty(res(k).eeg_loc)
0067            %
0068            % Transform the augmented EEG location vectors
0069            %
0070            for p = 1:size(res(k).eeg_loc,2)
0071                res(k).eeg_loc(:,p) = t*[ res(k).eeg_loc(:,p) ; 1 ];
0072            end
0073            count = count + 1;
0074            res(k).coord_frame = trans.to;
0075        end
0076     end
0077 end
0078 
0079 if count > 0
0080     fprintf(1,'\t%d EEG electrode locations transformed\n',count);
0081 end
0082 
0083 return;
0084 
0085 end

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