diff --git a/ShoulderCase/@Muscle/Muscle.m b/ShoulderCase/@Muscle/Muscle.m index 065a6a6..a61da31 100644 --- a/ShoulderCase/@Muscle/Muscle.m +++ b/ShoulderCase/@Muscle/Muscle.m @@ -1,64 +1,70 @@ classdef Muscle < handle % The Muscle class is linked to a segmented muscle file (a mask) % and to the slice it has been segmented out of. % % Then, this class can measured values linked to the PCSA and the % muscle's degeneration. properties container = nan; name = ""; segmentationName = ""; sliceName = ""; PCSA = nan; atrophy = nan; fat = nan; osteochondroma = nan; degeneration = nan; forceApplicationPoint = nan; forceVector = nan; end methods function obj = Muscle(musclesContainer,muscleName) obj.container = musclesContainer; obj.name = muscleName; [~, ~] = mkdir(obj.dataPath); [~, ~] = mkdir(obj.dataMaskPath); [~, ~] = mkdir(obj.dataContourPath); end function output = dataPath(obj) output = fullfile(obj.container.dataPath, obj.name); end function output = dataMaskPath(obj) output = fullfile(obj.dataPath, "mask"); end function output = dataContourPath(obj) output = fullfile(obj.dataPath, "contour"); end function setSliceName(obj, value) obj.sliceName = value; end function setSegmentationName(obj, value) obj.segmentationName = value; end - function output = loadMask(obj) - output = imread(fullfile(obj.dataMaskPath,obj.segmentationName + "_Mask.png")) > 0; + function output = loadMask(obj, maskSuffix) + output = imread(fullfile(obj.dataMaskPath,... + obj.segmentationName+"_"+maskSuffix+".png")) > 0; + end + + function output = saveMask(obj, mask, maskSuffix) + output = imwrite(fullfile(obj.dataMaskPath,... + obj.segmentationName+"_"+maskSuffix+".png")) > 0; end function output = loadPixelCoordinates(obj) output = load(fullfile(obj.container.dataSlicesPath,... obj.sliceName + "_PixelCoordinates.mat")).imagesPixelCoordinates; end end end diff --git a/ShoulderCase/@Muscle/measureAndSaveCentroid.m b/ShoulderCase/@Muscle/measureAndSaveCentroid.m new file mode 100644 index 0000000..49e1c49 --- /dev/null +++ b/ShoulderCase/@Muscle/measureAndSaveCentroid.m @@ -0,0 +1,7 @@ +function measureAndSaveCentroid(obj) + muscleContour = obj.loadMask("Contour"); + centroidIndices = round(regionprops(muscleContour).Centroid); + muscleCentroid = false(size(muscleContour)); + muscleCentroid(centroidIndices(1), centroidIndices(2)) = true; + obj.saveMask(muscleCentroid, "Centroid"); +end \ No newline at end of file diff --git a/ShoulderCase/@Muscle/measureAndSaveContour.m b/ShoulderCase/@Muscle/measureAndSaveContour.m new file mode 100644 index 0000000..e645430 --- /dev/null +++ b/ShoulderCase/@Muscle/measureAndSaveContour.m @@ -0,0 +1,5 @@ +function measureAndSaveContour(obj) + muscleSegmentation = obj.loadMask("Segmentation"); + muscleContour = bwmorph(muscleSegmentation, "remove"); + obj.saveMask(muscleContour, "Contour"); +end \ No newline at end of file