ChannelSelector
- class gpype.backend.flow.channel_selector.ChannelSelector[source]
Bases:
IONodeSelects channels by name, by role, or by position.
Router addresses channels by position, which is what you want when wiring a pipeline and not what you want when a montage changes. This addresses them by what they are:
ChannelSelector(labels=[“C3”, “Cz”, “C4”]) ChannelSelector(roles=Constants.ChannelRoles.SIGNAL) ChannelSelector(indices=[0, 2, 4], exclude=True)
Selecting by role is the device-agnostic form: every amplifier appends different extras, and asking for the signal channels is the same request on all of them.
Every failure is raised at setup, i.e. when the pipeline starts and before a file or a socket exists. Skipping a channel that could not be found would change the channel count silently, everything downstream would accept it, and the operator would find out on analysis day that an electrode is missing from the whole recording.
- ONE_OF = (('labels', 'roles', 'indices'),)
Exactly one of these must be given – the constructor refuses any other count. Declared because no per-parameter field can say it: read one at a time they all look merely optional, so a form built from the catalog would offer three optional fields and produce a document that always fails.
- class Configuration[source]
Bases:
ConfigurationConfiguration class for ChannelSelector parameters.
- __init__(labels=None, roles=None, indices=None, exclude=False, **kwargs)[source]
Initialize the channel selector.
- Parameters:
labels (
Optional[list]) – Channel names to select. Also reorders: the output follows the order given.roles (
Union[str,list,None]) – One role, or several, from Constants.ChannelRoles.indices (
Optional[list]) – Channel positions to select. Also reorders.exclude (
bool) – Invert the selection. Survivors keep input order.**kwargs – Additional arguments for the parent IONode.
- Raises:
ValueError – If not exactly one criterion is given, if it is empty, or if it repeats an entry.