expconv
expconv
¶
Exponential convolution functions for pharmacokinetic modeling.
This module implements efficient recursive formulas for convolving signals with exponential and multi-exponential functions. These are the core building blocks for compartmental pharmacokinetic models.
GPU/CPU agnostic using the xp array module pattern. NO scipy dependency - see XP Compatibility Requirements in plan.md.
References
Flouri D, Lesnic D, Sourbron SP (2016). Fitting the two-compartment model in DCE-MRI by linear inversion. Magn Reson Med. 76(3):998-1006. doi:10.1002/mrm.25991
Attribution
expconv adapts the recursive exponential-convolution algorithm from
dcmri v0.6.20 (https://github.com/dcmri/dcmri, module dcmri/utils.py),
licensed under the Apache License, Version 2.0. Modified: (f, T, t)
signature, batched/GPU array-module path, and non-normalized output. See the
project NOTICE file.
expconv
¶
Convolve a signal with exponential decay function(s).
Computes the convolution: (f * exp(-t/T))(t) = integral_0^t f(u) * exp(-(t-u)/T) du
using an efficient recursive formula that avoids explicit numerical integration. This is the fundamental operation for compartmental pharmacokinetic models.
Handles both single-voxel (scalar T) and batch (array T) cases. When T is an array, every voxel is processed in a single pass with the loop running over time points — efficient on CPU and GPU.
| PARAMETER | DESCRIPTION |
|---|---|
f
|
Input signal (e.g., arterial input function).
Shape
TYPE:
|
T
|
Time constant(s) of the exponential decay in seconds.
Scalar for a single convolution, or array of shape
TYPE:
|
t
|
Time points in seconds. Shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ndarray
|
Convolution result. Shape |
Notes
The recursive formula from Flouri et al. (2016) is used:
E[i] = E[i-1] * exp(-dt/T) + integral_{t[i-1]}^{t[i]} f(u) * exp(-(t[i]-u)/T) du
where the integral within each interval is evaluated analytically assuming piecewise-linear interpolation of f.
This is O(n) in computation time, compared to O(n^2) for naive numerical integration.
Examples:
>>> import numpy as np
>>> from osipy.common.convolution import expconv
>>> t = np.linspace(0, 10, 101)
>>> aif = np.exp(-t / 2) # Input function
>>> T = 5.0 # 5 second time constant
>>> result = expconv(aif, T, t)
References
.. [1] Flouri D, Lesnic D, Sourbron SP (2016). Fitting the two-compartment model in DCE-MRI by linear inversion. Magn Reson Med. 76(3):998-1006. doi:10.1002/mrm.25991