send_markers¶
send_markers adds markers to the current data file.
anywave('send_markers', markers);
markers is a struct array, one element per marker, with these fields:
| field | type | content | required |
|---|---|---|---|
label |
char | label of the marker | yes |
position |
double | position in seconds | yes |
duration |
double | duration in seconds (default 0) | no |
value |
double | value associated with the marker (default 0) | no |
channels |
cell array of char | labels of the channels the marker is attached to. Empty for a global marker | no |
color |
char | color as '#RRGGBB', for instance '#FF0000' is red (default: the default color of AnyWave) |
no |
One marker¶
Only label and position are needed:
marker = struct('label', 'my marker', 'position', 12.5);
anywave('send_markers', marker);
Several markers¶
Every marker needs a value for every field you use
A struct array has the same fields for all its elements. If you set markers(1).duration and forget it for
markers(2), the field of the second marker is empty ([]) and the command stops with the error
Can't index into an empty array. (duration, value) or Data type mismatch. (color).
Either give a value to the fields for all the markers, or build the array with struct().
Only channels may be left empty.
The simplest way is to build the whole array with struct(), one cell per marker for every field:
markers = struct( ...
'label', {'first marker', 'second marker', 'third marker'}, ...
'position', {1, 6, 7}, ...
'duration', {5, 0, 0.5}, ...
'value', {0, 0, 10}, ...
'color', {'#FF0000', '#00FF00', '#0000FF'}, ...
'channels', {{}, {'A1'}, {'A1', 'A2'}}); % double braces: one cell array per marker
anywave('send_markers', markers);
The first marker is global (no channel) with a duration of 5 s and is red. The second one is attached to channel A1. The third one is attached to A1 and A2, has a value of 10 and lasts 0.5 s.
Or fill the array in a loop, all fields for every marker:
positions = [2.5 8.0 14.2];
markers = struct('label', {}, 'position', {}, 'duration', {}, 'value', {}, 'color', {}, 'channels', {});
for k = 1:numel(positions)
markers(k).label = sprintf('event %d', k);
markers(k).position = positions(k);
markers(k).duration = 1;
markers(k).value = k;
markers(k).color = '#8800CC';
markers(k).channels = {};
end
anywave('send_markers', markers);
Check what was added¶
anywave('send_markers', struct('label', 'check me', 'position', 3));
markers = anywave('get_markers', struct('labels', {{'check me'}}));
Errors¶
| message | cause |
|---|---|
send_markers: argument must be a struct array. |
the argument is not a struct |
send_markers: struct must contain at least two fields (label, position) |
fewer than two fields |
send_markers: struct must contain label and position fields. |
label or position is missing |
send_markers: field label must be a string. |
label is not a char array |
send_markers: field position must be a double. |
position is not a double |
Can't index into an empty array. |
duration or value is empty in one of the markers |
Data type mismatch. |
color is empty or is not a char array in one of the markers |
Note
A marker placed after the end of the data file is not kept by AnyWave. Check that position is smaller than
the duration of the file (args.file_duration).