MATLAB Answers

Waveform Segmentation Using Deep Learning: Error on getmask

46 views (last 30 days)
We are implementing it as described in [Waveform Segmentation Using Deep Learning].
I get an error in the following process and cannot proceed.
type getmask.m
trainDs = transform(trainDs, @getmask);
testDs = transform(testDs, @getmask);
The error statement is as follows
Error: nargin
The function getmask does not exist.
tFuncArgs = nargin(fun); 65)
tds =,
fcn, ...
Error: (line 359)
dsnew ={:});
Error: segmentation_default (line 30)
trainDs = transform(trainDs, @getmask);


Star Strider
Star Strider on 1 Dec 2020
What MATLAB release/version are you running?
The current online documentation is for R2020b, so if you are running an earlier version, it may not apply, and you may not be able to use all the examples in the online documentation. (I am not certain when the Waveform Segmentation Using Deep Learning Example first appeared, so I cannot determine the first release/version that will work with it.)
優哉 山口
優哉 山口 on 1 Dec 2020
Dear Star Strider
Thank you for your comment.
The version of Matlab is R2020b.
Also, the required Toolbox version is as follows
Deep Learning Toolbox Ver14.1
Signal Processing Toolbox Ver8.5

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 1 Dec 2020
You need to create it from the code they gave you on the page:
function outputCell = getmask(inputCell)
%GETMASK Convert region labels to a mask of labels of size equal to the
%size of the input ECG signal.
% inputCell is a two-element cell array containing an ECG signal vector
% and a table of region labels.
% outputCell is a two-element cell array containing the ECG signal vector
% and a categorical label vector mask of the same length as the signal.
% Copyright 2020 The MathWorks, Inc.
sig = inputCell{1};
roiTable = inputCell{2};
L = length(sig);
M = signalMask(roiTable);
% Get categorical mask and give priority to QRS regions when there is overlap
mask = catmask(M,L,'OverlapAction','prioritizeByList','PriorityList',[2 1 3]);
% Set missing values to "n/a"
mask(ismissing(mask)) = "n/a";
outputCell = {sig,mask};


優哉 山口
優哉 山口 on 1 Dec 2020
Dear Image Analyst
Thank you for your comment.
By creating getmask.m, we were able to get rid of the initial error.
However, I still get the following error, so I'll check it out.
Error: catmask
PriorityList should be an array with 4 elements.
Error: signalMask/catmask (line 403)
PriorityList,{'numeric'},{'vector','positive','numel',obj.pNumCategories},'catmask','PriorityList ');
Error: getmask (line 19)
mask = catmask(M,L, 'OverlapAction', 'prioritizeByList', 'PriorityList',[2 13]);
Error: (line 619)
data = ds.Transforms{ii}(data);
Error: (line 222)
[data, info] = ds.applyTransforms(data, info);
Error: (line 288)
dataFromRead = read(copyds);
Error: segmentation_default (line 30)
transformedData = preview(trainDs)
優哉 山口
優哉 山口 on 7 Dec 2020
I solved the problem in the following way
1. completely deleted the data that had been downloaded in the Japanese version (2020a)
2. download the example (2020b) from the Matlab website again and run it
There were problems caused by the mixing of multiple environments.
Thank you for your support.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!