BandPower

class gpype.backend.transform.band_power.BandPower[source]

Bases: IONode

Reduces a spectrum to power in named frequency bands.

This is the most common feature in online BCI work, and until now nothing could consume an FFT at all: the spectrum carried no frequency axis, so a scope was its only possible destination.

Bands may be named – the conventional EEG bands are built in – or given as explicit ranges. The output is one value per band per channel, labelled so that a downstream file or stream says which is which rather than leaving the reader to count columns.

Each value is the band’s power: the sum of the squared spectrum amplitudes over its bins, in the input’s unit squared. That unit has no notation yet, so the output records none. Before 4.1.0 the node summed the amplitudes themselves.

A row arrives once per FFT cycle – FFT’s FRAME_RATE, not the signal’s own sampling rate carried through unchanged – and this node declares its own rate accordingly, so Result.rate, times and duration behind it describe how often a row actually arrives rather than the rate the spectrum was taken at. Before that fix (found 2026-09-26), a Collector after FFT(250) -> BandPower at 250 Hz reported the input’s 250 Hz for values arriving twice a second – 125 times too fast.

DEFAULT_BANDS = ('delta', 'theta', 'alpha', 'beta', 'gamma')

The conventional EEG bands, by name – which is the form an author writes. Not the resolved [name, low, high] triples: those are the internal shape, and publishing them as the default told an authoring tool that a triple is what a person has to type.

class Configuration[source]

Bases: Configuration

Configuration class for BandPower parameters.

class Keys[source]

Bases: Keys

Configuration keys for BandPower settings.

BANDS = 'bands'

Bands to measure, as name or [low, high] pairs

__init__(bands=None, **kwargs)[source]

Initialize the band power node.

Parameters:
  • bands – Band names from BANDS, or explicit [low, high] pairs in Hz, or a mix. Defaults to the conventional EEG bands.

  • **kwargs – Additional arguments for the parent IONode.

Raises:

ValueError – If a band name is unknown, a range is malformed, or the list is empty.

setup(data, port_context_in)[source]

Rebuild the frequency axis and resolve each band to bins.

Parameters:
Return type:

dict[str, dict]

Returns:

Output port contexts.

Raises:

ValueError – If the input is not a spectrum, or a band falls entirely outside the represented frequencies.

step(data)[source]

Sum the squared spectrum over each band.

Parameters:

data (dict[str, ndarray]) – One spectrum, bins by channels.

Return type:

dict[str, ndarray]

Returns:

One row, channel-major with one value per band.