[chronojump] Force sensor variability method can be also RMSSD



commit d0c24f899ec9b503b9b22e501525cfdb387ba07d
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Jul 8 19:44:22 2021 +0200

    Force sensor variability method can be also RMSSD

 glade/app1.glade                   | 69 ++++++++++++++++++++++++++++++--------
 glade/preferences_win.glade        | 63 ++++++++++++----------------------
 src/forceSensor.cs                 | 22 +++++++-----
 src/gui/app1/forceSensorAnalyze.cs | 13 +++++--
 src/gui/preferences.cs             | 26 +++++++++-----
 src/preferences.cs                 |  2 +-
 6 files changed, 119 insertions(+), 76 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index f4a3c83ce..2ed6efa50 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -25753,6 +25753,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -25918,10 +25921,45 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkLabel" 
id="label_force_sensor_ai_variability_cvrmssd">
+                                                            <widget class="GtkHBox" id="hbox530">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label650">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label">(</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" 
id="label_force_sensor_ai_variability_method">
+                                                            <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="xalign">0</property>
-                                                            <property name="label">(cvRMSSD)</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label651">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label">)</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">True</property>
@@ -32029,6 +32067,18 @@ Concentric</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">6</property>
                                                             <child>
+                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="pack_type">end</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_capturing">
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">4</property>
@@ -32065,18 +32115,6 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="pack_type">end</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_no_capturing">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -41174,6 +41212,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/glade/preferences_win.glade b/glade/preferences_win.glade
index d232503ad..67961a1ba 100644
--- a/glade/preferences_win.glade
+++ b/glade/preferences_win.glade
@@ -4476,55 +4476,34 @@ It starts before and arrives there with some speed.</property>
                                                         <property name="can_focus">False</property>
                                                         <property name="spacing">6</property>
                                                         <child>
-                                                          <widget class="GtkHBox" id="hbox80">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="spacing">8</property>
-                                                            <child>
-                                                            <widget class="GtkRadioButton" 
id="radio_force_sensor_variability_cvrmssd">
-                                                            <property name="label">cvRMSSD</property>
+                                                          <widget class="GtkRadioButton" 
id="radio_force_sensor_variability_rmssd">
+                                                            <property name="label">RMSSD</property>
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property 
name="receives_default">False</property>
                                                             <property name="active">True</property>
                                                             <property name="draw_indicator">True</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
+                                                            <property 
name="group">radio_force_sensor_variability_cvrmssd</property>
+                                                          </widget>
+                                                          <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
                                                             <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkHBox" id="hbox81">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="spacing">4</property>
-                                                            <child>
-                                                            <widget class="GtkLabel" id="label142">
+                                                          </packing>
+                                                        </child>
+                                                        <child>
+                                                          <widget class="GtkRadioButton" 
id="radio_force_sensor_variability_cvrmssd">
+                                                            <property name="label">cvRMSSD</property>
                                                             <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="xalign">0</property>
-                                                            <property name="label" 
translatable="yes">(Recommended)</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
+                                                            <property name="can_focus">True</property>
+                                                            <property 
name="receives_default">False</property>
+                                                            <property name="active">True</property>
+                                                            <property name="draw_indicator">True</property>
                                                           </widget>
                                                           <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">0</property>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
                                                           </packing>
                                                         </child>
                                                         <child>
@@ -4534,12 +4513,12 @@ It starts before and arrives there with some speed.</property>
                                                             <property name="can_focus">True</property>
                                                             <property 
name="receives_default">False</property>
                                                             <property name="draw_indicator">True</property>
-                                                            <property 
name="group">radio_force_sensor_variability_cvrmssd</property>
+                                                            <property 
name="group">radio_force_sensor_variability_rmssd</property>
                                                           </widget>
                                                           <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
-                                                            <property name="position">1</property>
+                                                            <property name="position">2</property>
                                                           </packing>
                                                         </child>
                                                       </widget>
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index ed6705789..e8885f3ec 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -1099,7 +1099,9 @@ public class ForceSensorCapturePoints
                return sum * UtilAll.DivideSafe(elapsedSeconds, samples);
        }
        
-       public void GetVariabilityAndAccuracy(int countA, int countB, int feedbackF, out double variability, 
out double feedbackDifference, bool cvRMSSD)
+       public void GetVariabilityAndAccuracy(int countA, int countB, int feedbackF,
+                       out double variability, out double feedbackDifference,
+                       Preferences.VariabilityMethodEnum variabilityMethod)
        {
                if(countA == countB)
                {
@@ -1113,10 +1115,10 @@ public class ForceSensorCapturePoints
                int numSamples = (countB - countA) + 1;
 
                // 2) get variability
-               if(cvRMSSD)
-                       variability = getVariabilityCVRMSSD (countA, countB, numSamples);
-               else
+               if(variabilityMethod == Preferences.VariabilityMethodEnum.CHRONOJUMP_OLD)
                        variability = getVariabilityOldMethod (countA, countB, numSamples);
+               else
+                       variability = getVariabilityRMSSDCVRMSSD (variabilityMethod, countA, countB, 
numSamples);
 
                // 3) Calculate difference.
                // Average of the differences between force and average
@@ -1129,7 +1131,7 @@ public class ForceSensorCapturePoints
 
                feedbackDifference = UtilAll.DivideSafe(sum, numSamples);
        }
-       private double getVariabilityCVRMSSD (int countA, int countB, int numSamples)
+       private double getVariabilityRMSSDCVRMSSD (Preferences.VariabilityMethodEnum method, int countA, int 
countB, int numSamples)
        {
                //see a test of this method below:
                //public static void TestVariabilityCVRMSSD()
@@ -1146,6 +1148,9 @@ public class ForceSensorCapturePoints
                double rmssd = Math.Sqrt(UtilAll.DivideSafe(sum, numSamples -1));
                LogB.Information("RMSSD: " + rmssd.ToString());
 
+               if(method == Preferences.VariabilityMethodEnum.RMSSD)
+                       return rmssd;
+
                //sumForMean += forces[countB]; //need this?
                double mean = sumForMean / numSamples;
 
@@ -1186,7 +1191,7 @@ public class ForceSensorCapturePoints
 
                double variability = 0;
                double feedbackDiff = 0;
-               fscp.GetVariabilityAndAccuracy(0, nums.Count -1, 20, out variability, out feedbackDiff, true);
+               fscp.GetVariabilityAndAccuracy(0, nums.Count -1, 20, out variability, out feedbackDiff, 
Preferences.VariabilityMethodEnum.CVRMSSD);
                LogB.Information("cvRMSSD: " + variability);
        }
 
@@ -2399,9 +2404,10 @@ public class ForceSensorAnalyzeInstant
        }
 
        public void CalculateVariabilityAndAccuracy(int countA, int countB,
-                       int feedbackF, out double variability, out double feedbackDifference, bool cvrmssd)
+                       int feedbackF, out double variability, out double feedbackDifference,
+                       Preferences.VariabilityMethodEnum variabilityMethod)
        {
-               fscAIPoints.GetVariabilityAndAccuracy(countA, countB, feedbackF, out variability, out 
feedbackDifference, cvrmssd);
+               fscAIPoints.GetVariabilityAndAccuracy(countA, countB, feedbackF, out variability, out 
feedbackDifference, variabilityMethod);
        }
        /*
         * Calculates RFD in a point using previous and next point
diff --git a/src/gui/app1/forceSensorAnalyze.cs b/src/gui/app1/forceSensorAnalyze.cs
index 26d477c6c..69fe5ef03 100644
--- a/src/gui/app1/forceSensorAnalyze.cs
+++ b/src/gui/app1/forceSensorAnalyze.cs
@@ -146,7 +146,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Label label_force_sensor_ai_impulse_values;
        [Widget] Gtk.Label label_force_sensor_ai_variability_values;
        [Widget] Gtk.Label label_force_sensor_ai_feedback_values;
-       [Widget] Gtk.Label label_force_sensor_ai_variability_cvrmssd;
+       [Widget] Gtk.Label label_force_sensor_ai_variability_method;
        [Widget] Gtk.Label label_force_sensor_ai_variability_units;
        [Widget] Gtk.Label label_force_sensor_ai_max_avg_in_window;
 
@@ -2204,7 +2204,14 @@ public partial class ChronoJumpWindow
                }
 
                table_force_sensor_ai_impulse_variability_and_feedback.Visible = (countA != countB);
-               label_force_sensor_ai_variability_cvrmssd.Visible = (preferences.forceSensorVariabilityMethod 
== Preferences.VariabilityMethodEnum.CVRMSSD);
+
+               if(preferences.forceSensorVariabilityMethod == Preferences.VariabilityMethodEnum.RMSSD)
+                       label_force_sensor_ai_variability_method.Text = "RMSSD";
+               else if(preferences.forceSensorVariabilityMethod == Preferences.VariabilityMethodEnum.CVRMSSD)
+                       label_force_sensor_ai_variability_method.Text = "cvRMSSD";
+               else
+                       label_force_sensor_ai_variability_method.Text = "Old method";
+
                if(preferences.forceSensorVariabilityMethod == Preferences.VariabilityMethodEnum.CVRMSSD)
                        label_force_sensor_ai_variability_units.Text = "%";
                else
@@ -2222,7 +2229,7 @@ public partial class ChronoJumpWindow
                        int feedbackF = preferences.forceSensorCaptureFeedbackAt;
 
                        fsAI.CalculateVariabilityAndAccuracy(countA, countB, feedbackF, out variability, out 
feedbackDiff,
-                                       (preferences.forceSensorVariabilityMethod == 
Preferences.VariabilityMethodEnum.CVRMSSD));
+                                       preferences.forceSensorVariabilityMethod);
 
                        label_force_sensor_ai_variability_values.Text = Math.Round(variability, 3).ToString();
 
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index b61d9c473..43e2b02d9 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -185,8 +185,9 @@ public class PreferencesWindow
        [Widget] Gtk.SpinButton spin_force_sensor_not_elastic_ecc_min_force;
        [Widget] Gtk.SpinButton spin_force_sensor_not_elastic_con_min_force;
        [Widget] Gtk.SpinButton spin_force_sensor_graphs_line_width;
-       [Widget] Gtk.RadioButton radio_force_sensor_variability_old;
+       [Widget] Gtk.RadioButton radio_force_sensor_variability_rmssd;
        [Widget] Gtk.RadioButton radio_force_sensor_variability_cvrmssd;
+       [Widget] Gtk.RadioButton radio_force_sensor_variability_old;
        [Widget] Gtk.SpinButton spin_force_sensor_analyze_ab_slider_increment;
        [Widget] Gtk.SpinButton spin_force_sensor_analyze_max_avg_force_in_window;
 
@@ -735,10 +736,12 @@ public class PreferencesWindow
 
                PreferencesWindowBox.spin_force_sensor_graphs_line_width.Value = 
preferences.forceSensorGraphsLineWidth;
 
-               if(preferences.forceSensorVariabilityMethod == 
Preferences.VariabilityMethodEnum.CHRONOJUMP_OLD)
-                       PreferencesWindowBox.radio_force_sensor_variability_old.Active = true;
-               else
+               if(preferences.forceSensorVariabilityMethod == Preferences.VariabilityMethodEnum.RMSSD)
+                       PreferencesWindowBox.radio_force_sensor_variability_rmssd.Active = true;
+               else if(preferences.forceSensorVariabilityMethod == Preferences.VariabilityMethodEnum.CVRMSSD)
                        PreferencesWindowBox.radio_force_sensor_variability_cvrmssd.Active = true;
+               else
+                       PreferencesWindowBox.radio_force_sensor_variability_old.Active = true;
 
                PreferencesWindowBox.spin_force_sensor_analyze_ab_slider_increment.Value = 
preferences.forceSensorAnalyzeABSliderIncrement;
                PreferencesWindowBox.spin_force_sensor_analyze_max_avg_force_in_window.Value = 
preferences.forceSensorAnalyzeMaxAVGInWindow;
@@ -2180,14 +2183,21 @@ public class PreferencesWindow
                                preferences.forceSensorGraphsLineWidth,
                                Convert.ToInt32(spin_force_sensor_graphs_line_width.Value));
 
-               if(preferences.forceSensorVariabilityMethod == 
Preferences.VariabilityMethodEnum.CHRONOJUMP_OLD &&
-                               PreferencesWindowBox.radio_force_sensor_variability_cvrmssd.Active)
+               //variability
+               if(PreferencesWindowBox.radio_force_sensor_variability_rmssd.Active &&
+                               preferences.forceSensorVariabilityMethod != 
Preferences.VariabilityMethodEnum.RMSSD)
+               {
+                       SqlitePreferences.Update(SqlitePreferences.ForceSensorVariabilityMethod, 
Preferences.VariabilityMethodEnum.RMSSD.ToString(), true);
+                       preferences.forceSensorVariabilityMethod = Preferences.VariabilityMethodEnum.RMSSD;
+               }
+               else if(PreferencesWindowBox.radio_force_sensor_variability_cvrmssd.Active &&
+                               preferences.forceSensorVariabilityMethod != 
Preferences.VariabilityMethodEnum.CVRMSSD)
                {
                        SqlitePreferences.Update(SqlitePreferences.ForceSensorVariabilityMethod, 
Preferences.VariabilityMethodEnum.CVRMSSD.ToString(), true);
                        preferences.forceSensorVariabilityMethod = Preferences.VariabilityMethodEnum.CVRMSSD;
                }
-               else if(preferences.forceSensorVariabilityMethod == Preferences.VariabilityMethodEnum.CVRMSSD 
&&
-                               PreferencesWindowBox.radio_force_sensor_variability_old.Active)
+               else if(PreferencesWindowBox.radio_force_sensor_variability_old.Active &&
+                               preferences.forceSensorVariabilityMethod != 
Preferences.VariabilityMethodEnum.CHRONOJUMP_OLD)
                {
                        SqlitePreferences.Update(SqlitePreferences.ForceSensorVariabilityMethod, 
Preferences.VariabilityMethodEnum.CHRONOJUMP_OLD.ToString(), true);
                        preferences.forceSensorVariabilityMethod = 
Preferences.VariabilityMethodEnum.CHRONOJUMP_OLD;
diff --git a/src/preferences.cs b/src/preferences.cs
index 54176a284..b48e984e0 100644
--- a/src/preferences.cs
+++ b/src/preferences.cs
@@ -122,7 +122,7 @@ public class Preferences
        public double forceSensorElasticConMinDispl;
        public int forceSensorNotElasticEccMinForce;
        public int forceSensorNotElasticConMinForce;
-       public enum VariabilityMethodEnum { CHRONOJUMP_OLD, CVRMSSD };
+       public enum VariabilityMethodEnum { CHRONOJUMP_OLD, RMSSD, CVRMSSD };
        public VariabilityMethodEnum forceSensorVariabilityMethod;
        public double forceSensorAnalyzeABSliderIncrement;
        public double forceSensorAnalyzeMaxAVGInWindow; //seconds


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]