[chronojump] removed unused findCurvesOld
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] removed unused findCurvesOld
- Date: Tue, 15 Dec 2015 18:25:23 +0000 (UTC)
commit 191c3c96000f47bbad08c859dfce5e6d3a8f11dc
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Dec 15 19:19:36 2015 +0100
removed unused findCurvesOld
encoder/graph.R | 148 -------------------------------------------------------
1 files changed, 0 insertions(+), 148 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index ed7dbb7..815b547 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -409,153 +409,6 @@ findCurvesNew <- function(displacement, eccon, isInertial, min_height, draw, tit
return(as.data.frame(cbind(startStored,endStored,startHStored)))
}
-#extrema method
-#there are problems when small changes of direction are found
-#unused now, use the new findCurves (above) that is equal to runEncoderCaptureCsharp()
-findCurvesOld <- function(displacement, eccon, min_height, draw, title) {
- position=cumsum(displacement)
- position.ext=extrema(position)
- print("at findCurves")
- print(position.ext)
-
- start=0; end=0; startH=0
- tempStart=0; tempEnd=0;
- #TODO: fer algo per si no es detecta el minindex previ al salt
- if(eccon=="c")
- {
- #1) fix big problems with set (signal). No minindex or no maxindex
- if(length(position.ext$minindex)==0) { position.ext$minindex=cbind(1,1) }
- if(length(position.ext$maxindex)==0) {
position.ext$maxindex=cbind(length(position),length(position)) }
-
- #2) fixes if 1st minindex is after 1st maxindex
- if(position.ext$maxindex[1] < position.ext$minindex[1]) { position.ext$minindex =
rbind(c(1,1),position.ext$minindex) }
-
- #3 find the curves (enter the bucle)
-
- row=1; #row means each curve
- i=1; j=1 #i minimums; j maximums
- while(max(c(i,j)) <=
min(c(length(position.ext$minindex[,1]),length(position.ext$maxindex[,1]))))
- {
- #3.1) assign tempStart and tempEnd using extrema data
-
- #tempStart at the end of minindexs
- #tempStart = position.ext$minindex[i,2]
-
- #tempStart at the mean of minindexs
- #this is better because has more data in order to reduceCurveBySpeed
- #then we get similar results than pyserial_pyper.py
- tempStart = mean(c(position.ext$minindex[i,1],position.ext$minindex[i,2]))
-
-
- #end at the mean of maximum values then reduceCurveBySpeed will end it when first
speed==0 at right of maxspeed
- tempEnd = mean(c(position.ext$maxindex[j,1],position.ext$maxindex[j,2]))
-
- #end at the first maximum value
- #tempEnd = position.ext$maxindex[j,1]
-
- #3.2) get heigh. Store curve if it's enough
-
- height=position[tempEnd]-position[tempStart]
- if(height >= min_height) {
- start[row] = tempStart
- end[row] = tempEnd
- startH[row]= position[position.ext$minindex[i,1]] #height at
start
- row=row+1;
- #if(eccon=="c") { break } #c only needs one result
- }
- i=i+1; j=j+1
- } #end of while
- } else { #ec, ecS, ce, ceS
- row=1; i=1; j=2
-
- referenceindex=0
- if(eccon=="ec" || eccon=="ecS") {
- referenceindex=position.ext$maxindex
- } else {
- referenceindex=position.ext$minindex
- }
-
- #when saved a row with ec-con, and there's only this curve, extrema doesn't find maxindex
- if(length(referenceindex) == 0) {
- start[1] = 1
-
- if(eccon=="ec" || eccon=="ecS")
- end[1] = mean(which(position == min(position)))
- else
- end[1] = mean(which(position == max(position)))
-
- startH[1]=position[1]
- start[2] =end[1]+1
- end[2] =length(position)
- startH[2]=position[start[2]]
- }
-
- #if a person starts stand up and goes down, extrema maxindex don't find the initial position
- #if this person does 3 squats, only 2 will be found
- #add first value of all the serie (1ms time) to maxindex to help to detect this first curve
- referenceindex = rbind(c(1,1),referenceindex)
-
- while(j <= length(referenceindex[,1])) {
- tempStart = mean(c(referenceindex[i,1],referenceindex[i,2]))
- tempEnd = mean(c(referenceindex[j,1],referenceindex[j,2]))
-
- if(eccon=="ec" || eccon=="ecS") {
- opposite=min(position[tempStart:tempEnd]) #find min value between the two tops
- mintop=min(c(position[tempStart],position[tempEnd])) #find wich top is lower
- height=mintop-opposite
- } else {
- opposite=max(position[tempStart:tempEnd]) #find max value between the two
bottoms
- maxbottom=max(c(position[tempStart],position[tempEnd])) #find wich bottom is
higher
- height=abs(maxbottom-opposite)
- }
- if(height >= min_height) {
- if(eccon == "ecS" || eccon == "ceS") {
- start[row] = tempStart
- end[row] = mean(which(position[tempStart:tempEnd] == opposite) +
tempStart)
- startH[row] = position[referenceindex[i,1]] #height at
start
- row=row+1
- start[row] = end[(row-1)] + 1
- end[row] = tempEnd
- startH[row] = position[start[row]] #height at start
- row=row+1
- i=j
- } else { #("ec" || "ce")
- start[row] = tempStart
- end[row] = tempEnd
- startH[row] = position[referenceindex[i,1]] #height at
start
- row=row+1
- i=j
- }
- } else {
- if(eccon=="ec" || eccon=="ecS") {
- if(position[tempEnd] >= position[tempStart]) {
- i=j
- }
- } else {
- if(position[tempEnd] <= position[tempStart]) {
- i=j
- }
- }
- }
- j=j+1
- }
- }
- if(draw) {
- lty=1
- col="black"
- plot((1:length(position))/1000 #ms -> s
- ,position/10, #mm -> cm
- type="l",
- xlim=c(1,length(position))/1000, #ms -> s
- xlab="",ylab="",axes=T,
- lty=lty,col=col)
-
- title(title, cex.main=1, font.main=1)
- mtext(paste(translateToPrint("time"),"(s)"),side=1,adj=1,line=-1)
- mtext(paste(translateToPrint("displacement"),"(cm)"),side=2,adj=1,line=-1)
- }
- return(as.data.frame(cbind(start,end,startH)))
-}
findSmoothingsECGetPower <- function(speed)
{
@@ -2593,7 +2446,6 @@ doProcess <- function(options)
#print(c("position",position))
#print(c("displacement",displacement))
- #curves=findCurvesOld(displacement, op$Eccon, op$MinHeight, curvesPlot, op$Title)
curves=findCurvesNew(displacement, op$Eccon, isInertial(op$EncoderConfigurationName),
op$MinHeight, curvesPlot, op$Title)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]