Skip to content

Commit

Permalink
Merge pull request #4 from LucyKershaw/LEK_development
Browse files Browse the repository at this point in the history
Added extended Tofts
  • Loading branch information
stadmill authored Feb 19, 2024
2 parents 316f928 + 7cd756f commit 5804f63
Show file tree
Hide file tree
Showing 132 changed files with 679 additions and 73 deletions.
Binary file added .DS_Store
Binary file not shown.
Empty file modified .github/workflows/documentation.yaml
100644 → 100755
Empty file.
Empty file modified .github/workflows/pytest-actions.yaml
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .idea/.gitignore
100644 → 100755
Empty file.
Empty file modified .idea/inspectionProfiles/Project_Default.xml
100644 → 100755
Empty file.
Empty file modified .idea/inspectionProfiles/profiles_settings.xml
100644 → 100755
Empty file.
Empty file modified .idea/misc.xml
100644 → 100755
Empty file.
Empty file modified .idea/modules.xml
100644 → 100755
Empty file.
Empty file modified .idea/other.xml
100644 → 100755
Empty file.
Empty file modified .idea/pypi.iml
100644 → 100755
Empty file.
Empty file modified .idea/vcs.xml
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Binary file modified docs/.DS_Store
Binary file not shown.
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.
Empty file modified docs/examples/aif/plot_aif_parker.py
100644 → 100755
Empty file.
Empty file modified docs/examples/aif/plot_dummy.py
100644 → 100755
Empty file.
Empty file modified docs/examples/tissue/README.rst
100644 → 100755
Empty file.
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
Empty file modified docs/examples/tissue/plot_tofts.py
100644 → 100755
Empty file.
Empty file modified docs/make.bat
100644 → 100755
Empty file.
Empty file modified docs/requirements.txt
100644 → 100755
Empty file.
Binary file modified 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.
Empty file modified docs/source/developers_guide/index.rst
100644 → 100755
Empty file.
Binary file modified 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.
Empty file modified docs/source/generated/api/osipi.extended_tofts.rst
100644 → 100755
Empty file.
Empty file modified docs/source/generated/api/osipi.tofts.rst
100644 → 100755
Empty file.
Empty file.
52 changes: 5 additions & 47 deletions docs/source/generated/backreferences/osipi.aif_parker.examples
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,66 +14,24 @@ Examples using ``osipi.aif_parker``

.. raw:: html

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

.. only:: html

.. image:: /generated/examples/aif/images/thumb/sphx_glr_plot_aif_parker_thumb.png
.. image:: /generated/examples/tissue/images/thumb/sphx_glr_plot_extended_tofts_thumb.png
:alt:

:ref:`sphx_glr_generated_examples_aif_plot_aif_parker.py`
:ref:`sphx_glr_generated_examples_tissue_plot_extended_tofts.py`

.. raw:: html

<div class="sphx-glr-thumbnail-title">The Parker AIF - a play with variables</div>
<div class="sphx-glr-thumbnail-title">The Extended Tofts model</div>
</div>


.. only:: not html

* :ref:`sphx_glr_generated_examples_aif_plot_aif_parker.py`

.. raw:: html

<div class="sphx-glr-thumbcontainer" tooltip="Dummy script to illustrate structure of examples folder ">

.. only:: html

.. image:: /generated/examples/aif/images/thumb/sphx_glr_plot_dummy_thumb.png
:alt:

:ref:`sphx_glr_generated_examples_aif_plot_dummy.py`

.. raw:: html

<div class="sphx-glr-thumbnail-title">A dummy script</div>
</div>


.. only:: not html

* :ref:`sphx_glr_generated_examples_aif_plot_dummy.py`

.. 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`
* :ref:`sphx_glr_generated_examples_tissue_plot_extended_tofts.py`

.. raw:: html

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


Examples using ``osipi.extended_tofts``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


.. start-sphx-glr-thumbnails


.. raw:: html

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


.. raw:: html

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

.. only:: html

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

:ref:`sphx_glr_generated_examples_tissue_plot_extended_tofts.py`

.. raw:: html

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


.. only:: not html

* :ref:`sphx_glr_generated_examples_tissue_plot_extended_tofts.py`

.. raw:: html

</div>

Empty file modified docs/source/generated/backreferences/osipi.tofts.examples
100644 → 100755
Empty file.
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
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
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.
Empty file modified docs/source/generated/examples/aif/index.rst
100644 → 100755
Empty file.
Empty file modified docs/source/generated/examples/aif/plot_aif_parker.ipynb
100644 → 100755
Empty file.
Empty file modified docs/source/generated/examples/aif/plot_aif_parker.py
100644 → 100755
Empty file.
Empty file modified docs/source/generated/examples/aif/plot_aif_parker.py.md5
100644 → 100755
Empty file.
Empty file modified docs/source/generated/examples/aif/plot_aif_parker.rst
100644 → 100755
Empty file.
Empty file.
Empty file modified docs/source/generated/examples/aif/plot_dummy.ipynb
100644 → 100755
Empty file.
Empty file modified docs/source/generated/examples/aif/plot_dummy.py
100644 → 100755
Empty file.
Empty file modified docs/source/generated/examples/aif/plot_dummy.py.md5
100644 → 100755
Empty file.
Empty file modified docs/source/generated/examples/aif/plot_dummy.rst
100644 → 100755
Empty file.
Empty file modified docs/source/generated/examples/aif/plot_dummy_codeobj.pickle
100644 → 100755
Empty file.
Empty file modified docs/source/generated/examples/aif/sg_execution_times.rst
100644 → 100755
Empty file.
17 changes: 17 additions & 0 deletions docs/source/generated/examples/index.rst
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ Tissue concentrations
</div>


.. raw:: html

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

.. only:: html

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

:ref:`sphx_glr_generated_examples_tissue_plot_extended_tofts.py`

.. raw:: html

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


.. raw:: html

</div>
Expand Down
37 changes: 37 additions & 0 deletions docs/source/generated/examples/sg_execution_times.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

:orphan:

.. _sphx_glr_generated_examples_sg_execution_times:


Computation times
=================
**00:00.000** total execution time for 0 files **from generated/examples**:

.. container::

.. raw:: html

<style scoped>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap5.min.css" rel="stylesheet" />
</style>
<script src="https://code.jquery.com/jquery-3.7.0.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script>
<script type="text/javascript" class="init">
$(document).ready( function () {
$('table.sg-datatable').DataTable({order: [[1, 'desc']]});
} );
</script>

.. list-table::
:header-rows: 1
:class: table table-striped sg-datatable

* - Example
- Time
- Mem (MB)
* - N/A
- N/A
- N/A
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
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
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.
18 changes: 18 additions & 0 deletions docs/source/generated/examples/tissue/index.rst
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ Tissue concentrations
</div>


.. raw:: html

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

.. only:: html

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

:ref:`sphx_glr_generated_examples_tissue_plot_extended_tofts.py`

.. raw:: html

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


.. raw:: html

</div>
Expand All @@ -41,4 +58,5 @@ Tissue concentrations
:hidden:

/generated/examples/tissue/plot_tofts
/generated/examples/tissue/plot_extended_tofts

104 changes: 104 additions & 0 deletions docs/source/generated/examples/tissue/plot_extended_tofts.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# The Extended Tofts model\n\nSimulating tissue concentrations from extended Tofts model with different settings.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Import necessary packages\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import numpy as np\nimport matplotlib.pyplot as plt\nimport osipi"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Generate Parker AIF with default settings.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# 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.\nt = np.arange(0, 6*60, 1)\n\n# Create an AIF with default settings\nca = osipi.aif_parker(t)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"Ktrans = 0.2 # in units of 1/min\nve = 0.2 # volume fraction between 0 and 1\nvp = [0.05, 0.2, 0.6] # volume fraction between 0 and 1\nct = osipi.extended_tofts(t, ca, Ktrans, ve, vp[0])\nplt.plot(t, ct, 'b-', label=f'vp = {vp[0]}')\nct = osipi.extended_tofts(t, ca, Ktrans, ve, vp[1])\nplt.plot(t, ct, 'g-', label=f'vp = {vp[1]}')\nct = osipi.extended_tofts(t, ca, Ktrans, ve, vp[2])\nplt.plot(t, ct, 'm-', label=f'vp = {vp[2]}')\nplt.xlabel('Time (sec)')\nplt.ylabel('Tissue concentration (mM)')\nplt.legend()\nplt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Comparing different discretization methods for an extracellular volume fraction of 0.2, Ktrans of 0.2 /min and vp of 0.05\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ct = osipi.extended_tofts(t, ca, Ktrans, ve, vp[0]) # Defaults to Convolution\nplt.plot(t, ct, 'b-', label='Convolution')\nct = osipi.extended_tofts(t, ca, Ktrans, ve, vp[0], discretization_method='exp')\nplt.plot(t, ct, 'g-', label='Exponential Convolution')\nplt.title(f'Ktrans = {Ktrans} /min')\nplt.xlabel('Time (sec)')\nplt.ylabel('Tissue concentration (mM)')\nplt.legend()\nplt.show()\n\n# Choose the last image as a thumbnail for the gallery\n# sphinx_gallery_thumbnail_number = -1"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Loading

0 comments on commit 5804f63

Please sign in to comment.