bsl.triggers.TriggerDef¶
- class bsl.triggers.TriggerDef(trigger_file=None)[source]¶
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 withTriggerDef.add()
andTriggerDef.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 withconfigparser
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
- trigger_file
Attributes
A dictionary with string keys and integers 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.- read(trigger_file)[source]¶
Read events from a
.ini
trigger definition file.Note
The
.ini
file is read withconfigparser
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_filepath-like
Path to the
.ini
file containing the table converting event numbers into event strings.
- remove(event)[source]¶
Remove an event from the trigger definition instance.
The event can be given by name (str) or by value (int).
- write(trigger_file)[source]¶
Write events to a
.ini
trigger definition file.- 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 withconfigparser
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
- trigger_file