twotcm_macro: Two Tissue Compartment Model with Alternative Macroparameter...

View source: R/kinfitr_2tcm_macro.R

twotcm_macroR Documentation

Two Tissue Compartment Model with Alternative Macroparameter Parameterisation

Description

Function to fit the Two Tissue Compartment Model with an alternative parameterisation to data. This gives some more fine-grained control over setting parameter limits and setting parameter values from previously estimated quantities.

Usage

twotcm_macro(
  t_tac,
  tac,
  input,
  weights = NULL,
  inpshift = NULL,
  vB = NULL,
  Vnd = NULL,
  BPp = NULL,
  k4 = NULL,
  frameStartEnd = NULL,
  K1.start = 0.1,
  K1.lower = 1e-04,
  K1.upper = 1,
  Vnd.start = 1,
  Vnd.lower = 1e-04,
  Vnd.upper = 10,
  BPp.start = 1,
  BPp.lower = 1e-04,
  BPp.upper = 50,
  k4.start = 0.1,
  k4.lower = 1e-04,
  k4.upper = 0.5,
  inpshift.start = 0,
  inpshift.lower = -0.5,
  inpshift.upper = 0.5,
  vB.start = 0.05,
  vB.lower = 0.01,
  vB.upper = 0.1,
  multstart_iter = 1,
  multstart_lower = NULL,
  multstart_upper = NULL,
  printvals = F
)

Arguments

t_tac

Numeric vector of times for each frame in minutes. We use the time halfway through the frame as well as a zero. If a time zero frame is not included, it will be added.

tac

Numeric vector of radioactivity concentrations in the target tissue for each frame. We include zero at time zero: if not included, it is added.

input

Data frame containing the blood, plasma, and parent fraction concentrations over time. This can be generated using the blood_interp function.

weights

Optional. Numeric vector of the weights assigned to each frame in the fitting. We include zero at time zero: if not included, it is added. If not specified, uniform weights will be used.

inpshift

Optional. The number of minutes by which to shift the timing of the input data frame forwards or backwards. If not specified, this will be fitted, however this takes longer to compute. Recommended to perform once on a large ROI for each measurement, and to specify this value for the remainder of the regions. Or perhaps even to use a simpler model, such as 1TCM.

vB

Optional. The blood volume fraction. If not specified, this will be fitted. Recommended to perform once on a large ROI for each measurement, and to specify this value for the remainder of the regions.

Vnd

Optional. This parameter can be used to fix the non-displaceable volume of distribution, i.e. the K1/k2 ratio to a specific value. If not specified, this will be fitted.

BPp

Optional. This parameter can be used to fix the BPp value, i.e. K1k3/k2k4 to a specific value. If not specified, this will be fitted.

k4

Optional. This parameter can be used to fix k4 to a specific value. If not specified, this will be fitted.

frameStartEnd

Optional: This allows one to specify the beginning and final frame to use for modelling, e.g. c(1,20). This is to assess time stability.

K1.start

Optional. Starting parameter for fitting of K1. Default is 0.1.

K1.lower

Optional. Lower bound for the fitting of K1. Default is 0.0001.

K1.upper

Optional. Upper bound for the fitting of K1. Default is 1.

Vnd.start

Optional. Starting parameter for fitting of Vnd. Default is 1.

Vnd.lower

Optional. Lower bound for the fitting of Vnd. Default is 0.0001.

Vnd.upper

Optional. Upper bound for the fitting of Vnd. Default is 10.

BPp.start

Optional. Starting parameter for fitting of BPp. Default is 1.

BPp.lower

Optional. Lower bound for the fitting of BPp. Default is 0.0001.

BPp.upper

Optional. Upper bound for the fitting of BPp. Default is 50.

k4.start

Optional. Starting parameter for fitting of k4. Default is 0.1.

k4.lower

Optional. Lower bound for the fitting of k4. Default is 0.0001.

k4.upper

Optional. Upper bound for the fitting of k4. Default is 0.5.

inpshift.start

Optional. Starting parameter for fitting of inpshift. Default is 0.

inpshift.lower

Optional. Lower bound for the fitting of inpshift. Default is -0.5.

inpshift.upper

Optional. Upper bound for the fitting of inpshift. Default is 0.5.

vB.start

Optional. Starting parameter for fitting of vB. Default is 0.05.

vB.lower

Optional. Lower bound for the fitting of vB. Default is 0.01.

vB.upper

Optional. Upper bound for the fitting of vB. Default is 0.1.

multstart_iter

Number of iterations for starting parameters. Default is 1. For more information, see nls_multstart. If specified as 1 for any parameters, the original starting value will be used, and the multstart_lower and multstart_upper values ignored.

multstart_lower

Optional. Lower bounds for starting parameters. Defaults to the lower bounds. Named list of whichever parameters' starting bounds should be altered.

multstart_upper

Optional. Upper bounds for starting parameters. Defaults to the upper bounds. Named list of whichever parameters' starting bounds should be altered.

printvals

Optional. This displays the parameter values for each iteration of the model. This is useful for debugging and changing starting values and upper and lower bounds for parameters.

Value

A list with a data frame of the fitted parameters out$par, their percentage standard errors (scaled so that 1 represents 100%) out$par.se, the model fit object out$fit, a dataframe containing the TACs both of the data and the fitted values out$tacs, the blood input data frame after time shifting input, a vector of the weights out$weights, a logical of whether the inpshift was fitted inpshift_fitted and a logical of whether the vB was fitted vB.

Author(s)

Granville J Matheson, mathesong@gmail.com

Examples

data(pbr28)

t_tac <- pbr28$tacs[[2]]$Times / 60
tac <- pbr28$tacs[[2]]$FC
weights <- pbr28$tacs[[2]]$Weights

input <- blood_interp(
  pbr28$procblood[[2]]$Time / 60, pbr28$procblood[[2]]$Cbl_dispcorr,
  pbr28$procblood[[2]]$Time / 60, pbr28$procblood[[2]]$Cpl_metabcorr,
  t_parentfrac = 1, parentfrac = 1
)

fit1 <- twotcm(t_tac, tac, input, weights)
fit2 <- twotcm(t_tac, tac, input, weights, inpshift = 0.1, vB = 0.05)

mathesong/kinfitr documentation built on Nov. 27, 2024, 1:38 a.m.