Skip to content

get_markers

get_markers returns the markers of the current data file as a list of Marker objects.

markers = aw.get_markers()           # every marker
markers = aw.get_markers(cfg)        # only the markers that match cfg (a dict)

The result

markers is a list, one anywave.Marker per marker:

attribute type content
label str label of the marker
position float position in seconds
duration float duration in seconds (0 for a marker without duration)
value float value associated with the marker (-1 when it has none)
targets list of str labels of the channels the marker is attached to. Empty for a global marker
markers = aw.get_markers()
for m in markers:
    print('%s at %.3f s (%.3f s long)' % (m.label, m.position, m.duration))

Note

  • When no marker matches, markers is an empty list: test it with if not markers:.
  • AnyWave stores positions, durations and values in single precision: 0.1 comes back as 0.10000000149011612. Compare positions with a tolerance, for instance abs(m.position - 0.1) < 1e-6.
  • The colour attribute that every Marker has is not filled by get_markers: it always says '#000000'.

Choose the markers

All the options are keys of cfg. When several are given, a marker must match all of them.

option value keeps the markers...
labels list of str whose label is in the list
values list of numbers whose value is in the list
channels list of str attached to at least one of these channels
options ['with duration'] that have a duration
markers = aw.get_markers({'labels': ['seizure', 'EI']})         # by label
markers = aw.get_markers({'values': [10, 5, 512]})              # by value
markers = aw.get_markers({'channels': ['A1', 'A3']})            # attached to A1 and/or A3
markers = aw.get_markers({'options': ['with duration']})        # only the markers with a duration
markers = aw.get_markers({'labels': ['seizure'], 'options': ['with duration']})    # seizure markers with a duration

Warning

values must be a list, even with a single value: {'values': [10]}. {'values': 10} is not read as a list, the filter is ignored and you get all the markers.

Use the markers to get data

Two ways to get the data of the markers: ask get_data to do it, or use the positions yourself.

# 1. get_data does the job (see the get_data page): the markers need a duration
chunks = aw.get_data({'use_markers': ['seizure'], 'split_data': True})      # one dict per marker

# 2. use the positions
for m in aw.get_markers({'labels': ['seizure']}):
    start = max(0.0, m.position - 2)                 # 2 s before the marker
    out = aw.get_data({'start': start, 'duration': m.duration + 4})     # until 2 s after its end