Home > utils > physio > physio_filt_highlow.m

physio_filt_highlow

PURPOSE ^

high- and/or low-pass continuous data in an EEGlab struct using eegfilt

SYNOPSIS ^

function EEG = physio_filt_highlow(EEG,defs)

DESCRIPTION ^

 high- and/or low-pass continuous data in an EEGlab struct using eegfilt
 
   EEG = physio_filt_highlow(EEG,defs)
 
 REQUIRES
   EEG - an EEGlab data structure
   defs.physio_filt_highlow.high_cutoff - high pass filter cutoff in Hz
   defs.physio_filt_highlow.low_cutoff - low pass filter cutoff in Hz
   defs.physio_filt_highlow.filt_order
   defs.physio_filt_highlow.channel - name of channel
 
 RETURN
   EEG - an EEGlab data structure, with the given signal having been
   filtered
 
 FB 2009.04.20

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function EEG = physio_filt_highlow(EEG,defs)
0002 
0003 % high- and/or low-pass continuous data in an EEGlab struct using eegfilt
0004 %
0005 %   EEG = physio_filt_highlow(EEG,defs)
0006 %
0007 % REQUIRES
0008 %   EEG - an EEGlab data structure
0009 %   defs.physio_filt_highlow.high_cutoff - high pass filter cutoff in Hz
0010 %   defs.physio_filt_highlow.low_cutoff - low pass filter cutoff in Hz
0011 %   defs.physio_filt_highlow.filt_order
0012 %   defs.physio_filt_highlow.channel - name of channel
0013 %
0014 % RETURN
0015 %   EEG - an EEGlab data structure, with the given signal having been
0016 %   filtered
0017 %
0018 % FB 2009.04.20
0019 
0020 % try
0021   channel = defs.physio_filt_highlow.channel;
0022   if iscell(channel), channel = channel{1}; end
0023   cidx = strmatch(channel,{EEG.chanlocs(:).labels});
0024   if isempty(cidx)
0025       error('target channel %s can not be found within EEG.chanlocs\n',...
0026           channel);
0027   elseif length(cidx) > 1
0028       warning('many channels match target channel %s, using first one\n',...
0029           channel);
0030       cidx = cidx(1);
0031   end
0032 % catch
0033 %   error('no target channel defined in defs.physio...artifact.channel\n');
0034 % end
0035 try lowcut = defs.physio_filt_highlow.low_cutoff; catch lowcut = []; end
0036 try highcut = defs.physio_filt_highlow.high_cutoff; catch highcut = []; end
0037 try fo = defs.physio_filt_highlow.filt_order; catch fo = []; end
0038 
0039 if (~isempty(lowcut) || ~isempty(highcut))
0040 
0041   eeglab('initpaths');
0042 
0043   % Filter data  - do highpass and low-pass in separate stages to avoid
0044   % numerical problems
0045   if lowcut
0046     EEG.data(cidx,:) = eegfilt(EEG.data(cidx,:),EEG.srate,lowcut,0,0,fo);
0047   end
0048   if highcut
0049     EEG.data(cidx,:) = eegfilt(EEG.data(cidx,:),EEG.srate,0,highcut,0,[]);
0050   end
0051 end

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003