%% Get Labeled Signal
% Load a labeled signal set containing recordings of whale songs.

load whales
lss

%
% Get a table with all the signals in lss.

t = getLabeledSignal(lss)

% Identify the sublabels of the trill regions.

d = getLabelNames(lss,'TrillRegions')

%
% Get the labeled signal corresponding to the second member of the set. Determine the sample rate.

idx = 2;

[lbs,info] = getLabeledSignal(lss,idx)
fs = info.SampleRate;

%
% Identify the moan and trill regions of interest. Use a signalMask object to plot the signal and highlight the moans and trills.

mvals = getLabelValues(lss,idx,'MoanRegions');
tvals = getLabelValues(lss,idx,'TrillRegions');

tb = [mvals;tvals];
tb.Value = categorical( ...
    [repmat("moan",height(mvals),1);repmat("trill",height(tvals),1)], ...
    ["moan" "trill"]);
sm = signalMask(tb,"SampleRate",fs);
plotsigroi(sm,getSignal(lss,idx))

%
% Identify three peaks of the trill region and plot them.

peaks = getLabelValues(lss,idx,{'TrillRegions','TrillPeaks'});

hold on
pk = plot(peaks.Location,cell2mat(peaks.Value),'v');
hold off
legend(pk,'trill peaks')

% Copyright 2018 The MathWorks, Inc.