FilterLFP - Filter the local field potentials, e.g. in the theta band. Filter the local field potentials using a cheby2 filter. USAGE filtered = FilterLFP(lfp,<options>) lfp local field potentials <a href="matlab:help samples">samples</a> <options> optional list of property-value pairs (see table below) ========================================================================= Properties Values ------------------------------------------------------------------------- 'passband' frequency range (default = [4 10], 'theta') 'order' filter order (default = 4, but see NOTE below) 'ripple' filter ripple (default = 20) 'nyquist' nyquist frequency (default = 625) 'filter' choose filter type between 'cheby2' (default) and 'fir1' ========================================================================= NOTE The passband can be supplied either explicitly, e.g. [30 80], or by name, by choosing among the following predefined frequency bands: delta [0 6] (order = 8) theta [4 10] spindles [9 17] gamma [30 80] ripples [100 250]
0001 function filtered = FilterLFP(lfp,varargin) 0002 0003 %FilterLFP - Filter the local field potentials, e.g. in the theta band. 0004 % 0005 % Filter the local field potentials using a cheby2 filter. 0006 % 0007 % USAGE 0008 % 0009 % filtered = FilterLFP(lfp,<options>) 0010 % 0011 % lfp local field potentials <a href="matlab:help samples">samples</a> 0012 % <options> optional list of property-value pairs (see table below) 0013 % 0014 % ========================================================================= 0015 % Properties Values 0016 % ------------------------------------------------------------------------- 0017 % 'passband' frequency range (default = [4 10], 'theta') 0018 % 'order' filter order (default = 4, but see NOTE below) 0019 % 'ripple' filter ripple (default = 20) 0020 % 'nyquist' nyquist frequency (default = 625) 0021 % 'filter' choose filter type between 'cheby2' (default) and 'fir1' 0022 % ========================================================================= 0023 % 0024 % NOTE 0025 % 0026 % The passband can be supplied either explicitly, e.g. [30 80], or by name, 0027 % by choosing among the following predefined frequency bands: 0028 % 0029 % delta [0 6] (order = 8) 0030 % theta [4 10] 0031 % spindles [9 17] 0032 % gamma [30 80] 0033 % ripples [100 250] 0034 0035 % Copyright (C) 2004-2015 by Michaƫl Zugaro 0036 % 0037 % This program is free software; you can redistribute it and/or modify 0038 % it under the terms of the GNU General Public License as published by 0039 % the Free Software Foundation; either version 3 of the License, or 0040 % (at your option) any later version. 0041 0042 % Default values 0043 passband = [4 10]; 0044 order = 4; 0045 0046 % Check number of parameters 0047 if nargin < 1 | mod(length(varargin),2) ~= 0, 0048 error('Incorrect number of parameters (type ''help <a href="matlab:help FilterLFP">FilterLFP</a>'' for details).'); 0049 end 0050 0051 % Check parameter sizes 0052 if ~isdmatrix(lfp), 0053 error('Parameter ''lfp'' is not a matrix (type ''help <a href="matlab:help FilterLFP">FilterLFP</a>'' for details).'); 0054 end 0055 0056 % Parse parameter list 0057 i = 1; 0058 while i <= length(varargin), 0059 if ~ischar(varargin{i}), 0060 error(['Parameter ' num2str(i) ' is not a property (type ''help <a href="matlab:help FilterLFP">FilterLFP</a>'' for details).']); 0061 end 0062 switch(lower(varargin{i})), 0063 case 'passband', 0064 passband = varargin{i+1}; 0065 if isastring(passband), 0066 switch(lower(passband)), 0067 case 'delta', 0068 passband = [0 6]; 0069 order = 8; 0070 case 'theta', 0071 passband = [4 10]; 0072 case 'spindles', 0073 passband = [9 17]; 0074 case 'gamma', 0075 passband = [30 80]; 0076 case 'ripples', 0077 passband = [100 250]; 0078 otherwise, 0079 error(['Unknown frequency band ''' passband ''' (type ''help <a href="matlab:help FilterLFP">FilterLFP</a>'' for details).']); 0080 end 0081 elseif ~isdvector(passband,'#2','>=0'), 0082 error('Incorrect value for ''passband'' (type ''help <a href="matlab:help FilterLFP">FilterLFP</a>'' for details).'); 0083 end 0084 varargin = {varargin{[1:(i-1) (i+2):length(varargin)]}}; 0085 otherwise, 0086 i = i+2; 0087 end 0088 end 0089 filtered = Filter(lfp,'passband',passband,'order',order,varargin{:});