summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2016-01-20 17:40:52 +0100
committerChris Schlaeger <chris@linux.com>2016-01-20 17:40:52 +0100
commitc452b3d724bb62194326e92d8819902a59d758e0 (patch)
tree33695eaa08efc56e107a36c6acf25332e90c1918 /lib
parent034fd536886e2cac72e07ce6039ab98ebd4c859d (diff)
downloadpostrunner-c452b3d724bb62194326e92d8819902a59d758e0.zip
FIX: Ensure that HRV data is synchronized with other FIT data.
Diffstat (limited to 'lib')
-rw-r--r--lib/postrunner/HRV_Analyzer.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/postrunner/HRV_Analyzer.rb b/lib/postrunner/HRV_Analyzer.rb
index 664f7c9..116561b 100644
--- a/lib/postrunner/HRV_Analyzer.rb
+++ b/lib/postrunner/HRV_Analyzer.rb
@@ -170,6 +170,16 @@ module PostRunner
predictor.insert(dt)
end
end
+
+ # The accumulated R-R intervals tend to be slightly larger than the
+ # total timer time measured by the device. It's unclear why this is the
+ # case, but I assume it's an accumulated measuring error. We calculate a
+ # correction factor and time-warp all timestamps so the total time
+ # aligns with the other data of the FIT file. We also correct the R-R
+ # intervals times accordingly.
+ time_warp_factor = @fit_file.total_timer_time / @timestamps.last
+ @timestamps.map! { |t| t * time_warp_factor }
+ @rr_intervals.map! { |t| t ? t * time_warp_factor : nil }
end
end