get_markers¶
get_markers returns the markers of the current data file as a struct array.
markers = anywave('get_markers'); % every marker
markers = anywave('get_markers', cfg); % only the markers that match cfg
The result¶
markers is a 1 x N struct array, one element per marker:
| field | type | content |
|---|---|---|
label |
char | label of the marker |
position |
double | position in seconds |
duration |
double | duration in seconds (0 for a marker without duration) |
value |
double | value associated with the marker (0 by default) |
channels |
cell array of char | labels of the channels the marker is attached to. Empty for a global marker |
markers = anywave('get_markers');
for k = 1:numel(markers)
m = markers(k);
fprintf('%s at %.3f s (%.3f s long)\n', m.label, m.position, m.duration);
end
Note
- When no marker matches,
markersis an empty array: test it withisempty(markers). - Positions, durations and values are stored in single precision by AnyWave:
0.1comes back as0.100000001490116. Compare positions with a tolerance, for instanceabs(m.position - 0.1) < 1e-6. - The field that lists the channels is
channels(like in send_markers).
Choose the markers¶
All the options are fields of cfg. When several are given, a marker must match all of them.
| option | value | keeps the markers... |
|---|---|---|
labels |
cell array of char | whose label is in the list |
values |
cell array or vector of numbers | whose value is in the list |
channels |
cell array of char | attached to at least one of these channels |
options |
{'with duration'} |
that have a duration |
By label¶
cfg = [];
cfg.labels = {'seizure', 'EI'};
markers = anywave('get_markers', cfg);
if ~isempty(markers)
% process markers
end
By value¶
cfg = [];
cfg.values = [10 5 512]; % markers with the value 10, 5 or 512
markers = anywave('get_markers', cfg);
Warning
With one value, write cfg.values = {10};. MATLAB sends cfg.values = 10 as a plain number, which AnyWave does not
read as a list: the filter is ignored and you get all the markers.
By channel¶
cfg = [];
cfg.channels = {'A1', 'A3'}; % markers attached to A1 and/or A3
markers = anywave('get_markers', cfg);
Only the markers with a duration¶
cfg = [];
cfg.options = {'with duration'};
markers = anywave('get_markers', cfg);
Combine the options¶
cfg = [];
cfg.labels = {'seizure'};
cfg.options = {'with duration'}; % seizure markers that have a duration
markers = anywave('get_markers', cfg);
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)
cfg = [];
cfg.use_markers = {'seizure'};
cfg.split_data = true;
chunks = anywave('get_data', cfg); % one element per marker
% 2. use the positions
markers = anywave('get_markers', struct('labels', {{'seizure'}}));
for k = 1:numel(markers)
cfg = [];
cfg.start = max(0, markers(k).position - 2); % 2 s before the marker
cfg.duration = markers(k).duration + 4; % until 2 s after its end
out = anywave('get_data', cfg);
end