neurodsp.filt.checks.check_filter_properties

neurodsp.filt.checks.check_filter_properties(filter_coefs, a_vals, fs, pass_type, f_range, transitions=(- 20, - 3), verbose=True)[source]

Check a filters properties, including pass band and transition band.

Parameters
filter_coefs1d or 2d array

If 1d, interpreted as the B-value filter coefficients. If 2d, interpreted as the second-order (sos) filter coefficients.

a_vals1d array or None

The A-value filter coefficients for a filter. If second-order filter coefficients are provided in filter_coefs, must be None.

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’.

transitionstuple of (float, float), optional, default: (-20, -3)

Cutoffs, in dB, that define the transition band.

verbosebool, optional, default: True

Whether to print out transition and pass bands.

Returns
passesbool

Whether all the checks pass. False if one or more checks fail.

Examples

Check the properties of an FIR filter:

>>> from neurodsp.filt.fir import design_fir_filter
>>> fs, pass_type, f_range = 500, 'bandpass', (1, 25)
>>> filter_coefs = design_fir_filter(fs, pass_type, f_range)
>>> passes = check_filter_properties(filter_coefs, 1, fs, pass_type, f_range)
Transition bandwidth is 0.5 Hz.
Pass/stop bandwidth is 24.0 Hz.