Skip to content

Commit

Permalink
Merge pull request #11 from mjt320/develop
Browse files Browse the repository at this point in the history
modify AIF interpolation method
  • Loading branch information
mjt320 authored Feb 12, 2024
2 parents fe057fa + af65e03 commit ca2f1fb
Show file tree
Hide file tree
Showing 6 changed files with 253 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .idea/SEPAL.iml

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

5 changes: 4 additions & 1 deletion .idea/misc.xml

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

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Created 28 September 2020
@authors: Michael Thrippleton
@email: [email protected]
@institution: University of Edinburgh, UK
---

### Installation:
pip install sepal
Expand Down Expand Up @@ -38,3 +39,7 @@ Most functionality is demonstrated in Jupyter notebook format in ./demo
- R2/R2* effects not included in fitting of enhancement curves (but is included for enhancement-to-concentration conversion)
- Compartment-specific relaxivity parameters/models
- Fitting water exchange parameters
---

### Updates
Release 1.0.1 - Changed AIF interpolation method to avoid oscillations. Added demo notebook on interpolation.
233 changes: 233 additions & 0 deletions demo/demo_interpolation.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "sepal"
version = "1.0.0"
version = "1.0.1"
description = "Quantitative MRI processing"
readme = "README.md"
authors = [{ name = "Michael Thrippleton", email = "[email protected]" }]
Expand Down
13 changes: 9 additions & 4 deletions src/sepal/aifs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from abc import ABC, abstractmethod

import numpy as np
from scipy.interpolate import interp1d
from scipy.interpolate import interp1d, Akima1DInterpolator


class AIF(ABC):
Expand Down Expand Up @@ -71,14 +71,19 @@ def __init__(self, t_data, c_ap_data):
"""
self.t_data = t_data
self.c_ap_data = c_ap_data
self.c_ap_func = interp1d(t_data, c_ap_data,
kind='quadratic', bounds_error=False,
fill_value=(0, c_ap_data[-1]))
self.c_ap_func = Akima1DInterpolator(t_data, c_ap_data)

def c_ap(self, t):
"""Get AIF plasma concentration(t). Overrides superclass method."""
# calculate concentration(t) using interpolation function
c_ap = self.c_ap_func(t)
# replace values outside time range with first/last values
idx_before = t < min(self.t_data)
idx_after = t > max(self.t_data)
c_ap_before = self.c_ap_data[0]
c_ap_after = self.c_ap_data[-1]
c_ap[idx_before] = c_ap_before
c_ap[idx_after] = c_ap_after
return c_ap


Expand Down

0 comments on commit ca2f1fb

Please sign in to comment.