pybispectra.general.Bispectrum#
- class pybispectra.general.Bispectrum(data: ndarray, freqs: ndarray, sampling_freq: int | float, verbose: bool = True)[source]#
Class for computing the bispectrum.
- Parameters:
- data
ndarray
, shape of [epochs, channels, frequencies] Fourier coefficients.
- freqs
ndarray
, shape of [frequencies] Frequencies (in Hz) in
data
. Frequencies are expected to be evenly spaced.- sampling_freq
int
|float
Sampling frequency (in Hz) of the data from which
data
was derived.- verbose
bool
(defaultTrue
) Whether or not to report the progress of the processing.
- data
- Attributes:
results
ResultsGeneral
Bispectrum results.
- data
ndarray
offloat
, shape of [epochs, channels, frequencies] Fourier coefficients.
- freqs
ndarray
offloat
, shape of [frequencies] Frequencies (in Hz) in
data
.- sampling_freq
int
|float
Sampling frequency (in Hz) of the data from which
data
was derived.- verbose
bool
Whether or not to report the progress of the processing.
Methods
compute
([indices, f1s, f2s, n_jobs])Compute the bispectrum, averaged over epochs.
copy
()Return a copy of the object.
Notes
Added in version 1.2.
- compute(indices: tuple[tuple[int]] | None = None, f1s: tuple[int | float] | None = None, f2s: tuple[int | float] | None = None, n_jobs: int = 1) None [source]#
Compute the bispectrum, averaged over epochs.
- Parameters:
- indices
tuple
oftuple
ofint
, length of 3 |None
(defaultNone
) Indices of the channels \(k\), \(m\), and \(n\), respectively, to compute the bispectrum for. If
None
, the bispectrum for all channel combinations is computed.- f1s
tuple
ofint
orfloat
, length of 2 |None
(defaultNone
) Start and end lower frequencies to compute the bispectrum for, respectively. If
None
, all frequencies are used.- f2s
tuple
ofint
orfloat
, length of 2 |None
(defaultNone
) Start and end higher frequencies to compute the bispectrum for, respectively. If
None
, all frequencies are used.- n_jobs
int
(default1
) The number of jobs to run in parallel. If
-1
, all available CPUs are used.
- indices
Notes
The bispectrum, \(\textbf{B}\), has the general form
\(\textbf{B}_{kmn}(f_1,f_2)=<\textbf{k}(f_1)\textbf{m}(f_2) \textbf{n}^*(f_2+f_1)>\) ,
where \(kmn\) is a combination of signals with Fourier coefficients \(\textbf{k}\), \(\textbf{m}\), and \(\textbf{n}\), respectively; \(f_1\) and \(f_2\) correspond to a lower and higher frequency, respectively; and \(<>\) represents the average value over epochs.
The bispectrum is computed between all values of
f1s
andf2s
. If any value off1s
is higher thanf2s
, anumpy.nan
value is returned.
- property results: ResultsGeneral#
Bispectrum results.