[chronojump] MIF. Added the possibility of getting manual trimming in R



commit 28149d4041983043721b07f1b3078f527bf95ec6
Author: Xavier Padullés <x padulles gmail com>
Date:   Tue Nov 10 11:10:05 2020 +0100

    MIF. Added the possibility of getting manual trimming in R

 r-scripts/maximumIsometricForce.R | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/r-scripts/maximumIsometricForce.R b/r-scripts/maximumIsometricForce.R
index 5bd6a45d..d7bd1bb4 100644
--- a/r-scripts/maximumIsometricForce.R
+++ b/r-scripts/maximumIsometricForce.R
@@ -53,7 +53,9 @@ assignOptions <- function(options)
                datetime                = options[21],
                 scriptsPath            = options[22],
                triggersOnList  = as.numeric(unlist(strsplit(options[23], "\\;"))),
-               triggersOffList  = as.numeric(unlist(strsplit(options[24], "\\;")))
+               triggersOffList  = as.numeric(unlist(strsplit(options[24], "\\;"))),
+               startSample = as.numeric(options[25]),
+               endSample = as.numeric(options[26])
         ))
 }
 
@@ -114,13 +116,30 @@ getDynamicsFromLoadCellFile <- function(captureOptions, inputFile, averageLength
         #Instantaneous RFD
         rfd = getRFD(originalTest)
         
-        #Finding the increase and decrease of the force to detect the start and end of the maximum voluntary 
force test
-        trimmingSamples = getTrimmingSamples(originalTest, rfd, averageLength = averageLength, percentChange 
= percentChange,
-                                            testLength = op$testLength, startDetectingMethod = "SD")
-        startSample = trimmingSamples$startSample
+        #The start and end samples are manualy selected
+        print(paste("op$startSample: ", op$startSample))
+        print(paste("op$endtSample: ", op$endSample))
+        if(is.na(op$startSample) || is.na(op$endSample))
+        {
+                op$startSample = 0
+                op$endSample = 0
+        }
+        if( (op$startSample > 0 || op$endSample > 0) && op$startSample <= length(originalTest$time) )
+        {
+                startSample = op$startSample
+                endSample = op$endSample
+        } else
+        #The start and end samples are automatically selected
+        {  
+                #Finding the increase and decrease of the force to detect the start and end of the maximum 
voluntary force test
+                trimmingSamples = getTrimmingSamples(originalTest, rfd, averageLength = averageLength, 
percentChange = percentChange,
+                                                     testLength = op$testLength, startDetectingMethod = "SD")
+                
+                startSample = trimmingSamples$startSample
+                endSample = trimmingSamples$endSample
+        }
         startTime = originalTest$time[startSample]
         
-        endSample = trimmingSamples$endSample
         endTime = originalTest$time[endSample]
         
         # Initial force. It is needed to perform an initial steady force to avoid jerks and great peaks in 
the force


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