|
10 | 10 | #' @param injRad The injected radioactivity. If not included, this will be set to 1 in case one is using SUV ratios. |
11 | 11 | #' @param bodymass The body mass of the participant. If not included, this will be set to 1 in case one is using SUV ratios. |
12 | 12 | #' @param frameStartEnd Optional: This allows one to specify the beginning and final frame to use for modelling, e.g. c(1,20). |
13 | | -#' This is to assess time stability. |
| 13 | +#' This can be used to assess time stability for example. |
| 14 | +#' @param timeStartEnd Optional. This allows one to specify the beginning and end time point instead of defining the frame numbers using frameStartEnd. This function will restrict the model to all time frames whose t_tac is between the values, i.e. c(0,5) will select all frames with midtimes during the first 5 minutes. Note that this requires t_tac. |
14 | 15 | #' |
15 | 16 | #' @return A list with a data frame of the calculated parameters \code{out$par} and a dataframe containing the TACs both of the |
16 | 17 | #' original data and the transformed values \code{out$tacs} |
|
25 | 26 | #' |
26 | 27 | #' fit1 <- SUV(tac, t_tac, injRad = 150, bodymass = 85) |
27 | 28 | #' fit2 <- SUV(tac, dur_tac = dur_tac, injRad = 150, bodymass = 85) |
| 29 | +#' fit3 <- SUV(tac, t_tac = t_tac, dur_tac = dur_tac, injRad = 150, bodymass = 85) |
| 30 | +#' fit4 <- SUV(tac, t_tac = t_tac, dur_tac = dur_tac, injRad = 150, bodymass = 85, frameStartEnd = c(1,5)) |
28 | 31 | #' @author Granville J Matheson, \email{mathesong@@gmail.com} |
29 | 32 | #' |
30 | 33 | #' @export |
31 | 34 |
|
32 | | -SUV <- function(tac, t_tac = NULL, dur_tac = NULL, injRad = 1, bodymass = 1, frameStartEnd = NULL) { |
| 35 | +SUV <- function(tac, t_tac = NULL, dur_tac = NULL, injRad = 1, bodymass = 1, |
| 36 | + frameStartEnd = NULL, timeStartEnd = NULL) { |
33 | 37 |
|
34 | 38 | # Tidying |
35 | 39 |
|
36 | | - if (is.null(dur_tac)) { |
37 | | - tidyinput <- tidyinput_art(t_tac, tac, tac, |
38 | | - frameStartEnd) # Don't need weights, thus just set to same as tac |
39 | | - t_tac <- tidyinput$t_tac |
40 | | - } else { |
| 40 | + if( is.null(frameStartEnd) && !is.null(timeStartEnd) && is.null(t_tac) ) { |
| 41 | + stop("timeStartEnd can only be used if t_tac is provided.") |
| 42 | + } |
| 43 | + |
| 44 | + # Convert timeStartEnd to frameStartEnd if needed |
| 45 | + if (is.null(frameStartEnd) && !is.null(timeStartEnd)) { |
| 46 | + frameStartEnd <- c(which(t_tac >= timeStartEnd[1])[1], |
| 47 | + tail(which(t_tac <= timeStartEnd[2]), 1)) |
| 48 | + } |
| 49 | + |
| 50 | + if (!is.null(dur_tac) & is.null(t_tac)) { |
| 51 | + |
41 | 52 | tidyinput <- tidyinput_art(dur_tac, tac, tac, |
42 | 53 | frameStartEnd) # Don't need weights, thus just set to same as tac |
43 | 54 | dur_tac <- tidyinput$t_tac |
| 55 | + |
| 56 | + tac <- tidyinput$tac |
44 | 57 | } |
45 | 58 |
|
| 59 | + if (is.null(dur_tac) & !is.null(t_tac)) { |
| 60 | + tidyinput <- tidyinput_art(t_tac, tac, tac, |
| 61 | + frameStartEnd) # Don't need weights, thus just set to same as tac |
| 62 | + t_tac <- tidyinput$t_tac |
| 63 | + |
| 64 | + tac <- tidyinput$tac |
| 65 | + } |
| 66 | + |
| 67 | + if (is.null(dur_tac) & is.null(t_tac)) { |
| 68 | + stop("Either t_tac or dur_tac must be provided") |
| 69 | + } |
46 | 70 |
|
47 | | - tac <- tidyinput$tac |
| 71 | + if (!is.null(dur_tac) & !is.null(t_tac)) { |
| 72 | + tidyinput1 <- tidyinput_art(dur_tac, tac, tac, |
| 73 | + frameStartEnd) # Don't need weights, thus just set to same as tac |
| 74 | + dur_tac <- tidyinput1$t_tac |
| 75 | + |
| 76 | + tidyinput2 <- tidyinput_art(t_tac, tac, tac, |
| 77 | + frameStartEnd) # Don't need weights, thus just set to same as tac |
| 78 | + t_tac <- tidyinput2$t_tac |
| 79 | + |
| 80 | + tac <- tidyinput1$tac |
| 81 | + } |
48 | 82 |
|
49 | 83 |
|
50 | 84 | # 'Model' |
|
0 commit comments