function output = plot(obj,varargin) % For now this function is specific to plotting the rotator cuff segmentation % results 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 SCase = obj.shoulder.SCase; muscleNames = fields(obj.list); rotatorCuffCrossSection = imread(fullfile(obj.dataSlicesPath,sliceName)); leg = {}; plotHandle(1) = imshow(rotatorCuffCrossSection); hold on colors = {'g','r','b','y'}; for i = 1:length(muscleNames) try segmentedImage = imread(fullfile(obj.list.(muscleNames{i}).dataMaskPath,maskName)); catch continue end if (max(segmentedImage,[],'all') > 0) % if segmentation result is not empty leg{end+1} = muscleNames{i}; [~,plotHandle(i+1)] = contour(segmentedImage,'color',colors{i}); end end plotHandle(i+2) = legend(leg); output = plotHandle; end