neurodsp.filt.utils.compute_transition_band

neurodsp.filt.utils.compute_transition_band(f_db, db, low=- 20, high=- 3)[source]

Compute transition bandwidth of a filter.

Parameters
f_db1d array

Frequency vector corresponding to attenuation decibels, in Hz.

db1d array

Degree of attenuation for each frequency specified in f_db, in dB.

lowfloat, optional, default: -20

The lower limit that defines the transition band, in dB.

highfloat, optional, default: -3

The upper limit that defines the transition band, in dB.

Returns
transition_bandfloat

The transition bandwidth of the filter.

Examples

Compute the transition band of an FIR filter, using the computed frequency response:

>>> from neurodsp.filt.fir import design_fir_filter
>>> filter_coefs = design_fir_filter(fs=500, pass_type='bandpass', f_range=(1, 25))
>>> f_db, db = compute_frequency_response(filter_coefs, 1, fs=500)
>>> compute_transition_band(f_db, db, low=-20, high=-3)
0.5

Compute the transition band of an IIR filter, using the computed frequency response:

>>> from neurodsp.filt.iir import design_iir_filter
>>> sos = design_iir_filter(fs=500, pass_type='bandstop',
...                         f_range=(10, 20), butterworth_order=7)
>>> f_db, db = compute_frequency_response(sos, None, fs=500)
>>> compute_transition_band(f_db, db, low=-20, high=-3)
2.0