Explorar el Código

calibration: better determination of average signal arrival time for compensating array wobble during calibration measurements

Fernando Pablo Lopez-Lezcano hace 8 años
padre
commit
a2b737fbb5
Se han modificado 1 ficheros con 19 adiciones y 11 borrados
  1. 19 11
      calibration/src/sphear_signal_arrival_times.m

+ 19 - 11
calibration/src/sphear_signal_arrival_times.m

@@ -9,7 +9,7 @@
 %%
 %% 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
 %%
 %%  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
 %%  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);
-    mean = 0;
+    avg_delay = 0;
     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);
       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
     if (m == 1)
-      first = mean/size(SIG, 2);
+      first = avg_delay/size(SIG, 2);
     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
+  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