classdef RespiratoryPhase < Phase properties FullPhase = Phase; SelectedPhase = []; InspirationPositions = []; ExpirationPositions = []; end methods %constructor function obj=RespiratoryPhase(Phase) if nargin==0;return;end % gets properties of superclass obj.FullPhase = Phase.Values; 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 obj.SelectedPhase = obj.FullPhase(imf_number,:); %Phase corresponding to respiratory phase end % Detects the frame's positions of inspiration moments function Inspiration(obj) max_resp_phase = max(obj.SelectedPhase); % respiratory phase maxima treshold_insp = 0.8*max_resp_phase; % inspiration treshold index1 = obj.SelectedPhase > treshold_insp; % frames above inpiration treshold indexNumeric1 = find(index1); values1 = obj.SelectedPhase(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) min_resp_phase = min(obj.SelectedPhase); % respiratory phase minima treshold_exp = 0.8*min_resp_phase; % systole treshold index2 = obj.SelectedPhase < treshold_exp; % frames below the systole treshold indexNumeric2 = find(index2); values2 = obj.SelectedPhase(indexNumeric2); [ordered_values2 oredered_index2] = sort(values2); obj.ExpirationPositions = indexNumeric2(oredered_index2); % sorts the frames in ascending respiratory phase end end end