pybic.BicAn

class pybic.BicAn(inData, **kwargs)[source]

Main class of pybic module, i.e., Bicoherence Analyzer.

pybic.BicAn(inData,**kwargs)

A typical usage is

# Import pybic module
import pybic as bic
# Create time series to analyze
x,t,fS = bic.TestSignal('circle')
# Analyze!
b = bic.BicAn(x,SampRate=fS)

Note

When using the __init__ method (i.e., pybic.BicAn(...)), keywords are case insensitive! For example, BicAn(inData,samprate=fS), BicAn(inData,SAMPRATE=fS), and BicAn(inData,sAmPrAtE=fS) are all valid means of setting the SampRate attribute upon initialization.

However, the direct augmentation of attributes is case sensitive, i.e., b.samprate = 100.0 will throw an error!

Parameters:
  • inData (ndarray or str) – Time series to be analyzed or TestSignal() string. Using 'input' opens FileDialog() window to choose a local file for input.

  • **kwargs – Keyword-argument pairs to set attributes (see BicAn attributes for more info).

Returns:

Output object.

Return type:

BicAn

Attributes

AlphaExp

CWT alpha exponent (see ApplyCWT()).

AxHands

List of axes handles.

BicOfTime

Calculate bispectrum/bicoherence spectrum for selected PlotSlice.

BicVec

Integers representing desired time series for cross-bispectrum.

Bispectro

Calculate bispectrogram.

CMap

Colormap for plots.

COILim

Cone of influence logarithmic cutoff (see BicAn.SpectroWavelet()).

CalcCOI

Calculate cone of influence (COI) for CWT (see BicAn.SpectroWavelet()).

CalcHist

Calculate histogram of amplitude from time series (see CalcHistVsT()).

CaxHands

List of colorbar axes handles.

CbarNorth

Place colorbar above plot.

Cross

Calculate cross-spectrum/cross-coherence.

Date

Date when pybic is loaded.

Detrend

Detrend input time series before analysis.

DistLevel

Y-axis limit for bicoherence uncertainty analysis.

Epsilon

Small value in polycoherence calculations.

ErrLim

Threshold for mean of time-frequency representation (TFR) over all frequency bins.

FScale

Log scale for frequency labels (see ScaleToString()).

Figure

Used for BicAn.PlotGUI() functionality.

Filter

Desired filter.

FontSize

Plot font size in points.

FreqRes

Frequency resolution in Hz.

InCOI

Input cone of influence (see BicAn.SpectroWavelet()).

InstFreq

Estimated instantaneous frequency of time-series.

InstFreqFlag

Toggle behavior of user clicks in BicAn.PlotGUI().

JustSpec

Limit calculation to time-frequency representation (TFR), ie, no polyspectral analysis.

LilGuy

Duplicate of BicAn.Epsilon for back-compatability.

LimFreq

Maximum frequency of CWT given by pybic.SampRate/LimFreq.

LineColor

Line color in plots.

LineWidth

Plot linewidths in points.

NFreq

Number of frequency bins.

NewGUICax

Flag for creating new colorbar axes.

NormBic

Normalize bicoherence spectrum when using BicAn.PlotBispec().

Note

User note.

PlotDPI

Dots per inch of plots.

PlotIt

Run BicAn.PlotGUI() after analysis is complete.

PlotSig

Selected time series to plot when using BicAn.PlotSpectro().

PlotSlice

Selected slice of TFR to plot when using BicAn.PlotPowerSpec() and BicAn.PlotMeanHist().

PlotType

Desired bispectral quantity to plot (see BicAn.PlotBispec() and BicAn.PlotPointOut()).

Processed

Processed input data.

RandLevel

Level of randomization in bicoherence uncertainty analysis.

Raw

Raw input data.

SampRate

Sampling rate in Hz.

Samples

Number of samples in processed data.

ScaleAxes

Desired axis scaling.

Sigma

CWT time-frequency resolution parameter (see ApplyCWT()).

SizeWarn

Display warning for large TFRs.

Smooth

Smoothing factor in samples.

SpecType

Desired time-frequency representation (TFR).

SpecVLim

Spectrogram colorbar limits as [vmin,vmax].

Step

STFT step in samples.

SubInt

STFT subinterval size in samples.

TLineCol

Colormap for automatic calls to PlotTimeline().

TScale

Log scale for time labels (see ScaleToString()).

TZero

Initial time.

TickLabel

Tick label customization.

Trispec

Calculate trispectrum.

Vector

Plot linewidths.

Window

STFT window function (see HannWindow() and FlatTopWindow()).

ZPad

Pad time series with zeros to avoid truncation for STFT.

bc

Bicoherence spectrum.

bg

Bispectrogram.

bs

Bispectrum.

bv

Bin vector of input signal histogram.

cc

Cross-coherence.

cg

Coherence spectrum (or 'coherogram').

cs

Cross-spectrum.

er

Mean & std dev of FFT.

ff

Full frequency vector

ft

Fourier amplitudes

fv

Frequency vector associated with time-frequency representation

hg

Histogram of input signal amplitudes.

ht

Time vector of input signal histogram.

mb

Mean bicoherence.

mh

Input signal histogram averaged over time.

sb

Std dev of bicoherence spectrum.

sg

Spectrogram (complex)

tc

Tricoherence spectrum.

tkRoot

Root window for tkinter.

tkVar

Variable for tkinter.

ts

Trispectrum (complex).

tv

Time vector associated with time-frequency representation

Methods

ApplyZPad()

Apply zero padding to Raw data.

Bicoherence()

Class wrapper for bispectral analysis.

CalcMean([Ntrials])

Calculate mean of bicoherence spectrum across the full bi-frequency space.

CheckCouple(f[, checkdiff])

Check nth order coupling for a given test vector of freqs.

ClickPlot(event)

Callback for BicAn.PlotGUI() clicks.

Coherence()

Class wrapper for SpecToCoherence().

FindMaxInRange(FxLo, FxHi, FyLo, FyHi[, useb2])

Finds maximum bicoherence in given range.

HistogramSig([Nbins])

Class wrapper for CalcHistVsT().

InstAmpFreq(j[, calc_type, fband, realBPF, ...])

Perform instantaneous amplitude and frequency analysis.

InstDiffFreq(j, k[, fband, fwindow, dist, ...])

Plot the instantaneous difference frequency vs normalized bispectral modulus.

MonteCarloMax([N, Nrolls, critCoh, plot, ...])

Identifies maxima in N-coherence spectra with random restart hillclimb.

ParseInput(inData, kwargs)

Parse inputs for BicAn constructor.

PlotBispec(*args[, normb2, plot3d, squeezeAxes])

Plots bispectrum or bicoherence spectrum.

PlotCoherence(*args[, crossSpec, vLim])

Plots cross-coherence spectrum cc or cross-spectrum cs.

PlotGUI([SaveAs, subplotType])

Main graphical interface for exploring BicAn data.

PlotHelper(whatPlot, X, Y[, IsFreq, ...])

Estimate and plot distribution of bispectrum/bicoherence for single point.

PlotHisto(*args[, vLim])

Plots data histogram vs time.

PlotInstFreq(j, k[, diff_freq, freq_type, ...])

Perform instantaneous frequency analysis.

PlotMeanHist(*args[, vLim])

Plots time average (or slice) of data histogram.

PlotPhaseDist(j, k[, ylim, SaveAs])

Plots phase distribution of single point in bifrequency space.

PlotPointOut(X, Y[, IsFreq, PlotAll, ...])

Wraps BicAn.PlotHelper() for BicAn.PlotGUI().

PlotPowerSpec(*args[, vLim])

Plots time average (or slice) of spectrogram.

PlotSpectro(*args[, vLim, maxLine])

Plots absolute value of spectrogram.

PlotTrispec([Tval, colorTricoh, elev, azim, ...])

Plots trispectrum or tricoherence spectrum.

ProcessData()

Main processing loop (see source code).

RefreshGUI([SaveAs])

Refreshes GUI as initiated by BicAn.PlotGUI().

SizeWarnPrompt(n)

Modal warning about large FFT size.

SpectroSTFT()

Class wrapper for ApplySTFT().

SpectroWavelet()

Class method for CWT analysis.

SwitchCMap()

Interactive colormap selection.

SwitchCMapClick()

Callback function for BicAn.SwitchCMap().

SwitchPlot(event)

Callback for BicAn.PlotGUI() keypresses.

Tricoherence()

Class wrapper for trispectral analysis (SpecToTrispec()).

WhichPlot([local])

Assists plotting functions with data and labeling.