send_markers¶
send_markers adds markers to the current data file. The argument is a list of anywave.Marker objects.
aw.send_markers(markers)
The Marker class¶
marker = aw.Marker(label='my marker', position=12.5)
marker = aw.Marker(label='my marker', position=12.5, duration=2, value=10, colour='#FF0000')
marker.targets = ['A1', 'A2'] # attach the marker to channels
| attribute | type | content | default |
|---|---|---|---|
label |
str | label of the marker | '' |
position |
float | position in seconds | 0. |
value |
float | value associated with the marker | 0. |
duration |
float | duration in seconds | 0. |
colour |
str | color as '#RRGGBB', for instance '#FF0000' is red |
'#000000' |
targets |
list of str | labels of the channels the marker is attached to. Empty for a global marker | [] |
- The constructor takes
label,position,value,durationandcolour, in this order when you use the positions instead of the names. It has notargetsargument: setmarker.targets(or callmarker.set_targets([...])). - A marker needs a
labeland aposition: the rest is optional. - The default color is
'#000000': black, not the default color of AnyWave. Givecolour=''to let AnyWave choose the default color of its markers.
Examples¶
Two markers: a global marker of 5 s, red, and a marker attached to the channel A1.
markers = [
aw.Marker(label='first marker', position=1, duration=5, colour='#FF0000'),
aw.Marker(label='second marker', position=6),
]
markers[1].targets = ['A1']
aw.send_markers(markers)
A loop, with one marker per event:
events = [2.5, 8.0, 14.2]
markers = [aw.Marker(label='event %d' % (k + 1), position=p, duration=1, value=k + 1, colour='#8800CC')
for k, p in enumerate(events)]
aw.send_markers(markers)
Check what was added¶
aw.send_markers([aw.Marker(label='check me', position=3)])
markers = aw.get_markers({'labels': ['check me']})
The markers are added to the list of AnyWave, and saved with the .mrk file of the recording
(see Marker files).
Good to know¶
- The argument must be a list, even for one marker:
aw.send_markers(marker)raisesException: arguments of send_markers must be a list of Markers. - A marker placed after the end of the data file is not kept by AnyWave. Check that
positionis smaller than the duration of the file (props['file_duration'], see get_props). - An empty list is accepted and does nothing.