dcmri.res_ncomp#

dcmri.res_ncomp(T, E, t)[source]#

Residue function of an n-compartment system.

See section N-compartment system for more detail.

Parameters:
  • T (array_like) – n-element array with mean transit times of each compartment.

  • E (array_like) – dimensionless and square n x n matrix. An off-diagonal element E[j,i] is the extraction fraction from compartment i to compartment j. A diagonal element E[i,i] is the extraction fraction from compartment i to the outside.

  • t (array_like) – the time points of the indicator flux J, in the same units as T. If t is not provided, the time points are assumed to be uniformly spaced with spacing dt. Defaults to None.

Returns:

Residue in each compartment, and at each time point, as a 3D array with dimensions (n,n,k), where n is the number of compartments and k is the number of time points in t. Encoding of the first two indices is as follows: R[j,i,:] is the residue in compartment i from an impulse injected into compartment J.

Return type:

numpy.ndarray

Example

>>> import numpy as np
>>> import dcmri as dc

Consider a measurement with 10 time points from 0 to 20s, and a 2-compartment system defined by T and E as follows:

>>> t = np.linspace(0, 20, 10)
>>> T = [20,2]
>>> E = [[0.7, 0.9], [0.3, 0.1]]

Calculate the residue in both compartments:

>>> R = dc.res_ncomp(T, E, t)

Given an impulse in compartment 1 at time t=0, the residue in compartment 1 is strictly decreasing:

>>> R[1,1,:]
array([1.        , 0.337098  , 0.12441734, 0.05534255, 0.03213718,
0.02364203, 0.01991879, 0.01779349, 0.01624864, 0.01495455])

Given an impulse in compartment 1 at time t=0, the residue in compartment 0 is zero initially and peaks at a later time:

>>> R[1,0,:]
array([0.        , 0.01895809, 0.02356375, 0.02370372, 0.02252098,
0.02100968, 0.01947964, 0.01802307, 0.01666336, 0.0154024 ])