2019-05-06 16:34:28 +02:00
|
|
|
classdef RespiratoryPhase < Phase
|
|
|
|
properties
|
|
|
|
FullPhase = Phase;
|
|
|
|
InspirationPositions = [];
|
|
|
|
ExpirationPositions = [];
|
|
|
|
end
|
|
|
|
|
2019-05-07 16:36:02 +02:00
|
|
|
properties % (GetAccess = private) should become private
|
|
|
|
IMF = uint32(0);
|
|
|
|
InspirationTreshold = double(0);
|
|
|
|
ExpirationTreshold = double(0);
|
|
|
|
MaxRespPhase = double(0);
|
|
|
|
MinRespPhase = double(0);
|
|
|
|
end
|
|
|
|
|
2019-05-06 16:34:28 +02:00
|
|
|
methods %constructor
|
|
|
|
function obj=RespiratoryPhase(Phase)
|
|
|
|
if nargin==0;return;end
|
|
|
|
% gets properties of superclass
|
2019-05-07 16:36:02 +02:00
|
|
|
obj.FullPhase = Phase.ModePhases;
|
2019-05-06 16:34:28 +02:00
|
|
|
obj.WorkLoad = Phase.WorkLoad;
|
|
|
|
obj.Video = Phase.Video;
|
|
|
|
end
|
|
|
|
|
|
|
|
% Choose the correct IMF depending on the work load
|
|
|
|
function SelectPhase(obj)
|
|
|
|
if strcmp(obj.WorkLoad,'Rest')
|
|
|
|
imf_number = 5;
|
|
|
|
else if strcmp(obj.WorkLoad,'Exercise')
|
|
|
|
imf_number = 4;
|
|
|
|
else if strcmp(obj.WorkLoad,'Continuous Acquisition')
|
|
|
|
imf_number = 5;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-05-07 16:36:02 +02:00
|
|
|
% SHOULD TRY TO USE GETPHASE FUNCTION
|
|
|
|
% obj.IMF = imf_number;
|
|
|
|
% GetPhase@Phase(obj.FullPhase,obj.IMF);
|
|
|
|
obj.Values = obj.FullPhase(imf_number,:); %Phase corresponding to respiratory phase
|
2019-05-06 16:34:28 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
% Detects the frame's positions of inspiration moments
|
|
|
|
function Inspiration(obj)
|
2019-05-07 16:36:02 +02:00
|
|
|
obj.MaxRespPhase = max(obj.Values); % respiratory phase maxima
|
|
|
|
obj.InspirationTreshold = 0.8*obj.MaxRespPhase; % inspiration treshold
|
|
|
|
index1 = obj.Values > obj.InspirationTreshold; % frames above inpiration treshold
|
2019-05-06 16:34:28 +02:00
|
|
|
indexNumeric1 = find(index1);
|
2019-05-07 16:36:02 +02:00
|
|
|
values1 = obj.Values(indexNumeric1);
|
2019-05-06 16:34:28 +02:00
|
|
|
[ordered_values1 oredered_index1] = sort(values1);
|
|
|
|
obj.InspirationPositions = indexNumeric1(oredered_index1); % sorts the frames in ascending respiratory phase
|
|
|
|
end
|
|
|
|
|
|
|
|
% Detects the frame's positions of expiration moments
|
|
|
|
function Expiration(obj)
|
2019-05-07 16:36:02 +02:00
|
|
|
obj.MinRespPhase = min(obj.Values); % respiratory phase minima
|
|
|
|
obj.ExpirationTreshold = 0.8*obj.MinRespPhase; % systole treshold
|
|
|
|
index2 = obj.Values < obj.ExpirationTreshold; % frames below the systole treshold
|
2019-05-06 16:34:28 +02:00
|
|
|
indexNumeric2 = find(index2);
|
2019-05-07 16:36:02 +02:00
|
|
|
values2 = obj.Values(indexNumeric2);
|
2019-05-06 16:34:28 +02:00
|
|
|
[ordered_values2 oredered_index2] = sort(values2);
|
|
|
|
obj.ExpirationPositions = indexNumeric2(oredered_index2); % sorts the frames in ascending respiratory phase
|
|
|
|
end
|
2019-05-07 16:36:02 +02:00
|
|
|
|
2019-05-06 16:34:28 +02:00
|
|
|
end
|
|
|
|
end
|