Skip to content

Commit 03d8593

Browse files
committed
Added a robustness control for Feng and FengConv blood models when there is only a zero and a peak
1 parent c6d97ad commit 03d8593

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

R/kinfitr_bloodmodels.R

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,20 +1322,22 @@ blmod_feng_startpars <- function(time, activity,
13221322
rise_coef <- coef(rise_lm)
13231323
startpars$t0 <- as.numeric(-1*(rise_coef[1] / rise_coef[2]))
13241324

1325-
if(startpars$t0 < 0) { # This can happen if the peak is very dispersed
1325+
if( is.na(startpars$t0) ) { startpars$t0 <- min(time) }
1326+
1327+
if(startpars$t0 < min(time)) { # This can happen if the peak is very dispersed
13261328
bloodrise <- bloodrise[blood$activity >= 0.1*startpars$peakval, ]
13271329
rise_lm <- lm(activity ~ time, data=bloodrise)
13281330
rise_coef <- coef(rise_lm)
13291331
startpars$t0 <- as.numeric(-1*(rise_coef[1]/rise_coef[2]))
13301332
}
13311333

1332-
if(startpars$t0 < 0) { # If still less than 0
1333-
startpars$t0 <- 0
1334+
if(startpars$t0 < min(time)) { # If still less than 0
1335+
startpars$t0 <- min(time)
13341336
}
13351337
}
13361338

1337-
if(startpars$t0 < 0) { # If still less than 0
1338-
startpars$t0 <- 0
1339+
if(startpars$t0 < min(time)) { # If still less than 0
1340+
startpars$t0 <- min(time)
13391341
}
13401342

13411343

@@ -1456,8 +1458,8 @@ blmod_feng_startpars <- function(time, activity,
14561458
startpars$A <- startpars$B
14571459
startpars$alpha <- startpars$beta
14581460

1459-
warning("not enough points left to define A and alpha: consider
1460-
revising the expdecay_props")
1461+
warning("not enough points left to define A and alpha starting parameters:
1462+
consider revising the expdecay_props")
14611463
}
14621464

14631465
# return the list in correct order

0 commit comments

Comments
 (0)