Unverified Commit 0be63ba0 authored by salonirose95's avatar salonirose95 Committed by GitHub
Browse files

Update single_fly.Rmd

parent 3f1a8232
......@@ -126,11 +126,20 @@ source("DTS_plotfunctions.R")
## Optomotor strength
if(!exists("OIprofile")){OIprofile <- data.frame(matrix(ncol = NofPeriods))}
if(sequence$type[i]=="optomotorR"||sequence$type[i]=="optomotorL")
{
avg = mean(abs(as.numeric(as.character( temp$torque ))))
maxi = max(as.numeric(as.character(rawdata$torque)))-min(as.numeric(as.character(rawdata$torque)))
{ x1 <- rep(seq(0, (length(temp$torque)-1)*10, by=10))
y1 <- temp$torque
mod <- nlsLM(y1 ~ k*p*exp(r*x1)/(k + p*(exp(r * x1)-1)),start=list(k=10,p=0,r=0),na.action = na.omit)
k1 <- coef(mod)[1]
p1 <- coef(mod)[2]
r1 <- coef(mod)[3]
f <- function(x){( k1*p1*exp(r1*x)/(k1 + p1*(exp(r1 * x)-1)))}
opt1 <-optimize(f, interval=c(0, 10000), maximum=TRUE)
opt2 <-optimize(f, interval=c(0, 10000))
avg = mean(abs(as.numeric(as.character( temp[,3] ))))
range1 <- c(abs(as.numeric(opt1[2])),abs(as.numeric(opt2[2])))
maxi = max(range1)
sequence$opto[i] = avg/maxi
sequence$opto[i] = maxi
}
} #for Number of Periods
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment