function output = plot(obj,varargin) if nargin == 2 error('Provide the slice name and the mask name or provide nothing (auto slice and segmentations will be plotted).') elseif nargin == 3 sliceName = varargin{1} + "_ForSegmentation.png"; maskName = varargin{2} + "_Mask.png"; else sliceName = "rotatorCuffMatthieu_ForSegmentation.png"; maskName = "autoMatthieu_Mask.png"; end rotatorCuffCrossSection = imread(fullfile(obj.dataSlicesPath,sliceName)); leg = {}; plotHandle(1) = imshow(rotatorCuffCrossSection); hold on muscleColor = containers.Map; muscleColor("SC") = "b"; muscleColor("SS") = "r"; muscleColor("IS") = "g"; muscleColor("TM") = "y"; for muscleName = ["SC", "SS", "IS", "TM"] try segmentedImage = imread(fullfile(obj.(muscleName).dataMaskPath,maskName)); catch continue end if (max(segmentedImage,[],'all') > 0) % if segmentation result is not empty leg{end+1} = muscleName; [~,plotHandle(end+1)] = contour(segmentedImage,'color',muscleColor(muscleName)); end end plotHandle(end+1) = legend(leg); output = plotHandle; end