classdef RespiratoryPhase < Phase properties FullPhase = Phase; InspirationPositions = []; ExpirationPositions = []; end properties % (GetAccess = private) should become private IMF = uint32(0); InspirationTreshold = double(0); ExpirationTreshold = double(0); MaxRespPhase = double(0); MinRespPhase = double(0); end methods %constructor function obj=RespiratoryPhase(Phase) if nargin==0;return;end % gets properties of superclass obj.FullPhase = Phase.ModePhases; 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 % 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 end % Detects the frame's positions of inspiration moments function Inspiration(obj) 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 indexNumeric1 = find(index1); values1 = obj.Values(indexNumeric1); [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) 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 indexNumeric2 = find(index2); values2 = obj.Values(indexNumeric2); [ordered_values2 oredered_index2] = sort(values2); obj.ExpirationPositions = indexNumeric2(oredered_index2); % sorts the frames in ascending respiratory phase end end end