Skip to content

Commit

Permalink
Merge pull request #8 from mjt320/develop
Browse files Browse the repository at this point in the history
prepared for distribution
  • Loading branch information
mjt320 authored Feb 7, 2024
2 parents ced76cc + 54c96d9 commit 524d6e5
Show file tree
Hide file tree
Showing 32 changed files with 895 additions and 666 deletions.
6 changes: 4 additions & 2 deletions .idea/SEPAL.iml

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

2 changes: 1 addition & 1 deletion .idea/misc.xml

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

4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# MANIFEST.in

recursive-include demo *
prune demo/.ipynb_checkpoints
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# South Edinburgh Perfusion Analysis Library (SEPAL)
# South Edinburgh Perfusion+ Analysis Library (SEPAL)

**Please note: This library is also hosted in the [OSIPI DCE-DSC-MRI_CodeCollection repository](https://github.com/OSIPI/DCE-DSC-MRI_CodeCollection), where unit tests and perfusion code by other authors can also be found.**

Python library for simulating and fitting DCE-MRI data. It permits arbitrary combinations of pulse sequence, pharmacokinetic model, water exchange model, etc. The code is a work-in-progress, has not been extensively tested and is not recommended or approved for clinical use.
Python library for simulating and fitting DCE- and other quantitative MRI data. It permits arbitrary combinations of pulse sequence, pharmacokinetic model, water exchange model, etc. The code is a work-in-progress, has not been extensively tested and is not recommended or approved for clinical use.

Created 28 September 2020
@authors: Michael Thrippleton
@email: [email protected]
@institution: University of Edinburgh, UK

### Installation:
pip install sepal

### Use:
Most functionality is demonstrated in Jupyter notebook format in ./demo

### Functionality:
- Enhancement-to-concentration conversion (assuming fast water exchange)
- Fit tissue concentration using pharmacokinetic model
Expand Down
63 changes: 20 additions & 43 deletions demo/demo_aif_module.ipynb

Large diffs are not rendered by default.

59 changes: 29 additions & 30 deletions demo/demo_enh_to_conc.ipynb

Large diffs are not rendered by default.

329 changes: 228 additions & 101 deletions demo/demo_fit_dce.ipynb

Large diffs are not rendered by default.

404 changes: 184 additions & 220 deletions demo/demo_fit_t1.ipynb

Large diffs are not rendered by default.

44 changes: 18 additions & 26 deletions demo/demo_fit_t2s.ipynb

Large diffs are not rendered by default.

17 changes: 6 additions & 11 deletions demo/demo_imaging_utilities.ipynb

Large diffs are not rendered by default.

22 changes: 8 additions & 14 deletions demo/demo_mt.ipynb

Large diffs are not rendered by default.

251 changes: 158 additions & 93 deletions demo/demo_pk_models.ipynb

Large diffs are not rendered by default.

64 changes: 40 additions & 24 deletions demo/demo_relaxivity_module.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@
{
"cell_type": "markdown",
"id": "fifty-passport",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"## Relaxivity module demo"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 1,
"id": "internal-arbor",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
"metadata": {
"pycharm": {
"name": "#%%\n"
}
],
},
"outputs": [],
"source": [
"import sys\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"sys.path.append('../src')\n",
"import relaxivity\n",
"from sepal import relaxivity\n",
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "markdown",
"id": "arabic-latvia",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"### The CRModel class\n",
"This is an abstract base class. Subclasses represent specific relaxivity models. \n",
Expand All @@ -46,9 +46,13 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"id": "4080ceab-24f8-4b2e-b57d-816474887489",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"cr_model = relaxivity.CRLinear(r1=5.0, r2=7.1)"
Expand All @@ -57,16 +61,24 @@
{
"cell_type": "markdown",
"id": "52762d06-81e5-4153-88f5-5d0e827d7f82",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"Now we can use the R1 and R2 methods to calculate the relaxation rates for a given concentration and pre-contrast relaxation rate values:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 3,
"id": "a3c01c12-fb5e-4aed-b9fb-b882270ba27f",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand All @@ -86,7 +98,11 @@
{
"cell_type": "markdown",
"id": "4a7c1681-7e9d-49b2-9474-56f86a8f25ef",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"Additional subclasses could be implemented to represent other concentration-relaxation relationships, e.g. quadratic."
]
Expand All @@ -113,4 +129,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
55 changes: 33 additions & 22 deletions demo/demo_signal_models.ipynb

Large diffs are not rendered by default.

99 changes: 52 additions & 47 deletions demo/demo_simulation.ipynb

Large diffs are not rendered by default.

81 changes: 60 additions & 21 deletions demo/demo_water_ex_models.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
{
"cell_type": "markdown",
"id": "eb332c7d-4589-47da-81d0-e2697ee70254",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"## Water exchange models demo"
]
Expand All @@ -13,23 +17,26 @@
"execution_count": 1,
"id": "42671502-6096-4107-8c21-3f876b950a66",
"metadata": {
"tags": []
"tags": [],
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import sys\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"sys.path.append('../src')\n",
"import water_ex_models\n",
"from sepal import water_ex_models\n",
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "markdown",
"id": "33acaa3b-10e0-454f-b62b-6a2cb5b1d0f4",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"### The WaterExModel Class\n",
"This abstract base class represents different water exchange models. The purpose of such an object is to convert a set of relaxation rates for each tissue compartment (blood, EES, cells) into one or more exponential relaxation components based on the water exchange properties. \n",
Expand All @@ -38,9 +45,13 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"id": "c2e14ed8-c6f6-4e79-9fe0-fbc9b323d156",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"p = {'b': 0.2, 'e': 0.4, 'i': 0.4}\n",
Expand All @@ -50,17 +61,25 @@
{
"cell_type": "markdown",
"id": "b6b07fe1-e732-4e57-9c4f-857815a6de3b",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"#### FXL\n",
"In the FXL, we end up with just one longitudinal relaxation component representing the tissue:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 3,
"id": "29c9d0d4-3fc0-44f5-ba00-322339389d8f",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand All @@ -81,17 +100,25 @@
{
"cell_type": "markdown",
"id": "e7855797-9f25-4ef3-b04e-6dd87d78169e",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"#### NXL\n",
"In the NXL, we get 3 relaxation components corresponding to the 3 tissue compartments:"
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 4,
"id": "0e547b96-a11b-48aa-88fd-99f46638c8f3",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand All @@ -112,17 +139,25 @@
{
"cell_type": "markdown",
"id": "db686624-a214-45e2-bae1-4e173f076d3f",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"#### NTEXL\n",
"In the No-TransEndothelial-water-eXchange Limit, we get relaxation components corresponding to blood and the combined extravascular spaces:"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 5,
"id": "feaf0f84-b3c9-44ee-ae22-7144cdd59e8b",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand All @@ -143,7 +178,11 @@
{
"cell_type": "markdown",
"id": "867ae4b1-5486-46c0-b2f8-5c73efdb0d29",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"#### Other water exchange models\n",
"Other models could be added, e.g. 3-site-2-exchange, 2-site-1-exchange."
Expand Down Expand Up @@ -171,4 +210,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
29 changes: 29 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# pyproject.toml

[build-system]
requires = ["setuptools>=61.0.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "sepal"
version = "1.0.0"
description = "Quantitative MRI processing"
readme = "README.md"
authors = [{ name = "Michael Thrippleton", email = "[email protected]" }]
license = { file = "LICENSE" }
classifiers = [
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
keywords = ["MRI", "perfusion", "quantitative"]
dependencies = [
"numpy",
"scipy",
"nibabel",
"joblib",
]
requires-python = ">=3.7"

[project.urls]
Homepage = "https://github.com/mjt320/SEPAL"
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# setup.py

from setuptools import setup

setup()
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/dce_fit.py → src/sepal/dce_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import numpy as np
from scipy.signal import argrelextrema
from scipy.interpolate import interp1d
from fitting import Fitter
from pk_models import Patlak
from utils.utilities import least_squares_global
from sepal.fitting import Fitter
from sepal.pk_models import Patlak
from sepal.utils.utilities import least_squares_global


class SigToEnh(Fitter):
Expand Down
Loading

0 comments on commit 524d6e5

Please sign in to comment.