Filtering
pynapple.process.filtering
Filtering module.
apply_bandpass_filter
Apply a band-pass filter to the provided signal. Mode can be :
"butter"
for Butterworth filter. In this case,order
determines the order of the filter."sinc"
for Windowed-Sinc convolution.transition_bandwidth
determines the transition bandwidth.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Tsd, TsdFrame, or TsdTensor
|
The signal to be filtered. |
required |
cutoff |
(Numeric, Numeric)
|
Cutoff frequencies in Hz. |
required |
fs |
float
|
The sampling frequency of the signal in Hz. If not provided, it will be inferred from the time axis of the data. |
None
|
mode |
(butter, sinc)
|
Filtering mode. Default is 'butter'. |
'butter'
|
order |
int
|
The order of the Butterworth filter. Higher values result in sharper frequency cutoffs. Default is 4. |
4
|
transition_bandwidth |
float
|
The transition bandwidth. 0.2 corresponds to 20% of the frequency band between 0 and the sampling frequency. The smaller the transition bandwidth, the larger the windowed-sinc kernel. Default is 0.02. |
0.02
|
Returns:
Name | Type | Description |
---|---|---|
filtered_data |
Tsd, TsdFrame, or TsdTensor
|
The filtered signal, with the same data type as the input. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
Notes
For the Butterworth filter, the cutoff frequency is defined as the frequency at which the amplitude of the signal is reduced by -3 dB (decibels).
Source code in pynapple/process/filtering.py
apply_bandstop_filter
Apply a band-stop filter to the provided signal. Mode can be :
"butter"
for Butterworth filter. In this case,order
determines the order of the filter."sinc"
for Windowed-Sinc convolution.transition_bandwidth
determines the transition bandwidth.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Tsd, TsdFrame, or TsdTensor
|
The signal to be filtered. |
required |
cutoff |
(Numeric, Numeric)
|
Cutoff frequencies in Hz. |
required |
fs |
float
|
The sampling frequency of the signal in Hz. If not provided, it will be inferred from the time axis of the data. |
None
|
mode |
(butter, sinc)
|
Filtering mode. Default is 'butter'. |
'butter'
|
order |
int
|
The order of the Butterworth filter. Higher values result in sharper frequency cutoffs. Default is 4. |
4
|
transition_bandwidth |
float
|
The transition bandwidth. 0.2 corresponds to 20% of the frequency band between 0 and the sampling frequency. The smaller the transition bandwidth, the larger the windowed-sinc kernel. Default is 0.02. |
0.02
|
Returns:
Name | Type | Description |
---|---|---|
filtered_data |
Tsd, TsdFrame, or TsdTensor
|
The filtered signal, with the same data type as the input. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
Notes
For the Butterworth filter, the cutoff frequency is defined as the frequency at which the amplitude of the signal is reduced by -3 dB (decibels).
Source code in pynapple/process/filtering.py
apply_highpass_filter
Apply a high-pass filter to the provided signal. Mode can be :
"butter"
for Butterworth filter. In this case,order
determines the order of the filter."sinc"
for Windowed-Sinc convolution.transition_bandwidth
determines the transition bandwidth.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Tsd, TsdFrame, or TsdTensor
|
The signal to be filtered. |
required |
cutoff |
Numeric
|
Cutoff frequency in Hz. |
required |
fs |
float
|
The sampling frequency of the signal in Hz. If not provided, it will be inferred from the time axis of the data. |
None
|
mode |
(butter, sinc)
|
Filtering mode. Default is 'butter'. |
'butter'
|
order |
int
|
The order of the Butterworth filter. Higher values result in sharper frequency cutoffs. Default is 4. |
4
|
transition_bandwidth |
float
|
The transition bandwidth. 0.2 corresponds to 20% of the frequency band between 0 and the sampling frequency. The smaller the transition bandwidth, the larger the windowed-sinc kernel. Default is 0.02. |
0.02
|
Returns:
Name | Type | Description |
---|---|---|
filtered_data |
Tsd, TsdFrame, or TsdTensor
|
The filtered signal, with the same data type as the input. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
Notes
For the Butterworth filter, the cutoff frequency is defined as the frequency at which the amplitude of the signal is reduced by -3 dB (decibels).
Source code in pynapple/process/filtering.py
apply_lowpass_filter
Apply a low-pass filter to the provided signal. Mode can be :
"butter"
for Butterworth filter. In this case,order
determines the order of the filter."sinc"
for Windowed-Sinc convolution.transition_bandwidth
determines the transition bandwidth.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Tsd, TsdFrame, or TsdTensor
|
The signal to be filtered. |
required |
cutoff |
Numeric
|
Cutoff frequency in Hz. |
required |
fs |
float
|
The sampling frequency of the signal in Hz. If not provided, it will be inferred from the time axis of the data. |
None
|
mode |
(butter, sinc)
|
Filtering mode. Default is 'butter'. |
'butter'
|
order |
int
|
The order of the Butterworth filter. Higher values result in sharper frequency cutoffs. Default is 4. |
4
|
transition_bandwidth |
float
|
The transition bandwidth. 0.2 corresponds to 20% of the frequency band between 0 and the sampling frequency. The smaller the transition bandwidth, the larger the windowed-sinc kernel. Default is 0.02. |
0.02
|
Returns:
Name | Type | Description |
---|---|---|
filtered_data |
Tsd, TsdFrame, or TsdTensor
|
The filtered signal, with the same data type as the input. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
Notes
For the Butterworth filter, the cutoff frequency is defined as the frequency at which the amplitude of the signal is reduced by -3 dB (decibels).
Source code in pynapple/process/filtering.py
get_filter_frequency_response
Utility function to evaluate the frequency response of a particular type of filter. The arguments are the same
as the function apply_lowpass_filter
, apply_highpass_filter
, apply_bandpass_filter
and
apply_bandstop_filter
.
This function returns a pandas Series object with the index as frequencies.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cutoff |
Numeric or tuple of Numeric
|
Cutoff frequency in Hz. |
required |
fs |
float
|
The sampling frequency of the signal in Hz. |
required |
filter_type |
Can be "lowpass", "highpass", "bandpass" or "bandstop" |
required | |
mode |
Can be "butter" or "sinc". |
required | |
order |
int
|
The order of the Butterworth filter. Higher values result in sharper frequency cutoffs. Default is 4. |
4
|
transition_bandwidth |
float
|
The transition bandwidth. 0.2 corresponds to 20% of the frequency band between 0 and the sampling frequency. The smaller the transition bandwidth, the larger the windowed-sinc kernel. Default is 0.02. |
0.02
|
Returns:
Type | Description |
---|---|
Series
|
|