0001 function [res,proj,comp] = mne_ex_cancel_noise(data,dest_comp)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
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
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
0067
0068 if isempty(data.info.projs)
0069 fprintf(1,'No projector included with these data\n');
0070 else
0071
0072
0073
0074 for k = 1:length(res.info.projs)
0075 res.info.projs(k).active = true;
0076 end
0077
0078
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