|
@@ -9,7 +9,7 @@
|
|
|
%%
|
|
%%
|
|
|
%% SIG: array of signals (measurements, capsules, samples)
|
|
%% SIG: array of signals (measurements, capsules, samples)
|
|
|
%%
|
|
%%
|
|
|
-%% Copyright 2016-2017, Fernando Lopez-Lezcano, All Rights Reserved
|
|
|
|
|
|
|
+%% Copyright 2016-2018, Fernando Lopez-Lezcano, All Rights Reserved
|
|
|
%% nando@ccrma.stanford.edu
|
|
%% nando@ccrma.stanford.edu
|
|
|
%%
|
|
%%
|
|
|
%% This program is free software: you can redistribute it and/or modify
|
|
%% This program is free software: you can redistribute it and/or modify
|
|
@@ -25,23 +25,31 @@
|
|
|
%% You should have received a copy of the GNU General Public License
|
|
%% You should have received a copy of the GNU General Public License
|
|
|
%% along with this program. If not, see <htp://www.gnu.org/licenses/>.
|
|
%% along with this program. If not, see <htp://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
-function [DELTA] = sphear_signal_arrival_times(SIG)
|
|
|
|
|
|
|
+function [MEAN DELAY DELTA] = sphear_signal_arrival_times(SIG)
|
|
|
|
|
+ MEAN = 0;
|
|
|
for m = 1:size(SIG, 1);
|
|
for m = 1:size(SIG, 1);
|
|
|
- mean = 0;
|
|
|
|
|
|
|
+ avg_delay = 0;
|
|
|
for c = 1:size(SIG, 2);
|
|
for c = 1:size(SIG, 2);
|
|
|
- [peaks, locs] = findpeaks(abs(reshape(SIG(m, c, :), 1, [])));
|
|
|
|
|
|
|
+ [peaks, locs] = findpeaks(abs(reshape(SIG(m, c, :), 1, [])), "MinPeakHeight", 0.0001, "MinPeakDistance", 16);
|
|
|
[value, index] = max(peaks);
|
|
[value, index] = max(peaks);
|
|
|
loc = locs(index);
|
|
loc = locs(index);
|
|
|
-
|
|
|
|
|
- printf("m=%d, c=%d: %d - %f\n", m, c, loc, value);
|
|
|
|
|
-
|
|
|
|
|
- mean = mean + loc;
|
|
|
|
|
|
|
+ %% printf("m=%d, c=%d: %d <%d - %f>\n", m, c, index, loc, value);
|
|
|
|
|
+ avg_delay = avg_delay + loc;
|
|
|
end
|
|
end
|
|
|
if (m == 1)
|
|
if (m == 1)
|
|
|
- first = mean/size(SIG, 2);
|
|
|
|
|
|
|
+ first = avg_delay/size(SIG, 2);
|
|
|
end
|
|
end
|
|
|
- printf("m=%d: time=%f, delta=%f\n", m, mean/size(SIG, 2), mean/size(SIG, 2) - first);
|
|
|
|
|
- DELTA(m) = mean/size(SIG, 2) - first;
|
|
|
|
|
|
|
+ DELAY(m) = avg_delay/size(SIG, 2);
|
|
|
|
|
+ DELTA(m) = DELAY(m) - first;
|
|
|
|
|
+ printf("m=%d: time=%f, delta=%f\n", m, DELAY(m), DELTA(m));
|
|
|
|
|
+ MEAN = MEAN + DELAY(m);
|
|
|
end
|
|
end
|
|
|
|
|
+ MEAN = MEAN / size(SIG, 1);
|
|
|
|
|
+ %% find proper deltas with respect to minimum delay
|
|
|
|
|
+ min_delay = min(DELAY);
|
|
|
|
|
+ max_delay = max(DELAY);
|
|
|
|
|
+ printf("average delay = %f, max delay = %f\n", MEAN, max_delay);
|
|
|
|
|
+ DELTA = (DELAY - min_delay)';
|
|
|
|
|
+ DELAY = DELAY';
|
|
|
end
|
|
end
|
|
|
|
|
|