Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Tofts and Ext. Tofts #5

Merged
merged 22 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .github/workflows/documentation.yaml
100644 → 100755
Empty file.
Empty file modified .github/workflows/pytest-actions.yaml
100644 → 100755
Empty file.
150 changes: 0 additions & 150 deletions .gitignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can keep this file on the repo. You can add .DS_Store as well.

This file was deleted.

Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
ltorres6 marked this conversation as resolved.
Show resolved Hide resolved
Empty file.
Empty file modified docs/Makefile
100644 → 100755
Empty file.
Binary file added docs/examples/.DS_Store
Binary file not shown.
Empty file modified docs/examples/README.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/aif/README.rst
100644 → 100755
Empty file.
18 changes: 1 addition & 17 deletions docs/examples/aif/plot_aif_parker.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
plt.show()

# %%
# The bolus arrival time (BAT) defaults to 30s. What happens if we change it? Let's try, by changing it in steps of 30s:
# The bolus arrival time (BAT) defaults to 0s. What happens if we change it? Let's try, by changing it in steps of 30s:

ca = osipi.aif_parker(t, BAT=0)
plt.plot(t, ca, 'b-', label='BAT = 0s')
Expand All @@ -44,21 +44,5 @@
plt.legend()
plt.show()

# %%
# the dose defaults to 0.1- what happens if we change it too?

ca = osipi.aif_parker(t, BAT=0, dose=0.05)
plt.plot(t, ca, 'b-', label='BAT = 0s, dose = 0.05')
ca = osipi.aif_parker(t, BAT=30, dose=0.1)
plt.plot(t, ca, 'r-', label='BAT = 30s, dose = 0.1')
ca = osipi.aif_parker(t, BAT=60, dose=0.2)
plt.plot(t, ca, 'g-', label='BAT = 60s, dose = 0.2')
ca = osipi.aif_parker(t, BAT=90, dose=0.3)
plt.plot(t, ca, 'm-', label='BAT = 90s, dose = 0.3')
plt.xlabel('Time (sec)')
plt.ylabel('Plasma concentration (mM)')
plt.legend()
plt.show()

# Choose the last image as a thumbnail for the gallery
# sphinx_gallery_thumbnail_number = -1
16 changes: 0 additions & 16 deletions docs/examples/aif/plot_dummy.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,5 @@
plt.legend()
plt.show()

# %%
# the dose defaults to 0.1- what happens if we change it too?

ca = osipi.aif_parker(t, BAT=0, dose=0.05)
plt.plot(t, ca, 'b-', label='BAT = 0s, dose = 0.05')
ca = osipi.aif_parker(t, BAT=30, dose=0.1)
plt.plot(t, ca, 'r-', label='BAT = 30s, dose = 0.1')
ca = osipi.aif_parker(t, BAT=60, dose=0.2)
plt.plot(t, ca, 'g-', label='BAT = 60s, dose = 0.2')
ca = osipi.aif_parker(t, BAT=90, dose=0.3)
plt.plot(t, ca, 'm-', label='BAT = 90s, dose = 0.3')
plt.xlabel('Time (sec)')
plt.ylabel('Plasma concentration (mM)')
plt.legend()
plt.show()

# Choose the last image as a thumbnail for the gallery
# sphinx_gallery_thumbnail_number = -1
Empty file modified docs/examples/tissue/README.rst
100644 → 100755
Empty file.
28 changes: 0 additions & 28 deletions docs/examples/tissue/plot_dummy.py

This file was deleted.

53 changes: 53 additions & 0 deletions docs/examples/tissue/plot_extended_tofts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""
====================
The Extended Tofts model
====================

Simulating tissue concentrations from extended Tofts model with different settings.
"""

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

# %%
# Generate Parker AIF with default settings.

# Define time points in units of seconds - in this case we use a time resolution of 1 sec and a total duration of 6 minutes.
t = np.arange(0, 6*60, 1)

# Create an AIF with default settings
ca = osipi.aif_parker(t)

# %%
# Plot the tissue concentrations for an extracellular volume fraction of 0.2 and 3 different plasma volumes of 0.05, 0.2 and 0.6
Ktrans = 0.2 # in units of 1/min
ve = 0.2 # volume fraction between 0 and 1
vp = [0.05, 0.2, 0.6] # volume fraction between 0 and 1
ct = osipi.extended_tofts(t, ca, Ktrans, ve, vp[0])
plt.plot(t, ct, 'b-', label=f'vp = {vp[0]}')
ct = osipi.extended_tofts(t, ca, Ktrans, ve, vp[1])
plt.plot(t, ct, 'g-', label=f'vp = {vp[1]}')
ct = osipi.extended_tofts(t, ca, Ktrans, ve, vp[2])
plt.plot(t, ct, 'm-', label=f'vp = {vp[2]}')
plt.xlabel('Time (sec)')
plt.ylabel('Tissue concentration (mM)')
plt.legend()
plt.show()

# %%
# Comparing different discretization methods for an extracellular volume fraction of 0.2, Ktrans of 0.2 /min and vp of 0.05
ct = osipi.extended_tofts(t, ca, Ktrans, ve, vp[0]) # Defaults to Convolution
plt.plot(t, ct, 'b-', label='Convolution')
ct = osipi.extended_tofts(t, ca, Ktrans, ve, vp[0], discretization_method='exp')
plt.plot(t, ct, 'g-', label='Exponential Convolution')
plt.title(f'Ktrans = {Ktrans} /min')
plt.xlabel('Time (sec)')
plt.ylabel('Tissue concentration (mM)')
plt.legend()
plt.show()

# Choose the last image as a thumbnail for the gallery
# sphinx_gallery_thumbnail_number = -1
52 changes: 52 additions & 0 deletions docs/examples/tissue/plot_tofts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""
====================
The Tofts model
====================

Simulating tissue concentrations from Tofts model with different settings.
"""

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

# %%
# Generate Parker AIF with default settings.

# Define time points in units of seconds - in this case we use a time resolution of 1 sec and a total duration of 6 minutes.
t = np.arange(0, 6*60, 1)

# Create an AIF with default settings
ca = osipi.aif_parker(t)

# %%
# Plot the tissue concentrations for an extracellular volume fraction of 0.2 and 3 different transfer rate constants of 0.05, 0.2 and 0.6 /min
Ktrans = [0.05, 0.2, 0.6] # in units of 1/min
ve = 0.2 # volume fraction between 0 and 1
ct = osipi.tofts(t, ca, Ktrans=Ktrans[0], ve=ve)
plt.plot(t, ct, 'b-', label=f'Ktrans = {Ktrans[0]} /min')
ct = osipi.tofts(t, ca, Ktrans[1], ve)
plt.plot(t, ct, 'g-', label=f'Ktrans = {Ktrans[1]} /min')
ct = osipi.tofts(t, ca, Ktrans[2], ve)
plt.plot(t, ct, 'm-', label=f'Ktrans = {Ktrans[2]} /min')
plt.xlabel('Time (sec)')
plt.ylabel('Tissue concentration (mM)')
plt.legend()
plt.show()

# %%
# Comparing different discretization methods for an extracellular volume fraction of 0.2 and Ktrans of 0.2 /min
ct = osipi.tofts(t, ca, Ktrans=Ktrans[1], ve=ve) # Defaults to Convolution
plt.plot(t, ct, 'b-', label='Convolution')
ct = osipi.tofts(t, ca, Ktrans=Ktrans[1], ve=ve, discretization_method='exp')
plt.plot(t, ct, 'g-', label='Exponential Convolution')
plt.title(f'Ktrans = {Ktrans[1]} /min')
plt.xlabel('Time (sec)')
plt.ylabel('Tissue concentration (mM)')
plt.legend()
plt.show()

# Choose the last image as a thumbnail for the gallery
# sphinx_gallery_thumbnail_number = -1
Empty file modified docs/make.bat
100644 → 100755
Empty file.
Empty file modified docs/requirements.txt
100644 → 100755
Empty file.
Binary file added docs/source/.DS_Store
Binary file not shown.
Empty file modified docs/source/_static/osipi.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/source/_templates/autosummary.rst
100644 → 100755
Empty file.
Empty file modified docs/source/about/index.rst
100644 → 100755
Empty file.
Empty file modified docs/source/conf.py
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions docs/source/developers_guide/index.rst
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ If you want to edit the documentation of a specific function, then you need to f
How to contribute tests
***********************

Beyond documentation and functionality, solid testing is equally critical for ensuring long-term stability of a package. `osipi` uses a continuous integration model where all tests are run before each push to the central respository. This is important because often changes at one part of the code, even if tested well locally, can have unintended consequences at other parts. The testing prevents that these errors propagate and destablize parts of the package.
Beyond documentation and functionality, solid testing is equally critical for ensuring long-term stability of a package. `osipi` uses a continuous integration model where all tests are run before each push to the central repository. This is important because often changes at one part of the code, even if tested well locally, can have unintended consequences at other parts. The testing prevents that these errors propagate and destablize parts of the package.

If you find a bug in any part of the code, this obviously points to a flaw in the code, but it also reveals a gap in the testing. It is critical when this happens that both the code AND the tests are reviewed to ensure that in future a scenario of this type is picked up during testing.

Expand All @@ -47,7 +47,7 @@ The tests are defined in the folder `osipi-tests`.
How to contribute functionality
*******************************

OSIPI is always happy to recieve new functionality for inclusion in the `osipi` package. This can be code that addresses a gap in the current functionality, or it can be code that improves the performance of a current implementation. Improvements can consist of extending the functionality (e.g. with new optional arguments), user friendliness or consistency, improvement of the accuracy or precision in the results, computation time, or platform independence, or improved documentation or code structure.
OSIPI is always happy to receive new functionality for inclusion in the `osipi` package. This can be code that addresses a gap in the current functionality, or it can be code that improves the performance of a current implementation. Improvements can consist of extending the functionality (e.g. with new optional arguments), user friendliness or consistency, improvement of the accuracy or precision in the results, computation time, or platform independence, or improved documentation or code structure.

Contribution of functionality generally proceeds in two steps. In the first step you submit your code to the primary *contributions* repository as explained in its `wiki <https://github.com/OSIPI/DCE-DSC-MRI_CodeCollection/wiki/How-to-contribute-code>`_. The task force will catalogue your code in the contributions repository and test it as explained in the `guidance <https://github.com/OSIPI/DCE-DSC-MRI_CodeCollection/wiki/The-testing-approach>`_. Afterwards, if it is found to address a gap in `osipi` and/or improve existing functionality, you will be invited to submit a pull request to `osipi` containing your contribution formatted as required by the package.

Expand Down
Binary file added docs/source/generated/.DS_Store
Binary file not shown.
Empty file modified docs/source/generated/api/osipi.aif_georgiou.rst
100644 → 100755
Empty file.
Empty file modified docs/source/generated/api/osipi.aif_parker.rst
100644 → 100755
Empty file.
Empty file modified docs/source/generated/api/osipi.aif_weinmann.rst
100644 → 100755
Empty file.
18 changes: 18 additions & 0 deletions docs/source/generated/api/osipi.extended_tofts.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
osipi.extended\_tofts
=====================


.. currentmodule:: osipi



.. autofunction:: extended_tofts





.. minigallery:: osipi.extended_tofts
:add-heading:


18 changes: 18 additions & 0 deletions docs/source/generated/api/osipi.tofts.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
osipi.tofts
===========


.. currentmodule:: osipi



.. autofunction:: tofts





.. minigallery:: osipi.tofts
:add-heading:


Empty file.
Loading
Loading