1717# ' tissue-to-plasma clearance rate. This can be obtained from MRTM1 of SRTM,
1818# ' or set at a specified value. If using SRTM to estimate this value, it is
1919# ' equal to k2 / R1.
20- # ' @param tstar Optional. The t* specification for regression. If tstar_type="frames",
20+ # ' @param tstar Optional. The t* specification for regression. If tstar_type="frames",
2121# ' this is the number of frames from the end to include (e.g., 10 means last 10 frames).
22- # ' If tstar_type="time", this is the time point (in minutes) after which all frames
22+ # ' If tstar_type="time", this is the time point (in minutes) after which all frames
2323# ' with midpoints later than this time are included. This value can be estimated using \code{mrtm2_tstar}.
2424# ' Note that this t* differs from that of the non-invasive Logan plot (which is the point at which
2525# ' pseudo-equilibrium is reached). Rather, with MRTM1 and MRTM2, all frames
@@ -75,7 +75,7 @@ mrtm2 <- function(t_tac, reftac, roitac, k2prime, tstar = NULL, weights = NULL,
7575
7676 # Convert timeStartEnd to frameStartEnd if needed
7777 if (is.null(frameStartEnd ) && ! is.null(timeStartEnd )) {
78- frameStartEnd <- c(which(t_tac > = timeStartEnd [1 ])[1 ],
78+ frameStartEnd <- c(which(t_tac > = timeStartEnd [1 ])[1 ],
7979 tail(which(t_tac < = timeStartEnd [2 ]), 1 ))
8080 }
8181
@@ -89,19 +89,6 @@ mrtm2 <- function(t_tac, reftac, roitac, k2prime, tstar = NULL, weights = NULL,
8989 tstar_type <- " frames"
9090 }
9191
92- # Validate tstar_type
93- if (! is.null(tstar )) {
94- tstar_type <- match.arg(tstar_type , c(" frames" , " time" ))
95-
96- # Convert tstar based on type
97- if (tstar_type == " time" ) {
98- frames_after_tstar <- which(t_tac > = tstar )
99- tstarIncludedFrames <- length(frames_after_tstar )
100- } else {
101- tstarIncludedFrames <- tstar
102- }
103- }
104-
10592 # Tidying
10693
10794 tidyinput <- tidyinput_ref(t_tac , reftac , roitac , weights , frameStartEnd )
@@ -116,6 +103,19 @@ mrtm2 <- function(t_tac, reftac, roitac, k2prime, tstar = NULL, weights = NULL,
116103 roitac <- tidyinput $ roitac
117104 weights <- tidyinput $ weights
118105
106+ # Validate tstar_type
107+ if (! is.null(tstar )) {
108+ tstar_type <- match.arg(tstar_type , c(" frames" , " time" ))
109+
110+ # Convert tstar based on type
111+ if (tstar_type == " time" ) {
112+ frames_after_tstar <- which(t_tac > = tstar )
113+ tstarIncludedFrames <- length(frames_after_tstar )
114+ } else {
115+ tstarIncludedFrames <- tstar
116+ }
117+ }
118+
119119 if (is.null(tstarIncludedFrames )) {
120120 tstarIncludedFrames <- length(reftac )
121121 }
@@ -236,7 +236,7 @@ plot_mrtm2fit <- function(mrtm2out, roiname = NULL, refname = NULL) {
236236 refname <- " Reference"
237237 }
238238
239- measured <- dplyr :: rename(measured ,
239+ measured <- dplyr :: rename(measured ,
240240 !! paste0(roiname , " .measured" ) : = ROI.measured ,
241241 !! refname : = Reference
242242 )
@@ -305,7 +305,7 @@ plot_mrtm2fit <- function(mrtm2out, roiname = NULL, refname = NULL) {
305305mrtm2_tstar <- function (t_tac , reftac , lowroi , medroi , highroi , k2prime , filename = NULL , frameStartEnd = NULL , timeStartEnd = NULL , gridbreaks = 2 ) {
306306 # Convert timeStartEnd to frameStartEnd if needed
307307 if (is.null(frameStartEnd ) && ! is.null(timeStartEnd )) {
308- frameStartEnd <- c(which(t_tac > = timeStartEnd [1 ])[1 ],
308+ frameStartEnd <- c(which(t_tac > = timeStartEnd [1 ])[1 ],
309309 tail(which(t_tac < = timeStartEnd [2 ]), 1 ))
310310 }
311311
0 commit comments