-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from OSIPI/dev
Functionality for one pipeline
- Loading branch information
Showing
28 changed files
with
739 additions
and
198 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
29 changes: 29 additions & 0 deletions
29
...xamples/signal_to_concentration/plot_signal_to_concentration_R1_to_C_linear_relaxivity.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
69 changes: 69 additions & 0 deletions
69
docs/examples/signal_to_concentration/plot_signal_to_concentration_S_to_C_via_R1_SPGR.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
67 changes: 67 additions & 0 deletions
67
docs/examples/signal_to_concentration/plot_signal_to_concentration_S_to_R1_SPGR.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.