CardiacPhase/Code/CardiacPhase.m

66 lines
2.6 KiB
Matlab

classdef CardiacPhase < Phase
properties
FullPhase = Phase;
SystolePositions = [];
DiastolePositions = [];
SystoleTreshold = double(0);
DiastoleTreshold = double(0);
end
methods %constructor
function obj=CardiacPhase(Phase)
if nargin==0;return;end
% gets properties of superclass
obj.FullPhase = Phase.ModePhases;
obj.WorkLoad = Phase.WorkLoad;
obj.Video = Phase.Video;
end
%
% methods %set methods
% % function set.ToBeSetByUser(obj,val)
% % if ~isboolean(val);error('provide a boolean value please');end
% % obj.ToBeSetByUser=val;
% % end
% end
%
% Choose the correct IMF depending on the work load
function SelectPhase(obj)
if strcmp(obj.WorkLoad,'Rest')
imf_number = 3;
else if strcmp(obj.WorkLoad,'Exercise')
imf_number = 2;
else if strcmp(obj.WorkLoad,'Continuous Acquisition')
imf_number = 3;
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 the cardiac phase
end
% Detects the frame's positions of diastolic events
function Diastole(obj)
max_heart_phase = max(obj.Values); % cardiac phase maxima
obj.DiastoleTreshold = 0.8*max_heart_phase; % diastole treshold
index1 = obj.Values > obj.DiastoleTreshold; % frames with phase above the diastolic treshold
indexNumeric1 = find(index1);
values1 = obj.Values(indexNumeric1);
[ordered_values1 oredered_index1] = sort(values1);
obj.DiastolePositions = indexNumeric1(oredered_index1); % sorts the frames in ascending cardiac phase
end
% Detects the frame's positions of systolic events
function Systole(obj)
min_heart_phase = min(obj.Values); % cardiac phase minima
obj.SystoleTreshold = 0.8*min_heart_phase; % systole treshold
index2 = obj.Values < obj.SystoleTreshold; % frames with phase below the systolic treshold
indexNumeric2 = find(index2);
values2 = obj.Values(indexNumeric2);
[ordered_values2 oredered_index2] = sort(values2);
obj.SystolePositions = indexNumeric2(oredered_index2); % sorts the frames in ascending cardiac phase
end
end
end