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} + "_Segmentation.png"; else sliceName = "rotatorCuffMatthieu_ForSegmentation.png"; maskName = "autoMatthieu_Segmentation.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 plotHandle(end+1) = plotMuscleContour(obj.(muscleName), muscleColor); leg{end + 1} = muscleName; end try plotHandle(end+1) = plotMuscleCentroid(obj.(muscleName), muscleColor); leg{end + 1} = muscleName + " centroid"; end end plotHandle(end+1) = legend(leg, "Location", "bestoutside"); output = plotHandle; end function output = plotMuscleContour(muscle, muscleColor) muscleContour = muscle.loadMask("Contour"); [contourY, contourX] = find(muscleContour); output = scatter(contourX, contourY,... 1, ".",... "MarkerEdgeColor", muscleColor(muscle.name),... "MarkerFaceColor", muscleColor(muscle.name)); end function output = plotMuscleCentroid(muscle, muscleColor) muscleCentroid = muscle.loadMask("Centroid"); [centroidY, centroidX] = find(muscleCentroid); output = scatter(centroidX, centroidY,... 50, "o",... "MarkerEdgeColor", muscleColor(muscle.name),... "MarkerFaceColor", muscleColor(muscle.name)); end