"Output argument 'labelVals' (and possibly others) not assigned a value" in SignalLabeler

2 次查看(过去 30 天)
Hello all and thank you in advance!
I am trying to create a custom labeling function for signal labeler and have tested it as a normal Matlab command and it works there.
However, as soon as I try to run it in SignalLabeler I get the above mentioned error message.
I have attached the code below and would be very grateful for any suggestions!
function [labelVals,labelLocs] = FindN2bP3Complex(x,freq,varargin)
%parentLabelVal,parentLabelLoc,varargin)
% Only applicable if epoch size is 1sec
num = 1;
for i = 1:(size(x,1)/freq)
localmax = islocalmax(x(num:num+(freq-1)));
localmin = islocalmin(x(num:num+(freq-1)));
xMax = find(localmax==1);
yMax = x(localmax);
xMin = find(localmin==1);
yMin = x(localmin);
if size(xMax,1) <= size(xMin,1)
countextreme = size(xMax,1);
else
countextreme = size(xMin,1);
end
count = 1;
for h = 1:countextreme
linvec = [(xMin(count)-xMax(count)) (yMin(count)-yMax(count))];
xrow = xMin(count);
xcol = xMax(count);
if x(xrow:xcol) == linvec(count:end)
else
labelLocs(count,1)=xMin(count);
labelLocs(count,2)=xMax(count);
labelVals(count,1)="N2bP3Complex";
end
count = count+1;
end
num = num+(freq-1);
end

回答(1 个)

Githin George
Githin George 2023-10-25
Hello,
I understand you are getting the error "Output argument 'labelVals' (and possibly others) not assigned a value" in Signal Labeler App when trying to import your custom labelling function.
Looking at the code provided and the error message, it is most likely due to labelVals’ and ‘labelLocs’ not being assigned a value outside of the else condition and hence MATLAB is throwing the error.
In addition, the function signature is also not matching with the recommended signature for a custom labeling function which would be as follows.
function [labelVals,labelLocs] = FindN2bP3Complex(x,t,parentLabelVal,parentLabelLoc,varargin)
% This is a template for creating a custom function for automated labeling
%
% x is a matrix where each column contains data corresponding to a
% channel. If the channels have different lengths, then x is a cell array
% of column vectors.
%
% t is a matrix where each column contains time corresponding to a
% channel. If the channels have different lengths, then t is a cell array
% of column vectors.
%
% parentLabelVal is the parent label value associated with the output
% sublabel or empty when output is not a sublabel.
% parentLabelLoc contains an empty vector when the parent label is an
% attribute, a vector of ROI limits when parent label is an ROI or a point
% location when parent label is a point.
%
% labelVals must be a column vector with numeric, logical or string output
% values.
% labelLocs must be an empty vector when output labels are attributes, a
% two column matrix of ROI limits when output labels are ROIs, or a column
% vector of point locations when output labels are points.
end
The following link provides an end-to-end example of using custom labeling functions for Signal Labeler App.
I hope this helps resolve the issue.
  6 个评论
Michel
Michel 2023-10-25
@Githin George Of course! This is eeg data from a single channel that has already been pre-processed. Thank you again for your help.
Michel
Michel 2023-10-27
@Walter Roberson apologies for the late reply. I don't know if I understand correctly, but when I check my variables, the islocalmax() function did indeed detect several local maxima. The same goes for the localmin() funtion. Thank you for your help.

请先登录,再进行评论。

产品


版本

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by