Home > vbmeg > external > mne > mne_ex_cancel_noise.m

mne_ex_cancel_noise

PURPOSE ^

SYNOPSIS ^

function [res,proj,comp] = mne_ex_cancel_noise(data,dest_comp)

DESCRIPTION ^

   Do projection and compensation as needed
   Return the appropriate operators
   
   [res,proj,comp] = mne_ex_cancel_noise(data,dest_comp)

   res     - Data after noise cancellation
   proj    - The projection operator applied
   comp    - The compensator which brings uncompensated data to the
             desired compensation grade (will be useful in forward
             calculations)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [res,proj,comp] = mne_ex_cancel_noise(data,dest_comp)
0002 %
0003 %   Do projection and compensation as needed
0004 %   Return the appropriate operators
0005 %
0006 %   [res,proj,comp] = mne_ex_cancel_noise(data,dest_comp)
0007 %
0008 %   res     - Data after noise cancellation
0009 %   proj    - The projection operator applied
0010 %   comp    - The compensator which brings uncompensated data to the
0011 %             desired compensation grade (will be useful in forward
0012 %             calculations)
0013 %
0014 
0015 %
0016 %   Author : Matti Hamalainen, MGH Martinos Center
0017 %   License : BSD 3-clause
0018 %
0019 %   Revision 1.4  2006/05/05 03:50:40  msh
0020 %   Added routines to compute L2-norm inverse solutions.
0021 %   Added mne_write_inverse_sol_stc to write them in stc files
0022 %   Several bug fixes in other files
0023 %
0024 %   Revision 1.3  2006/04/27 20:57:41  msh
0025 %   Fixed typo on line 76 of mne_ex_cancel_noise
0026 %
0027 %   Revision 1.2  2006/04/23 15:29:40  msh
0028 %   Added MGH to the copyright
0029 %
0030 %   Revision 1.1  2006/04/21 17:31:07  msh
0031 %   Added the examples.
0032 %   Modified the formatting of some informative output.
0033 %
0034 %
0035 
0036 me='MNE:mne_ex_cancel_noise';
0037 
0038 if nargin == 1
0039     dest_comp = 0;
0040 elseif nargin ~= 2
0041     error(me,'Incorrect number of arguments');
0042 end
0043 %
0044 %   Compensate the data and make a compensator for forward modelling
0045 %
0046 comp = [];
0047 proj = [];
0048 comp_now = mne_get_current_comp(data.info);
0049 if comp_now == dest_comp
0050     res = data;
0051 else
0052     try 
0053         res  = mne_compensate_to(data,dest_comp);
0054         fprintf(1,'The data are now compensated to grade %d.\n',dest_comp);
0055     catch
0056         error(me,'%s',mne_omit_first_line(lasterr));
0057     end
0058 end
0059 if dest_comp > 0
0060     comp = mne_make_compensator(res.info,0,dest_comp);
0061     fprintf(1,'Appropriate forward operator compensator created.\n');
0062 else
0063     fprintf(1,'No forward operator compensator needed.\n');
0064 end
0065 %
0066 %   Do the projection
0067 %
0068 if isempty(data.info.projs)
0069     fprintf(1,'No projector included with these data\n');
0070 else
0071     %
0072     %   Activate the projection items
0073     %
0074     for k = 1:length(res.info.projs)
0075         res.info.projs(k).active = true;
0076     end
0077     %
0078     %   Create the projector
0079     %
0080     [proj,nproj] = mne_make_projector_info(res.info);
0081     if nproj == 0
0082         fprintf(1,'The projection vectors do not apply to these channels\n');
0083         proj = [];
0084     else
0085         fprintf(1,'Created an SSP operator (subspace dimension = %d)\n',nproj);
0086         res.evoked.epochs = proj*res.evoked.epochs;
0087         fprintf(1,'Projector applied to the data\n');
0088     end
0089 end
0090 
0091 return;
0092 
0093 end

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