bsl.triggers.TriggerDef#

class bsl.triggers.TriggerDef(trigger_file=None)#

Class used to store pairs {str: int} of events name and events value.

Each name and each value is unique. The pairs can be read from a .ini file or edited manually with TriggerDef.add() and TriggerDef.remove().

The class will expose the name as attributes self.event_str = event_int for all pairs.

Parameters

trigger_file (None | path-like) –

Path to the .ini file containing the table converting event numbers into event strings.

Note

The .ini file is read with configparser and has to be structured as follows:

[events]
event_str_1 = event_id_1   # comment
event_str_2 = event_id_2   # comment

Example:

[events]
rest = 1
stim = 2

Attributes
by_name

A dictionary with string keys and integers value.

by_value

A dictionary with integers keys and string values.

Methods

add(name, value[, overwrite])

Add an event to the trigger definition instance.

read(trigger_file)

Read events from a .ini trigger definition file.

remove(event)

Remove an event from the trigger definition instance.

write(trigger_file)

Write events to a .ini trigger definition file.

add(name, value, overwrite=False)#

Add an event to the trigger definition instance.

Parameters
  • name (str) – Name of the event

  • value (int) – Value of the event

  • overwrite (bool) – If True, overwrite previous event with the same name or value.

property by_name#

A dictionary with string keys and integers value.

Type

dict

property by_value#

A dictionary with integers keys and string values.

Type

dict

read(trigger_file)#

Read events from a .ini trigger definition file.

Note

The .ini file is read with configparser and has to be structured as follows:

[events]
event_str_1 = event_id_1   # comment
event_str_2 = event_id_2   # comment

Example:

[events]
rest = 1
stim = 2
Parameters

trigger_file (path-like) – Path to the .ini file containing the table converting event numbers into event strings.

remove(event)#

Remove an event from the trigger definition instance.

The event can be given by name (str) or by value (int).

Parameters

event (str | int) – If a str is provided, assumes event is the name. If a int is provided, assumes event is the value.

write(trigger_file)#

Write events to a .ini trigger definition file.

Note

The .ini file is written with configparser and is structured as follows:

[events]
event_str_1 = event_id_1
event_str_2 = event_id_2