Skip to content

[Abstract] PipelineUnit

João Saraiva edited this page Jun 9, 2022 · 2 revisions

A Pipeline Unit 📦 is any class able to be part of a Pipeline of processes. These can be filters, denoisers, segmenters, machine learning trainers, decision modules, etc. You may find these Pipeline Units implemented in various modules:

How to instantiate a Pipeline Unit

PipelineUnit is an abstract class, meaning objects cannot be instantiated from it. You need to instantiate one of its subclasses (from above), corresponding to the behavior you need. Each of these has its own initializer, so, to instantiate one of them, just follow its signature.

Apply it

Just call its apply method and give what it requires.

pipeline_unit.apply(...)

The parameters are different depending on the Pipeline Unit, but, usually, they are collections of Timeseries.


DEVELOPER HUB

Create your own Pipeline Units

From scratch

Go on, create any agent you would like to process and analyse Biosignals . Create event detectors, segment excluders, quality analysers, whatever you need for your research. Create a class that inherits from PipelineUnit, implement n initializer and the apply method. The apply method works as the executor of the Command Design Pattern, where a Pipeline calls the apply of every PipelineUnit.

Deriving from an existing one

Extend the functionality of a concrete PipelineUnit, such as filters and machine learning trainers.

Example: MySupervisingTrainer
class MySupervisingTrainer(SupervisingTrainer):
    
    # Probably the SupervisingTrainer already comes with the properties you need, you just want different behavior.
    def __init(self, model, train_conditions, name):
        super().__init__(model, train_conditions, name)

    # Different behavior here. Override 'apply'!
    def apply(self, object, target):
        # TODO