Skip to content

Commit

Permalink
remove kinfitr
Browse files Browse the repository at this point in the history
  • Loading branch information
bilgelm committed Sep 12, 2024
1 parent d17a319 commit 1324c5a
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 455 deletions.
17 changes: 0 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ _Dynamic PET_ requires Python 3.11+ and the following modules:
`nibabel` for neuroimaging data I/O and simple manipulations, and
`click` for the CLI.

To run the `kinfitr` implementations of kinetic models, you will also need an
installation of R and the [kinfitr] R package as well as the `rpy2` Python module.

[kinfitr]: https://github.com/mathesong/kinfitr

## Installation

You can install _Dynamic PET_ via [pip] after cloning the repository:
Expand All @@ -67,18 +62,6 @@ $ git clone https://github.com/bilgelm/dynamicpet.git
$ pip install -e dynamicpet
```

If you would like to use kinetic models implemented in `kinfitr` with
_Dynamic PET_, first [install R](https://cran.r-project.org)
and the [kinfitr] R package.
Then install _Dynamic PET_ with the `kinfitr` extra after cloning the `git`
repository as descibed above:

```console
$ pip install -e dynamicpet[kinfitr]
```

[kinfitr]: https://github.com/mathesong/kinfitr

## Usage

Please see the [Usage] for details on the CLI.
Expand Down
9 changes: 2 additions & 7 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@

## dynamicpet.kineticmodel

These kinetic model implementations use the entire temporal extent of the TAC object provided for modeling. If you'd like to use a specific time interval for
These kinetic model implementations use the entire temporal extent of the TAC
object provided for modeling. If you'd like to use a specific time interval for
modeling, first extract this time interval and then fit the kinetic model.

```{eval-rst}
Expand All @@ -61,9 +62,3 @@ modeling, first extract this time interval and then fit the kinetic model.
:members:
:inherited-members:
```

```{eval-rst}
.. automodule:: dynamicpet.kineticmodel.kinfitr
:members:
:inherited-members:
```
49 changes: 1 addition & 48 deletions poetry.lock

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

5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@ numpy = ">=1.24.3"
click = ">=8.1.3"
scipy = ">=1.10.1"
tqdm = ">=4.65.0"

rpy2 = { version = ">=3.5.12", optional = true }
types-tqdm = "^4.66.0.20240417"

[tool.poetry.extras]
kinfitr = ["rpy2"]

[tool.poetry.scripts]
kineticmodel = "dynamicpet.__main__:kineticmodel"
denoise = "dynamicpet.__main__:denoise"
Expand Down
12 changes: 0 additions & 12 deletions src/dynamicpet/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
"SUVR",
"SRTMLammertsma1996",
"SRTMZhou2003",
"kinfitr.SRTM",
"kinfitr.SRTM2",
]

INTEGRATION_TYPES = (
Expand Down Expand Up @@ -281,16 +279,6 @@ def kineticmodel(
weight_by=weight_by,
fwhm=fwhm,
)
case "kinfitr.srtm":
from dynamicpet.kineticmodel import kinfitr

km = kinfitr.SRTM(reftac, pet_img)
km.fit(mask=petmask_img_mat)
case "kinfitr.srtm2":
from dynamicpet.kineticmodel import kinfitr

km = kinfitr.SRTM2(reftac, pet_img)
km.fit(mask=petmask_img_mat)
case _:
raise ValueError(f"Model {model} is not supported")

Expand Down
147 changes: 0 additions & 147 deletions src/dynamicpet/kineticmodel/kinfitr.py

This file was deleted.

27 changes: 0 additions & 27 deletions tests/test_kineticmodel_simulated.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,30 +268,3 @@ def test_srtmlammertsma1996_tm(
assert np.allclose(bp, bp_true, rtol=relative_tol)
assert np.allclose(r1, r1_true, rtol=relative_tol)
assert np.allclose(fitted_tacs.dataobj, tac.dataobj, rtol=relative_tol)


def test_srtmkinfitr_tm(
frame_start: NDArray[np.double],
frame_duration: NDArray[np.double],
) -> None:
"""Test kinfitr SRTM wrapper."""
kinfitr = pytest.importorskip("dynamicpet.kineticmodel.kinfitr")

bp_true = 1.5
r1_true = 1.2
ct, cref = get_tacs_and_reftac_dataobj(
frame_start, frame_duration, bp_true, r1_true
)

tac = TemporalMatrix(ct, frame_start, frame_duration)
reftac = TemporalMatrix(cref, frame_start, frame_duration)

km = kinfitr.SRTM(reftac, tac)
km.fit()

bp: NumpyRealNumberArray = km.get_parameter("bp")
r1: NumpyRealNumberArray = km.get_parameter("R1")

relative_tol = 0.006
assert np.allclose(bp, bp_true, rtol=relative_tol)
assert np.allclose(r1, r1_true, rtol=relative_tol)
Loading

0 comments on commit 1324c5a

Please sign in to comment.