neurodsp.filt.checks.check_filter_definition¶

neurodsp.filt.checks.
check_filter_definition
(pass_type, f_range)[source]¶ Check a filter definition for validity, and get filter frequency range of the filter.
 Parameters
 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’.
 Returns
 f_lofloat or None
The lower frequency range of the filter, specifying the highpass frequency, if specified.
 f_hifloat or None
The higher frequency range of the filter, specifying the lowpass frequency, if specified.
 Raises
 ValueError
If the filter passtype it not understood, or cutoff frequencies are incompatible.
Examples
Check a filter definition, and get the cutoff frequencies returned, if the filter is valid:
>>> f_hi, f_lo = check_filter_definition(pass_type='bandpass', f_range=(5, 25))
Check a filter definition, for an invalid filter. This example fails since a bandpass filter requires two values for
f_range
.>>> try: ... f_hi, f_lo = check_filter_definition(pass_type='bandpass', f_range=(20)) ... except ValueError: ... print("The filter definition is invalid.") The filter definition is invalid.