Skip to content

Commit

Permalink
Merge pull request #34 from OSIPI/dev
Browse files Browse the repository at this point in the history
Functionality for one pipeline
  • Loading branch information
ltorres6 authored Jul 15, 2024
2 parents 71a4206 + d1fdeb0 commit d766d98
Show file tree
Hide file tree
Showing 28 changed files with 739 additions and 198 deletions.
101 changes: 0 additions & 101 deletions docs/build/html/_sphinx_design_static/design-tabs.js

This file was deleted.

This file was deleted.

29 changes: 29 additions & 0 deletions docs/examples/signal/plot_signal_SPGR.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
==============
Linear model for relationship between R1 and magnitude signal
==============
Demonstrating the linear model for relationship between R1 and magnitude signal, s = k.R1
"""

# %%
# Import necessary packages
import matplotlib.pyplot as plt
import numpy as np
import osipi

# %%
# Convert a series of R1 values to the corresponding signal intensities using the SPGR model.

R1 = np.linspace(0.1, 10, 50) # R1 in units of /s.
S0 = np.float64(100) # fully T1-relaxed signal in a.u.
TR = np.float64(5e-3) # repetition time in units of s.
a = np.float64(15) # prescribed flip angle in units of deg.
S = osipi.signal_SPGR(R1, S0, TR, a) # signal in a.u.
print(f"Signal: {S}")

# Plot S vs. R1
plt.plot(R1, S, "r-")
plt.xlabel("R1 (/s)")
plt.ylabel("S (a.u.)")
plt.show()
27 changes: 27 additions & 0 deletions docs/examples/signal/plot_signal_linear.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
==============
Linear model for relationship between R_1 and magnitude signal S
==============
Demonstrating the linear model for relationship between R_1 and magnitude signal, S = k.R_1
"""

# %%
# Import necessary packages
import matplotlib.pyplot as plt
import numpy as np
import osipi

# %%
# Convert a series of R1 values to the corresponding signal intensities.

R1 = np.array([0.0, 1.5, 3.0, 4.0, 10.0]) # R_1 in units of /s
k = np.float64(150.0) # constant of proportionality in units of a.u. s
S = osipi.signal_linear(R1, k) # signal in a.u.
print(f"Signal: {S}")

# Plot S vs. R1
plt.plot(R1, S, "ro-")
plt.xlabel("R1 (/s)")
plt.ylabel("S (a.u.)")
plt.show()
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
==============
Electromagnetic property inverse model: longitudinal relaxation rate, linear with relaxivity
==============
Demonstrating the inverse linear relaxivity model
for converting R_1 to tissue indicator concentration C.
"""

# %%
# Import necessary packages
import matplotlib.pyplot as plt
import numpy as np
import osipi

# %%
# Convert a series of R1 values to the corresponding indicator concentrations.
R1 = np.array([1, 2, 3, 4, 5, 6], dtype=np.float64)
R10 = np.float64(1)
r1 = np.float64(5)

C = osipi.R1_to_C_linear_relaxivity(R1, R10, r1)
print(f"Concentration (mM): {C}")

# Plot C vs. R1
plt.plot(R1, C, "r-")
plt.xlabel("R1 (/s)")
plt.ylabel("C (mM)")
plt.show()
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""
==============
Signal to concentration via electromagnetic property (SPGR, FXL, analytical linear relaxivity)
==============
Demonstrating the SPGR model for relationship between
signal S and total tissue indicator concentration, assuming the FXL.
"""

# %%
# Import necessary packages
import matplotlib.pyplot as plt
import numpy as np
import osipi

# %%
# Convert a series of S values to the corresponding indicator concentrations.
# Example data adapted from OSIPI repository ("vox_1")
S = np.array(
[
7,
9,
6,
10,
9,
6,
9,
10,
9,
9,
9,
12,
8,
10,
12,
15,
53,
70,
71,
70,
63,
58,
54,
50,
53,
48,
52,
49,
42,
],
dtype=np.float64,
)
S_baseline = S[0] # use first point for baseline signal
R10 = np.float64(1 / 1.4)
TR = np.float64(0.002)
a = np.float64(13)
r1 = np.float64(4.5)

C = osipi.S_to_C_via_R1_SPGR(S, S_baseline, R10, TR, a, r1)
print(f"Concentration (mM): {C}")

# Plot S and C
fig, ax = plt.subplots(2, 1)
ax[0].plot(S, "b-")
ax[0].set_ylabel("S (a.u.)")
ax[1].plot(C, "b-")
ax[1].set_ylabel("C (mM)")
ax[1].set_xlabel("time point")
plt.show()
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"""
==============
Signal to electromagnetic properties (R1) (SPGR, FXL, analytical linear relaxivity)
==============
Demonstrating the SPGR model for relationship between signal S and R1, assuming the FXL.
"""

# %%
# Import necessary packages
import matplotlib.pyplot as plt
import numpy as np
import osipi

# %%
# Convert a series of S values to the corresponding R1 values.
# Example data adapted from OSIPI repository ("vox_1")
S = np.array(
[
7,
9,
6,
10,
9,
6,
9,
10,
9,
9,
9,
12,
8,
10,
12,
15,
53,
70,
71,
70,
63,
58,
54,
50,
53,
48,
52,
49,
42,
],
dtype=np.float64,
)
S_baseline = np.float64(S[0]) # use first point for baseline signal
R10 = np.float64(1 / 1.4)
TR = np.float64(0.002)
a = np.float64(13)

R1 = osipi.S_to_R1_SPGR(S, S_baseline, R10, TR, a)
print(f"R_1 (/s): {R1}")

# Plot S and R1
fig, ax = plt.subplots(2, 1)
ax[0].plot(S, "b-")
ax[0].set_ylabel("S (a.u.)")
ax[1].plot(R1, "b-")
ax[1].set_ylabel("R1 (/s)")
ax[1].set_xlabel("time point")
plt.show()
6 changes: 4 additions & 2 deletions docs/source/reference/alphabetical.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ Alphabetic list of all currently available `osipi` code snippets.
:toctree: ../generated/api/
:template: autosummary.rst

aif_parker
aif_georgiou
aif_parker
aif_weinmann
tofts
extended_tofts
signal_linear
signal_SPGR
tofts
11 changes: 6 additions & 5 deletions docs/source/reference/general.convolution.rst
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ Convolution

.. currentmodule:: osipi

.. note::
Exponential convolution
-----------------------

This is a placeholder page. There is no relevant functionality in ``osipi`` yet.
.. autosummary::
:toctree: ../generated/api/
:template: autosummary.rst

Please check back later - or better yet, write up what you were looking for here and contribute it! This way the next person looking for this feature won't have to..

See :ref:`developer-guide` for guidance on how to contribute.
exp_conv
11 changes: 7 additions & 4 deletions docs/source/reference/models.signal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ Signal models

.. currentmodule:: osipi

.. note::

This is a placeholder page. There is no relevant functionality in ``osipi`` yet.
Magnitude models: DCE - R1 in the fast water exchange limit
-----------------------------------------------------------

Please check back later - or better yet, write up what you were looking for here and contribute it! This way the next person looking for this feature won't have to..
.. autosummary::
:toctree: ../generated/api/
:template: autosummary.rst

See :ref:`developer-guide` for guidance on how to contribute.
signal_linear
signal_SPGR
10 changes: 6 additions & 4 deletions docs/source/reference/processes.R1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ R1 measurement

.. currentmodule:: osipi

.. note::

This is a placeholder page. There is no relevant functionality in ``osipi`` yet.
Signal to R1
---------------

Please check back later - or better yet, write up what you were looking for here and contribute it! This way the next person looking for this feature won't have to..
.. autosummary::
:toctree: ../generated/api/
:template: autosummary.rst

See :ref:`developer-guide` for guidance on how to contribute.
S_to_R1_SPGR
Loading

0 comments on commit d766d98

Please sign in to comment.