ref #3 - methode zum auswählen der achse hinzugefügt. nutze qualitätsmerkmale RMS, Intersections und GeoMean um die beste Achse zu suchen.
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
%measurements = dlmread('../measurements/wearR/PR_recording_80bpm_4-4_177596720.csv', ';'); %*
|
%measurements = dlmread('../measurements/wearR/PR_recording_80bpm_4-4_177596720.csv', ';'); %*
|
||||||
%measurements = dlmread('../measurements/wearR/recording_48bpm_4-4_176527527.csv', ';');
|
%measurements = dlmread('../measurements/wearR/recording_48bpm_4-4_176527527.csv', ';');
|
||||||
%measurements = dlmread('../measurements/wearR/recording_48bpm_4-4_176606785.csv', ';');
|
%measurements = dlmread('../measurements/wearR/recording_48bpm_4-4_176606785.csv', ';');
|
||||||
%measurements = dlmread('../measurements/wearR/recording_48bpm_4-4_176696356.csv', ';'); %*
|
%measurements = dlmread('../../measurements/wearR/recording_48bpm_4-4_176696356.csv', ';'); %*
|
||||||
%measurements = dlmread('../measurements/wearR/recording_48bpm_4-4_176820066.csv', ';');
|
%measurements = dlmread('../measurements/wearR/recording_48bpm_4-4_176820066.csv', ';');
|
||||||
%measurements = dlmread('../measurements/wearR/recording_48bpm_4-4_176931941.csv', ';'); %double
|
%measurements = dlmread('../measurements/wearR/recording_48bpm_4-4_176931941.csv', ';'); %double
|
||||||
%measurements = dlmread('../measurements/wearR/recording_72bpm_4-4_176381633.csv', ';');
|
%measurements = dlmread('../measurements/wearR/recording_72bpm_4-4_176381633.csv', ';');
|
||||||
@@ -41,8 +41,8 @@
|
|||||||
%measurements = dlmread('../measurements/wearR/recording_180bpm_4-4_177064915.csv', ';'); *
|
%measurements = dlmread('../measurements/wearR/recording_180bpm_4-4_177064915.csv', ';'); *
|
||||||
|
|
||||||
|
|
||||||
files = dir(fullfile('../../measurements/lgWear/', '*.csv'));
|
%files = dir(fullfile('../../measurements/lgWear/', '*.csv'));
|
||||||
%files = dir(fullfile('../../measurements/wearR/', '*.csv'));
|
files = dir(fullfile('../../measurements/wearR/', '*.csv'));
|
||||||
|
|
||||||
for file = files'
|
for file = files'
|
||||||
|
|
||||||
@@ -104,24 +104,24 @@ for file = files'
|
|||||||
corr_y_pos(corr_y_pos<0)=0;
|
corr_y_pos(corr_y_pos<0)=0;
|
||||||
corr_z_pos(corr_z_pos<0)=0;
|
corr_z_pos(corr_z_pos<0)=0;
|
||||||
|
|
||||||
[peak_x, idx_x] = findpeaks(corr_x_pos, 'MinPeakHeight', 0.1,'MinPeakDistance', 100);
|
[peak_x, idx_x_raw] = findpeaks(corr_x_pos, 'MinPeakHeight', 0.1,'MinPeakDistance', 50, 'MinPeakProminence', 0.1);
|
||||||
[peak_y, idx_y] = findpeaks(corr_y_pos, 'MinPeakHeight', 0.1,'MinPeakDistance', 100);
|
[peak_y, idx_y_raw] = findpeaks(corr_y_pos, 'MinPeakHeight', 0.1,'MinPeakDistance', 50, 'MinPeakProminence', 0.1);
|
||||||
[peak_z, idx_z] = findpeaks(corr_z_pos, 'MinPeakHeight', 0.1,'MinPeakDistance', 100);
|
[peak_z, idx_z_raw] = findpeaks(corr_z_pos, 'MinPeakHeight', 0.1,'MinPeakDistance', 50, 'MinPeakProminence', 0.1);
|
||||||
|
|
||||||
idx_x = sort(idx_x);
|
idx_x_raw = sort(idx_x_raw);
|
||||||
idx_y = sort(idx_y);
|
idx_y_raw = sort(idx_y_raw);
|
||||||
idx_z = sort(idx_z);
|
idx_z_raw = sort(idx_z_raw);
|
||||||
|
|
||||||
idx_x = findFalseDetectedPeaks(idx_x, lag_x, corr_x);
|
idx_x = findFalseDetectedPeaks(idx_x_raw, lag_x, corr_x);
|
||||||
idx_y = findFalseDetectedPeaks(idx_y, lag_y, corr_y);
|
idx_y = findFalseDetectedPeaks(idx_y_raw, lag_y, corr_y);
|
||||||
idx_z = findFalseDetectedPeaks(idx_z, lag_z, corr_z);
|
idx_z = findFalseDetectedPeaks(idx_z_raw, lag_z, corr_z);
|
||||||
|
|
||||||
Xwindow = m(i-window_size:i,3);
|
Xwindow = m(i-window_size:i,3);
|
||||||
Xwindow_mean_ts_diff = mean(diff(lag_x(idx_x) * sample_rate_ms)); %2.5 ms is the time between two samples at 400hz
|
Xwindow_mean_ts_diff = mean(diff(lag_x(idx_x) * sample_rate_ms)); %2.5 ms is the time between two samples at 400hz
|
||||||
Xwindow_mean_bpm = (60000 / (Xwindow_mean_ts_diff));
|
Xwindow_mean_bpm = (60000 / (Xwindow_mean_ts_diff));
|
||||||
|
|
||||||
figure(11);
|
figure(11);
|
||||||
plot(lag_x, corr_x, lag_x(idx_x), corr_x(idx_x), 'r*') %z
|
plot(lag_x, corr_x, lag_x(idx_x), corr_x(idx_x), 'r*', lag_x(idx_x_raw), corr_x(idx_x_raw), 'g*') %z
|
||||||
hold ("on")
|
hold ("on")
|
||||||
m_label_ms = strcat(" mean ms: ", num2str(Xwindow_mean_ts_diff));
|
m_label_ms = strcat(" mean ms: ", num2str(Xwindow_mean_ts_diff));
|
||||||
m_label_bpm = strcat(" mean bpm: ", num2str(Xwindow_mean_bpm));
|
m_label_bpm = strcat(" mean bpm: ", num2str(Xwindow_mean_bpm));
|
||||||
@@ -133,7 +133,7 @@ for file = files'
|
|||||||
Ywindow_mean_bpm = (60000 / (Ywindow_mean_ts_diff));
|
Ywindow_mean_bpm = (60000 / (Ywindow_mean_ts_diff));
|
||||||
|
|
||||||
figure(12);
|
figure(12);
|
||||||
plot(lag_y, corr_y, lag_y(idx_y), corr_y(idx_y), 'r*') %z
|
plot(lag_y, corr_y, lag_y(idx_y), corr_y(idx_y), 'r*', lag_y(idx_y_raw), corr_y(idx_y_raw), 'g*') %z
|
||||||
hold ("on")
|
hold ("on")
|
||||||
m_label_ms = strcat(" mean ms: ", num2str(Ywindow_mean_ts_diff));
|
m_label_ms = strcat(" mean ms: ", num2str(Ywindow_mean_ts_diff));
|
||||||
m_label_bpm = strcat(" mean bpm: ", num2str(Ywindow_mean_bpm));
|
m_label_bpm = strcat(" mean bpm: ", num2str(Ywindow_mean_bpm));
|
||||||
@@ -145,12 +145,28 @@ for file = files'
|
|||||||
Zwindow_mean_bpm = (60000 / (Zwindow_mean_ts_diff));
|
Zwindow_mean_bpm = (60000 / (Zwindow_mean_ts_diff));
|
||||||
|
|
||||||
figure(13);
|
figure(13);
|
||||||
plot(lag_z, corr_z, lag_z(idx_z), corr_z(idx_z), 'r*') %z
|
plot(lag_z, corr_z, lag_z(idx_z), corr_z(idx_z), 'r*', lag_z(idx_z_raw), corr_z(idx_z_raw), 'g*') %z
|
||||||
hold ("on")
|
hold ("on")
|
||||||
m_label_ms = strcat(" mean ms: ", num2str(Zwindow_mean_ts_diff));
|
m_label_ms = strcat(" mean ms: ", num2str(Zwindow_mean_ts_diff));
|
||||||
m_label_bpm = strcat(" mean bpm: ", num2str(Zwindow_mean_bpm));
|
m_label_bpm = strcat(" mean bpm: ", num2str(Zwindow_mean_bpm));
|
||||||
title(strcat(" ", m_label_ms, " ", m_label_bpm));
|
title(strcat(" ", m_label_ms, " ", m_label_bpm));
|
||||||
hold ("off");
|
hold ("off");
|
||||||
|
|
||||||
|
|
||||||
|
%breakpoints dummy for testing
|
||||||
|
if(length(idx_x) > length(idx_x_raw))
|
||||||
|
a = 0; %breakpointdummy
|
||||||
|
end
|
||||||
|
|
||||||
|
if(length(idx_y) > length(idx_y_raw))
|
||||||
|
a = 0; %breakpointdummy
|
||||||
|
end
|
||||||
|
|
||||||
|
if(length(idx_z) > length(idx_z_raw))
|
||||||
|
a = 0; %breakpointdummy
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%Find the most proper axis. We use 3 quantities: mean of corr.
|
%Find the most proper axis. We use 3 quantities: mean of corr.
|
||||||
%value, sum of corr val. and number of peaks. Simple normalization
|
%value, sum of corr val. and number of peaks. Simple normalization
|
||||||
@@ -170,10 +186,14 @@ for file = files'
|
|||||||
num_peaks_x = 1;%length(idx_x);
|
num_peaks_x = 1;%length(idx_x);
|
||||||
num_peaks_y = 1;%length(idx_y);
|
num_peaks_y = 1;%length(idx_y);
|
||||||
num_peaks_z = 1;%length(idx_z);
|
num_peaks_z = 1;%length(idx_z);
|
||||||
|
|
||||||
|
num_intersection_x = getNumberOfIntersections(corr_x, lag_x, 0.2);
|
||||||
|
num_intersection_y = getNumberOfIntersections(corr_y, lag_y, 0.2);
|
||||||
|
num_intersection_z = getNumberOfIntersections(corr_z, lag_z, 0.2);
|
||||||
|
|
||||||
quantity_matrix = [corr_mean_x corr_mean_y corr_mean_z;
|
quantity_matrix = [corr_mean_x corr_mean_y corr_mean_z;
|
||||||
corr_rms_x corr_rms_y corr_rms_z;
|
corr_rms_x corr_rms_y corr_rms_z;
|
||||||
num_peaks_x num_peaks_y num_peaks_z];
|
num_intersection_x num_intersection_y num_intersection_z];
|
||||||
|
|
||||||
quantity_matrix_percent(1,:) = quantity_matrix(1,:) ./ sum(quantity_matrix(1,:));
|
quantity_matrix_percent(1,:) = quantity_matrix(1,:) ./ sum(quantity_matrix(1,:));
|
||||||
quantity_matrix_percent(2,:) = quantity_matrix(2,:) ./ sum(quantity_matrix(2,:));
|
quantity_matrix_percent(2,:) = quantity_matrix(2,:) ./ sum(quantity_matrix(2,:));
|
||||||
@@ -181,11 +201,13 @@ for file = files'
|
|||||||
|
|
||||||
quantity_factors = sum(quantity_matrix_percent) / 3;
|
quantity_factors = sum(quantity_matrix_percent) / 3;
|
||||||
|
|
||||||
%quantity_x = quantity_factors(1);
|
%TODO: Wenn ein quantity wert NaN ist, sind alle NaN...
|
||||||
%quantity_y = quantity_factors(2);
|
quantity_x = quantity_factors(1);
|
||||||
%quantity_z = quantity_factors(3);
|
quantity_y = quantity_factors(2);
|
||||||
|
quantity_z = quantity_factors(3);
|
||||||
|
|
||||||
%choose axis with sum(corr) nearest to 0
|
%choose axis with sum(corr) nearest to 0
|
||||||
|
%{
|
||||||
corr_sum_xyz = [sum(corr_x) sum(corr_y) sum(corr_z)];
|
corr_sum_xyz = [sum(corr_x) sum(corr_y) sum(corr_z)];
|
||||||
[~,idx_nearest_zero] = min(abs(corr_sum_xyz));
|
[~,idx_nearest_zero] = min(abs(corr_sum_xyz));
|
||||||
|
|
||||||
@@ -198,9 +220,13 @@ for file = files'
|
|||||||
else
|
else
|
||||||
window_mean_ts_diff = Zwindow_mean_ts_diff;
|
window_mean_ts_diff = Zwindow_mean_ts_diff;
|
||||||
window_mean_bpm = Zwindow_mean_bpm;
|
window_mean_bpm = Zwindow_mean_bpm;
|
||||||
end
|
end
|
||||||
|
%}
|
||||||
|
|
||||||
|
%quantity_x = num_intersection_x;
|
||||||
|
%quantity_y = num_intersection_y;
|
||||||
|
%quantity_z = num_intersection_z;
|
||||||
|
|
||||||
%{
|
|
||||||
if(quantity_x > quantity_y && quantity_x > quantity_z)
|
if(quantity_x > quantity_y && quantity_x > quantity_z)
|
||||||
window_mean_ts_diff = Xwindow_mean_ts_diff;
|
window_mean_ts_diff = Xwindow_mean_ts_diff;
|
||||||
window_mean_bpm = Xwindow_mean_bpm;
|
window_mean_bpm = Xwindow_mean_bpm;
|
||||||
@@ -211,7 +237,7 @@ for file = files'
|
|||||||
window_mean_ts_diff = Zwindow_mean_ts_diff;
|
window_mean_ts_diff = Zwindow_mean_ts_diff;
|
||||||
window_mean_bpm = Zwindow_mean_bpm;
|
window_mean_bpm = Zwindow_mean_bpm;
|
||||||
end
|
end
|
||||||
%}
|
|
||||||
|
|
||||||
if(isnan(window_mean_ts_diff) || isnan(window_mean_bpm))
|
if(isnan(window_mean_ts_diff) || isnan(window_mean_bpm))
|
||||||
%do nothing
|
%do nothing
|
||||||
|
|||||||
Reference in New Issue
Block a user