neurodsp.filt.design_fir_filter¶
- neurodsp.filt.design_fir_filter(fs, pass_type, f_range, n_cycles=None, n_seconds=None)[source]¶
Design an FIR filter.
- Parameters:
- fsfloat
Sampling rate, in Hz.
- pass_type{‘bandpass’, ‘bandstop’, ‘lowpass’, ‘highpass’}
Which kind of filter to apply:
‘bandpass’: apply a bandpass filter
‘bandstop’: apply a bandstop (notch) filter
‘lowpass’: apply a lowpass filter
‘highpass’ : apply a highpass filter
- f_rangetuple of (float, float) or float
Cutoff frequency(ies) used for filter, specified as f_lo & f_hi. For ‘bandpass’ & ‘bandstop’, must be a tuple. For ‘lowpass’ or ‘highpass’, can be a float that specifies pass frequency, or can be a tuple and is assumed to be (None, f_hi) for ‘lowpass’, and (f_lo, None) for ‘highpass’.
- n_cyclesfloat, optional
Filter length, in number of cycles, defined at the ‘f_lo’ frequency. Either n_cycles or n_seconds can be defined to set the filter length, but not both. If not provided, and n_seconds is also not defined, defaults to 3.
- n_secondsfloat, optional
Filter length, in seconds. Either n_cycles or n_seconds can be defined to set the filter length, but not both.
- Returns:
- filter_coefs1d array
The filter coefficients for an FIR filter.
Examples
Create the filter coefficients for an FIR filter:
>>> filter_coefs = design_fir_filter(fs=500, pass_type='bandpass', f_range=(1, 25))