Skip to content

Commit

Permalink
Create forward tofts function
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedNasser8 committed Jul 19, 2024
1 parent d653e40 commit eb9b39f
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/osipi/DRO/Model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from scipy.integrate import cumtrapz
from scipy.integrate import cumtrapz, trapz


def tofts(cp, c_tiss, dt, datashape):
Expand Down Expand Up @@ -48,3 +48,30 @@ def exntended_tofts(cp, c_tiss, dt, datashape):
vp[j, i, k] = vp_voxel

return ktrans, kep, vp


def forward_tofts(ktrans, kep, cp, vp, dt):
"""
Forward Tofts model for DCE-MRI DRO
Parameters:
ktrans (numpy.ndarray): The transfer constant Ktrans.
kep (numpy.ndarray): The rate constant kep.
cp (numpy.ndarray): The plasma concentration C_p(t).
vp (numpy.ndarray): The plasma volume fraction v_p.
dt (float): The time step between measurements.
Returns:
numpy.ndarray: The tissue concentration C_tiss(t).
"""
time_points = cp.shape[-1]
c_tiss = np.zeros(ktrans.shape)
for t in range(time_points):
if t == 0:
c_tiss[..., t] = vp * cp[..., t]
else:
exp = np.exp(-kep * np.arange(t + 1)[::-1] * dt)
integral = trapz(cp[..., : t + 1] * exp, dx=dt, axis=-1)
c_tiss[..., t] = vp * cp[..., t] + ktrans * integral

return c_tiss

0 comments on commit eb9b39f

Please sign in to comment.