[chronojump/optimizeRFD: 96/96] Shifted raw signal to match the model start




commit 4d67a7892c0242cf57e2d8c91504379876754049
Author: Xavier Padullés <x padulles gmail com>
Date:   Wed Dec 30 13:38:54 2020 +0100

    Shifted raw signal to match the model start

 r-scripts/maximumIsometricForce.R | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/r-scripts/maximumIsometricForce.R b/r-scripts/maximumIsometricForce.R
index fc6489e4..a8ead793 100644
--- a/r-scripts/maximumIsometricForce.R
+++ b/r-scripts/maximumIsometricForce.R
@@ -984,12 +984,21 @@ getBestFit <- function(originalTest
     
     currentMeanError = mean(abs(forceModel$error[!is.nan(forceModel$error)]))
     
+    #Correcting the startSample to the closest to the beginning of the model
+    startSampleCorrected = which.min(abs(originalTest$time - forceModel$T0))
+    endSample = endSample - (startSample - startSampleCorrected)
+    startSample = startSampleCorrected
+    
+    # startTime = originalTest$time[startSample]
+    # endTime = originalTest$time[endSample]
+    
     print(paste("currentMeanError: ", currentMeanError, "lastMeanError: ", lastMeanError))
     print(paste("samples: ", startSample, ":", endSample, sep = ""))
+    print(paste("time without T0:", startTime, "T0:", forceModel$T0, "StartSampleCorrecte:", 
startSampleCorrected))
     print(paste("time: ", startTime + forceModel$T0, ":", endTime + forceModel$T0))
     
     return(list(model = forceModel
-                , startSample = startSample, startTime = startTime + forceModel$T0
+                , startSample = startSampleCorrected, startTime = startTime + forceModel$T0
                 , endSample = endSample, endTime = endTime + forceModel$T0
     ))
 }


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