Epoching nodes
epoch
- class timeflux.nodes.epoch.Samples(trigger, length=0.6, rate=None, buffer=5)[source]
Bases:
timeflux.core.node.Node
Fixed-size epoching.
This node produces equal-length epochs from the default input stream. These epochs are triggered from the events stream. Each epoch contains contextual metadata, making this node ideal in front of the ml node to train a model. Non-monotonic data, late data, late events, jittered data and jumbled events are all handled reasonably well. Multiple epochs are automatically assigned to dynamic outputs ports. For convenience, the first epoch is bound to the default output, so you can avoid enumerating all output ports if you expects only one epoch.
- Variables
- Parameters
Instantiate the node.
- class timeflux.nodes.epoch.Epoch(event_trigger, before=0.2, after=0.6)[source]
Bases:
timeflux.core.node.Node
Event-triggered epoching.
This node continuously buffers a small amount of data (of a duration of
before
seconds) from the default input stream. When it detects a marker matching theevent_trigger
in thelabel
column of the event input stream, it starts accumulating data forafter
seconds. It then sends the epoched data to an output stream, and sets the metadata to a dictionary containing the triggering marker and optional event data. Multiple, overlapping epochs are authorized. Each concurrent epoch is assigned its own Port. For convenience, the first epoch is bound to the default output, so you can avoid enumerating all output ports if you expects only one epoch.- Variables
- Parameters
Example
graphs: # Nothing is displayed because the epoch does not have any event input - id: example nodes: - id: random module: timeflux.nodes.random class: Random - id: epoch module: timeflux.nodes.epoch class: Epoch params: event_trigger: test - id: display module: timeflux.nodes.debug class: Display edges: - source: random target: epoch - source: epoch target: display rate: 10
Instantiate the node.
- class timeflux.nodes.epoch.Trim(samples=0)[source]
Bases:
timeflux.core.node.Node
Trim data so epochs are of equal length.
Because real-time data is often jittered, the Epoch node is not always able to provide dataframes of equal dimensions. This can be problematic if the data is further processed by the Pipeline node, for example. This simple node takes care of trimming the extra samples. It should be placed just after an Epoch node.
- Variables
- Parameters
samples (int) – The maximum number of samples per epoch. If 0, the size of the first epoch is used.
Instantiate the node.
- class timeflux.nodes.epoch.ToXArray(reporting='warn', output='DataArray', context_key=None)[source]
Bases:
timeflux.core.node.Node
Convert multiple epochs to DataArray
This node iterates over input ports with valid epochs, concatenates them on the first axis, and creates a XArray with dimensions (‘epoch’, ‘time’, ‘space’) where epoch corresponds to th input ports, time to the ports data index and space to the ports data columns. A port is considered to be valid if it has meta with key ‘epoch’ and data with expected number of samples. If some epoch have an invalid length (which happens when the data has jitter), the node either raises a warning, an error or pass.
- Variables
- Parameters
reporting (string| None) – How this function handles epochs with invalid length: warn will issue a warning with
warnings.warn()
, error will raise an exception, None will ignore it.output (DataArray`|`Dataset) – Type of output to return
context_key (string|None) – If output type is Dataset, key to define the target of the event. If None, the whole context is considered.
Instantiate the node.