Skip to content

Commit

Permalink
Merge pull request #2 from stadmill/main
Browse files Browse the repository at this point in the history
Added tofts model
  • Loading branch information
plaresmedima authored Jan 25, 2024
2 parents 1b3dcde + 768b913 commit 316f928
Show file tree
Hide file tree
Showing 71 changed files with 913 additions and 458 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/other.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions .idea/pypi.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added docs/.DS_Store
Binary file not shown.
18 changes: 1 addition & 17 deletions docs/examples/aif/plot_aif_parker.py
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
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
28 changes: 0 additions & 28 deletions docs/examples/tissue/plot_dummy.py

This file was deleted.

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
Binary file added docs/source/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/source/developers_guide/index.rst
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.
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:


10 changes: 5 additions & 5 deletions docs/source/generated/backreferences/osipi.aif_parker.examples
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,24 @@ Examples using ``osipi.aif_parker``

.. raw:: html

<div class="sphx-glr-thumbcontainer" tooltip="Dummy script to show the examples structure. ">
<div class="sphx-glr-thumbcontainer" tooltip="Simulating tissue concentrations from Tofts model with different settings.">

.. only:: html

.. image:: /generated/examples/tissue/images/thumb/sphx_glr_plot_dummy_thumb.png
.. image:: /generated/examples/tissue/images/thumb/sphx_glr_plot_tofts_thumb.png
:alt:

:ref:`sphx_glr_generated_examples_tissue_plot_dummy.py`
:ref:`sphx_glr_generated_examples_tissue_plot_tofts.py`

.. raw:: html

<div class="sphx-glr-thumbnail-title">Dummy script as demo</div>
<div class="sphx-glr-thumbnail-title">The Tofts model</div>
</div>


.. only:: not html

* :ref:`sphx_glr_generated_examples_tissue_plot_dummy.py`
* :ref:`sphx_glr_generated_examples_tissue_plot_tofts.py`

.. raw:: html

Expand Down
Empty file.
39 changes: 39 additions & 0 deletions docs/source/generated/backreferences/osipi.tofts.examples
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@


Examples using ``osipi.tofts``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


.. start-sphx-glr-thumbnails


.. raw:: html

<div class="sphx-glr-thumbnails">


.. raw:: html

<div class="sphx-glr-thumbcontainer" tooltip="Simulating tissue concentrations from Tofts model with different settings.">

.. only:: html

.. image:: /generated/examples/tissue/images/thumb/sphx_glr_plot_tofts_thumb.png
:alt:

:ref:`sphx_glr_generated_examples_tissue_plot_tofts.py`

.. raw:: html

<div class="sphx-glr-thumbnail-title">The Tofts model</div>
</div>


.. only:: not html

* :ref:`sphx_glr_generated_examples_tissue_plot_tofts.py`

.. raw:: html

</div>

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 316f928

Please sign in to comment.