-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.m
124 lines (109 loc) · 3.87 KB
/
main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
clc;
clear;
close all;
%% Installing the needed packages
addpath('functions');
addpath('lib');
addpath('lib\hosa');
%% Set values for constant variables
maxNumberOfIMF = 6;
alpha = 0.05;
trainingFolder = ['a', 'b', 'c', 'd', 'e', 'f'];
%% Create a folder for output data and figures
if not(isfolder('output\data'))
mkdir('output\data')
end
if not(isfolder('output\figures'))
mkdir('output\figures')
end
%% Plot IMFs for PCG recordings
% Diagnosis: AD (Aortic disease)
plot_IMF('a0213','Aortic disease');
% Diagnosis: AS (Aortic stenosis)
plot_IMF('c0026','Aortic stenosis');
% Diagnosis: Benign (Innocent or benign murmurs)
plot_IMF('a0004','Benign murmurs');
% Diagnosis: CAD (Coronary artery disease)
plot_IMF('b0063','Coronary artery disease');
% Diagnosis: MPC (Miscellaneous pathological conditions)
plot_IMF('a0203','Pathologic');
% Diagnosis: MR (Mitral regurgitation)
plot_IMF('c0012','Mitral regurgitation');
% Diagnosis: MVP (Mitral valve prolapse)
plot_IMF('a0040','Mitral valve prolapse');
% Diagnosis: Normal
plot_IMF('a0012','Normal');
%% Extract the useful IMFs
for i=1:6
fprintf("Extracting IMFs from database " + ...
trainingFolder(i) + "...\n");
IMF_extraction(trainingFolder(i));
fprintf("IMFs extracted successfully from database " + ...
trainingFolder(i) + "\n");
end
%% Identify the useful IMFs
percentages = check_kurtosis_test();
fprintf("\n---- Percentage of 1s in each IMF ----\n");
for i=1:maxNumberOfIMF
fprintf("\tIMF%d: %.3f%%\n",i,percentages(i));
end
%% Plot the bispectra of the fundamental heart sounds (S1, S2) for each IMF
% Diagnosis: AD (Aortic disease)
plot_bispectrum('a0213','Aortic disease');
% Diagnosis: AS (Aortic stenosis)
plot_bispectrum('c0026','Aortic stenosis');
% Diagnosis: Benign (Innocent or benign murmurs)
plot_bispectrum('a0004','Benign murmurs');
% Diagnosis: CAD (Coronary artery disease)
plot_bispectrum('b0063','Coronary artery disease');
% Diagnosis: MPC (Miscellaneous pathological conditions)
plot_bispectrum('a0203','Pathologic');
% Diagnosis: MR (Mitral regurgitation)
plot_bispectrum('c0012','Mitral regurgitation');
% Diagnosis: MVP (Mitral valve prolapse)
plot_bispectrum('a0040','Mitral valve prolapse');
% Diagnosis: Normal
plot_bispectrum('a0012','Normal');
%% Compute the bispectral features
for i=1:6
fprintf("Extracting features from database " + ...
trainingFolder(i) + "...\n");
bisp_features_extraction(trainingFolder(i));
fprintf("Features extracted successfully from database " + ...
trainingFolder(i) + "\n");
end
%% Merge the extracted features into one csv file
merge_bisp_features_files()
%% Statistical analysis of bispectral features
bisp_features_analysis(alpha,'disp');
%% Plot cepstrum and find pitch
% Diagnosis: AD (Aortic disease)
plot_cepstrum('a0213','Aortic disease');
% Diagnosis: AS (Aortic stenosis)
plot_cepstrum('c0026','Aortic stenosis');
% Diagnosis: Benign (Innocent or benign murmurs)
plot_cepstrum('a0004','Benign murmurs');
% Diagnosis: CAD (Coronary artery disease)
plot_cepstrum('b0063','Coronary artery disease');
% Diagnosis: MPC (Miscellaneous pathological conditions)
plot_cepstrum('a0203','Pathologic');
% Diagnosis: MR (Mitral regurgitation)
plot_cepstrum('c0012','Mitral regurgitation');
% Diagnosis: MVP (Mitral valve prolapse)
plot_cepstrum('a0040','Mitral valve prolapse');
% Diagnosis: Normal
plot_cepstrum('a0012','Normal');
%% Compute the pitch from the cepstrum for all the signals
for i=1:6
fprintf("Extracting pitch from database " + ...
trainingFolder(i) + "...\n");
pitch_estimation_cepstrum(trainingFolder(i));
fprintf("Pitch extracted successfully from database " + ...
trainingFolder(i) + "\n");
end
%% Merge the extracted features into one csv file
merge_pitch_files()
%% Statistics
pitch_statistical_analysis();
%% Plot the impulse response and the reconstructed signal using Cepstrum
find_impulse_response('a0001','MVP');