Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedNasser8 committed Nov 15, 2024
1 parent 50cd665 commit 3535067
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
8 changes: 4 additions & 4 deletions docs/examples/tissue/plot_two_cxm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
ca = osipi.aif_parker(t)

# %%
#Plot the tissue concentrations for an extracellular volume fraction
#of 0.2, plasma volume fraction of 0.1, permeability serface area of 5 ml/min
#and flow rate of 10 ml/min
# Plot the tissue concentrations for an extracellular volume fraction
# of 0.2, plasma volume fraction of 0.1, permeability serface area of 5 ml/min
# and flow rate of 10 ml/min
PS = 15 # Permeability surface area product in ml/min
Fp = [10, 25] # Flow rate in ml/min
ve = 0.1 # Extracellular volume fraction
vp = [0.1,0.02] # Plasma volume fraction
vp = [0.1, 0.02] # Plasma volume fraction

ct = osipi.two_compartment_exchange_model(t, ca, Fp=Fp[0], PS=PS, ve=ve, vp=vp[0])
plt.plot(t, ct, "b-", label=f" Fp = {Fp[0]},PS = {PS}, ve = {ve}, vp = {vp[0]}")
Expand Down
17 changes: 13 additions & 4 deletions src/osipi/_tissue.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def two_compartment_exchange_model(
>>> ve = 0.2 # Extracellular volume fraction
>>> vp = 0.1 # Plasma volume fraction
>>> ct = osipi.two_compartment_exchange_model(t, ca, Fp, PS, ve, vp)
>>> plt.plot(t, ca, 'r', t, ct, 'g')
>>> plt.plot(t, ca, "r", t, ct, "g")
"""
if not np.allclose(np.diff(t), np.diff(t)[0]):
Expand Down Expand Up @@ -429,11 +429,20 @@ def two_compartment_exchange_model(
vp
* sig_p
* sig_n
* ((1 - te * sig_n) * np.exp(-tau_upsample * sig_n) + (te * sig_p - 1.0) * np.exp(-tau_upsample * sig_p))
* (
(1 - te * sig_n) * np.exp(-tau_upsample * sig_n)
+ (te * sig_p - 1.0) * np.exp(-tau_upsample * sig_p)
)
/ (sig_p - sig_n)
)

irf_ce = ve * sig_p * sig_n * (np.exp(-tau_upsample * sig_n) - np.exp(-tau_upsample * sig_p)) / (sig_p - sig_n)
irf_ce = (
ve
* sig_p
* sig_n
* (np.exp(-tau_upsample * sig_n) - np.exp(-tau_upsample * sig_p))
/ (sig_p - sig_n)
)

irf_cp[[0]] /= 2
irf_ce[[0]] /= 2
Expand All @@ -448,7 +457,7 @@ def two_compartment_exchange_model(
t_upsample = np.linspace(t[0], t[-1], n_upsample)

Cp = np.interp(t, t_upsample, Cp)
Ce = np.interp(t,t_upsample, Ce)
Ce = np.interp(t, t_upsample, Ce)

# get tissue concentration
Ct = Cp + Ce
Expand Down

0 comments on commit 3535067

Please sign in to comment.