pybic
Polyspectral analysis toolkit for Python.
______ ______ _
| ___ \ | ___ (_)
| |_/ / _| |_/ /_ ___
| __/ | | | ___ \ |/ __| v2.1 (c) 2022-2026
| | | |_| | |_/ / | (__
\_| \__, \____/|_|\___| G. Riggs & T. Matheny
__/ |
|___/
PyBic is an open-source module specializing in signal processing, with particular emphasis on polyspectral analysis.
The Bic in PyBic refers to bicoherence analysis, which is by
far the most common use of the polyspectrum. Explicitly, we use
The bispectrum
B_xyz(f1,f2) = < X(f1)Y(f2)Z(f1+f2)* >,
where x,y,z are time series with corresponding Fourier transforms
X,Y,Z, and <...> denotes averaging in time.
The (squared) bicoherence spectrum
b^2_xyz(f1,f2) = |B_xyz(f1,f2)|^2
--------------------
( <|X(f1)Y(f2)|^2> <|Z(f1+f2)|^2> + eps ),
where eps is a small number meant to prevent 0/0 = NaN catastrophe
For more information and references on the history, theory, utility, and implementation of polyspectra, please see our publication in Computer Physics Communications, RiggsKoepkeMatheny2026.
Also check out our GitHub repo and Read the Docs pages!
To run the demo from the shell, use
$ python3 pybic.py
or, alternatively, in Python
import pybic as bic
b = bic.RunDemo()
Additionally, we’ve developed Jupyter notebooks with a guided tour
of PyBic and a demonstration of the Plot() function.
Todo
Add minimum threshold keyword to PlotBispec() method to mask b^2 below noise floor (none)
Add colormap picker in PlotGUI() with SHIFT + c, say (none)
Swap out matplotlib widgets for full tkinter GUI =^x (some)
Figure out setter functions (some)
Configure warnings (none)
Implement some kind of check for Raw data! Should eliminate string, etc. (done)
Fix colorbar axes overplotting each refresh (done)
Fix issue with colorbar labels when calling RefreshGUI() (done)
Add buttons and callbacks from Matlab (some)
Swap out “dum” variables for more literate ones
Comment the code!!! (some)
Fix butt-ugly inputs to PlotPointOut children! (done)
Flag for base units (maybe not based in time, say)
Antialiased option! (none)
Bispectrogram (none)
Auto-filters! (none)
Video output (none)
Base units (none)
Cross stuff in
BicAn.FindMaxInRange()(none)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Functions
|
Quick and dirty brickwall bandpass filter. |
|
Calculate continuous wavelet transform (CWT) of time-series. |
|
Remove linear trend from data. |
|
Butterworth bandpass filter. |
|
Calculate short-time Fourier transform (STFT) of time-series. |
|
Calculate amplitude histogram vs. time of time-series. |
|
Draws simplex for trispectrum. |
Simple file picker dialog. |
|
Flat-top window. |
|
|
Estimate local bispectrum and bicoherence of a single (f1,f2) value. |
|
Estimate mean and std dev of bicoherence for single (f1,f2) value. |
|
Estimate the nth-order polyspectrum/polycoherence spectrum of a given (f1,f2,...,fn) value |
|
Hann window (and all powers of sine). |
|
Calculates instantaneous frequency from zero crossings. |
|
Loading bar animation. |
|
All purpose plotting tool! |
|
General purpose plot labels. |
|
Add plot and right-hand side (RHS) label to existing plot. |
|
Plot line with color. |
|
Add plot and top label to existing plot. |
|
Demonstration of |
|
Converts order of magnitude to `metric prefix`_. |
|
3-oscillator FM signal generator. |
|
Estimate auto-bispectrum/-bicoherence spectrum from spectrogram(s). |
|
Estimate cross-spectrum/-coherence from spectrogram. |
|
Estimate cross-bispectrum/-bicoherence spectrum from spectrogram(s). |
|
Estimate auto-trispectrum/-tricoherence spectrum from spectrogram(s). |
|
Provides various signals for bispectral analysis. |
|
Whittaker-Shannon interpolation. |
|
Matlab-esque |
|
Creates array of all combinations of |
|
Smooths data, attempts to return correct amplitudes. |
|
Returns gradient of unwrapped phase. |
Outputs n numbers whose sum is < 1. |
Classes
|
Main class of |