deeplabcut_into_motionMapper Undefined function or variable 'findWatershedRegion'

Im having problems in the deeplabcut_into_motionMapper.m script where it reaches a part in the code where it says there is an undefined function at line 200 called findWatershedRegion. Could someone let me know if there is a script or something else that I need that is missing? I have tried reinstalling the files but I was not able to find a solution.

Here is the portion of the code that the line is found in.

%% Make density plots

if isunix
    addpath(genpath('./utilities/'));
    addpath(genpath('./t_sne/'));
else
    addpath(genpath('t_sne'));
    addpath(genpath('utilities'));
end

maxVal = max(max(abs(combineCells(embeddingValues))));
maxVal = round(maxVal * 1.3);

sigma = maxVal / 15;
numPoints = 501;
rangeVals = [-maxVal maxVal];

[xx,density] = findPointDensity(combineCells(embeddingValues),sigma,numPoints,rangeVals);


figure
maxDensity = max(density(:));
imagesc(xx,xx,density)
axis equal tight off xy
caxis([0 maxDensity * .8])
colormap(cc)
colorbar
set(gca,'fontsize',14,'fontweight','bold')


LL = watershed(-density,8);
LL(density < 1e-6) = 0;
a = setdiff(unique(LL),0);
for i=1:length(a)
    LL(LL==a(i)) = i;
end
savefig(strcat(fileName,'_density_map.fig'))

figure
subplot(1,2,1)
imagesc(xx,xx,density)
caxis([0 maxDensity * .8])
axis equal tight off xy
hold on
set(gca,'fontsize',16,'fontweight','bold')

subplot(1,2,2)
imagesc(xx,xx,LL)
axis equal tight off xy
hold on
colormap(cc)

numRegions = max(LL(:));
Bs = cell(numRegions,1);
for i=1:numRegions
    
    B = bwboundaries(LL==i);
    subplot(1,2,1)
    plot(xx(B{1}(:,2)),xx(B{1}(:,1)),'k-','linewidth',2)
    
    subplot(1,2,2)
    plot(xx(B{1}(:,2)),xx(B{1}(:,1)),'k-','linewidth',2)
    
    Bs{i} = B{1};
    
    [ii,jj] = find(LL==i);
    medianX = xx(round(median(jj)));
    medianY = xx(round(median(ii)));
    text(medianX,medianY,num2str(i),'backgroundcolor','k','color','w','fontweight','bold','fontsize',12)
   
end

zValues = combineCells(embeddingValues);
N = length(zValues(:,1));

[regionValues,v,obj,pRest] = findWatershedRegion(zValues,xx,LL,[],[],[]);
ethogram = zeros(N,numRegions+1);
for i=1:N
    ethogram(i,regionValues(i)+1) = regionValues(i);
end
savefig(strcat(fileName,'_Ethogram.fig'))



figure
imagesc((1:N)./parameters.samplingFreq,0:numRegions,ethogram')
colormap(cc)
caxis([0 numRegions]);
hold on
axis xy
for i=0:numRegions
    plot([0 N/parameters.samplingFreq],double(i)-.5+zeros(1,2),'k-')
end

CC2 = bwconncomp(regionValues == 0);
for i=1:CC2.NumObjects
    ii = CC2.PixelIdxList{i}(1)/parameters.samplingFreq;
    Q =  length(CC2.PixelIdxList{i})/parameters.samplingFreq;
    rectangle('Position',[ii -.5 Q 1],'facecolor','k')
end
xlim([0 N/parameters.samplingFreq]);
set(gca,'ytick',0:numRegions,'fontsize',16,'fontweight','bold','ticklength',[0 0])

xlabel('Time (s)','fontsize',18,'fontweight','bold')
ylabel('Behavior #','fontsize',18,'fontweight','bold')
title('Ethogram','fontsize',22,'fontweight','bold')


if parameters.numProcessors > 1
    delete(gcp('nocreate'));
end

savefig(strcat(fileName,'_Region_map.fig'))