Skip to content

Commit

Permalink
Fix bugs PPG + legend
Browse files Browse the repository at this point in the history
  • Loading branch information
goldina committed Sep 30, 2023
1 parent c3193c8 commit 006ac03
Show file tree
Hide file tree
Showing 6 changed files with 578 additions and 398 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Examples Eran/
Create Examples/
Problems/

Examples/

pebm - Copy/

SHANY Sheina ecg-kit.txt
Expand Down
6 changes: 6 additions & 0 deletions GUI/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ Saved/

atr2quality.m
PhysioZooGUI_Saved.m
PhysioZooGUI_PeakDetection - Copy.m
PhysioZooGUI_HRVAnalysis OLD.m
download_ppg_exe_file.m
get_biomarkers.m
get_fiducials.m


4 changes: 4 additions & 0 deletions GUI/PPG/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

pyPPG.exe


36 changes: 25 additions & 11 deletions GUI/PPG_biomarkers.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
exe_file_path = fileparts(mfilename('fullpath'));
executable_file = [exe_file_path filesep 'PPG' filesep 'pyPPG.exe'];

if exist(executable_file, 'file') && exist(config_file_name, 'file') && exist(fiducials_path, 'file')

config_struct = ReadYaml(config_file_name);
Fs = load(ppg_file_name, 'Fs');

% if exist(executable_file, 'file') && exist(config_file_name, 'file') && exist(fiducials_path, 'file')
try
try
config_struct = ReadYaml(config_file_name);
Fs = load(ppg_file_name, 'Fs');
catch e
rethrow(e);
end
if ~exist(executable_file, 'file')
ME = MException('PPG_peaks:noSuchFile', 'Please, download PPG executable from https://physiozoo.com/!');
throw(ME);
end
%% Input parameters
in.data_path = ppg_file_name;
in.savedata = 1;
Expand Down Expand Up @@ -54,11 +61,18 @@
end
else
disp(['PPG_biomarkers error: ', error, '\n', result]);
% rethrow(MException('PPG_biomarkers:jsystem', error));
ME = MException('PPG_peaks:jsystem', error);
throw(ME);
% disp(['PPG_biomarkers error: ', error, '\n', result]);
% rethrow(MException('PPG_biomarkers:jsystem', error));
end
% if isempty(biomarkers_path)
% rethrow('The PPG biomarkers was''t calculated.');
% end
else
h_e = errordlg('The PPG exe or config file does''t exist!', 'Input Error'); setLogo(h_e, 'PPG');
% if isempty(biomarkers_path)
% rethrow('The PPG biomarkers was''t calculated.');
% end
% else
% h_e = errordlg('Please, download PPG executable for https://physiozoo.com/!', 'Input Error'); setLogo(h_e, 'PPG');
% h_e = errordlg('The PPG exe or config file does''t exist!', 'Input Error'); setLogo(h_e, 'PPG');
% end
catch e
rethrow(e);
end
65 changes: 44 additions & 21 deletions GUI/PPG_peaks.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@
exe_file_path = fileparts(mfilename('fullpath'));
executable_file = [exe_file_path filesep 'PPG' filesep 'pyPPG.exe'];

if exist(executable_file, 'file') && exist(config_file_name, 'file')

config_struct = ReadYaml(config_file_name);
Fs = load(ppg_file_name, 'Fs');
try
% if exist(executable_file, 'file') && exist(config_file_name, 'file')
try
config_struct = ReadYaml(config_file_name);
Fs = load(ppg_file_name, 'Fs');
catch e
rethrow(e);
end
if ~exist(executable_file, 'file')
ME = MException('PPG_peaks:noSuchFile', 'Please, download PPG executable from https://physiozoo.com/!');
throw(ME);
end

%% Input parameters
in.data_path = ppg_file_name;
Expand All @@ -32,33 +40,48 @@
executable_file = strrep(executable_file ,'\', '/');
%% EXTRACT FIDUCIALS
in.process_type = 'fiducials';
tic

func_args = zip_args(fieldnames(in), struct2cell(in));
command = ['"' executable_file '" "' ,'{\"function\":\"ppg_example\",\"args\":',func_args,'}'];

% try
tic
[status, result, error] = jsystem(command);

if status ~= 0
disp(['PPG_peaks error: ', error, '\n', result]);
rethrow(error);
else
toc
% if status ~= 0
% disp(['PPG_peaks error: ', error, '\n', result]);
% rethrow(error);
if status == 0
fiducials_file_names = jsondecode(result);
if ~isempty(fiducials_file_names) && isfield(fiducials_file_names, 'fiducials_mat')
fiducials_path = fiducials_file_names.fiducials_mat;
if exist(fiducials_path, 'file')
a = load(fiducials_path);
if isfield(a, 'PPG_fiducials')
fiducials_table = struct2table(a.PPG_fiducials);
end
end
fiducials_table = struct2table(a.PPG_fiducials);
end
end
end
else
disp(['PPG_peaks error: ', error, '\n', result]);
ME = MException('PPG_peaks:jsystem', error);
throw(ME);
end
toc
% if isempty(fiducials_table) || isempty(fiducials_path)
% rethrow('The fiducials points was''t calculated.');
% end
else
h_e = errordlg('The PPG exe or config file does''t exist!', 'Input Error'); setLogo(h_e, 'PPG');
% rethrow('The PPG exe or config file does''t exist!');

% if isempty(fiducials_table) || isempty(fiducials_path)
% rethrow('The fiducials points was''t calculated.');
% end
% else
% catch e
% if ~exist(executable_file, 'file')
% ME = MException('PPG_peaks:noSuchFile', 'Please, download PPG executable from https://physiozoo.com/!');
% rethrow(ME);
% else
% rethrow([e ': ' error]);
% end
% h_e = errordlg('Please, download PPG executable for https://physiozoo.com/!', 'Input Error'); setLogo(h_e, 'PPG');
% h_e = errordlg('The PPG exe or config file does''t exist!', 'Input Error'); setLogo(h_e, 'PPG');
% rethrow('The PPG exe or config file does''t exist!');
% end
catch e
rethrow(e);
end

0 comments on commit 006ac03

Please sign in to comment.