diff options
author | Chris Schlaeger <chris@linux.com> | 2015-11-23 20:41:00 +0100 |
---|---|---|
committer | Chris Schlaeger <chris@linux.com> | 2015-11-23 20:41:00 +0100 |
commit | 54719ca934e1b01dca10344bd3b392c686528a89 (patch) | |
tree | 64b36dace152521910095871409fdb6e2ec9611c | |
parent | a74286529da3049f929ca5a9b4fbc174a0d4cd06 (diff) | |
download | postrunner-54719ca934e1b01dca10344bd3b392c686528a89.zip |
Show R-R intervals in ms instead of s.
-rw-r--r-- | README.md | 7 | ||||
-rw-r--r-- | lib/postrunner/ChartView.rb | 7 | ||||
-rw-r--r-- | lib/postrunner/HRV_Analyzer.rb | 17 |
3 files changed, 18 insertions, 13 deletions
@@ -3,8 +3,11 @@ PostRunner is an application to manage FIT files such as those produced by Garmin products like the Forerunner 620 (FR620) and Fenix 3. It allows you to import the files from the device and inspect them. -It can also update satellite orbit prediction (EPO) data on the device -to speed-up fix times. It is an offline alternative to Garmin Connect. +In addition to the common features like plotting pace, heart rates, +elevation and other captured values it also provides a heart rate +variability (HRV) analysis. It can also update satellite orbit prediction +(EPO) data on the device to speed-up fix times. It is an offline +alternative to Garmin Connect. ## Installation diff --git a/lib/postrunner/ChartView.rb b/lib/postrunner/ChartView.rb index b146ea4..8009954 100644 --- a/lib/postrunner/ChartView.rb +++ b/lib/postrunner/ChartView.rb @@ -46,7 +46,7 @@ module PostRunner chart_div(doc, 'altitude', "Elevation (#{select_unit('m')})") chart_div(doc, 'heart_rate', 'Heart Rate (bpm)') if @hrv_analyzer.has_hrv_data? - chart_div(doc, 'hrv', 'Heart Rate Variability (s)') + chart_div(doc, 'hrv', 'R-R Intervals/Heart Rate Variability (ms)') #chart_div(doc, 'hrv_score', 'HRV Score (30s Window)') end chart_div(doc, 'run_cadence', 'Run Cadence (spm)') @@ -187,9 +187,10 @@ EOT prev_intvl = @hrv_analyzer.rr_intervals[idx - 1] next unless curr_intvl && prev_intvl - dt = curr_intvl - prev_intvl + # Convert the R-R interval duration to ms. + dt = (curr_intvl - prev_intvl) * 1000.0 min_value = dt if min_value.nil? || min_value > dt - data_set << [ @hrv_analyzer.timestamps[idx] * 1000, dt] + data_set << [ @hrv_analyzer.timestamps[idx] * 1000, dt ] end else @activity.fit_activity.records.each do |r| diff --git a/lib/postrunner/HRV_Analyzer.rb b/lib/postrunner/HRV_Analyzer.rb index 8375a9b..664f7c9 100644 --- a/lib/postrunner/HRV_Analyzer.rb +++ b/lib/postrunner/HRV_Analyzer.rb @@ -130,6 +130,14 @@ module PostRunner private def collect_rr_intervals + # The rr_intervals Array stores the beat-to-beat time intervals (R-R). + # If one or move beats have been skipped during measurement, a nil value + # is inserted. + @rr_intervals = [] + # The timestamps Array stores the relative (to start of sequence) time + # for each interval in the rr_intervals Array. + @timestamps = [] + # Each Fit4Ruby::HRV object has an Array called 'time' that contains up # to 5 R-R interval durations. If less than 5 are present, they are # filled with nil. @@ -137,19 +145,12 @@ module PostRunner @fit_file.hrv.each do |hrv| raw_rr_intervals += hrv.time.compact end + return if raw_rr_intervals.empty? window = 20 intro_mean = raw_rr_intervals[0..4 * window].reduce(:+) / (4 * window) predictor = LinearPredictor.new(window, intro_mean) - # The rr_intervals Array stores the beat-to-beat time intervals (R-R). - # If one or move beats have been skipped during measurement, a nil value - # is inserted. - @rr_intervals = [] - # The timestamps Array stores the relative (to start of sequence) time - # for each interval in the rr_intervals Array. - @timestamps = [] - # The timer accumulates the interval durations. timer = 0.0 raw_rr_intervals.each do |dt| |