{
"info": {
"author": "",
"author_email": "Janic Tom Weber , Yoel P\u00e9rez Haas ",
"bugtrack_url": null,
"classifiers": [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.10"
],
"description": "# The `adaptfx` package\n\n## Content\n\n1. [About](#about) \n2. [Installation](#installation) \n3. [Package Structure](#package-structure) \n4. [Describtion](#description) \n 1. [2D Algorithms](#the-2d-algorithms)\n 2. [3D Algorithms](#the-3d-algorithms)\n 3. [GUI](#gui)\n 4. [Probability Updating](#probability-updating)\n 5. [Additional Data](#additional-data)\n5. [Extended Function](#extended-functionality)\n6. [Troubleshooting](#troubleshooting)\n\n---\n\n## About\n\n`adaptfx` is a python package to calculate adaptive fractionation schemes. Using magnetic resonance (MR) guidance in radiotherapy, treatment plans can be adapted daily to a patient's geometry, thereby exploiting inter-fractional motion of tumors and organs at risk (OAR). This can improve OAR sparing or tumor coverage, compared to standard fractionation schemes, which simply apply a predefined dose every time.\n\n\nFor this adaptive approach a reinforcement learning algorithm based on dynamic programming was initially developed by P\u00e9rez Haas et al. [[1]](#1). The package is actively maintained and frequently extended as part of our ongoing research on the topic\n\n\n## Installation\n\nIt is recommended to create a virtual environment using the `venv` module:\n\n```\n$ python3.10 -m venv adaptfx_env\n```\n\nactivate the virtual environment\n```\n$ cd adaptfx_env\n$ source bin/activate\n```\n\nTo install the `adaptfx` package, use either of the methods below.\n\n### Method 1: pip\n\n```\n$ pip install adaptfx\n```\n\n### Method 2: install from source\n\n```\n$ git clone https://github.com/openAFT/adaptfx.git\n$ cd adaptfx\n$ pip3 install .\n```\n\nthe command line tool (CLI) is then available and can be used via\n\n```\n$ aft [options] \n```\n\nfor more information on the usage of the CLI, read the [manual](MANUAL.md).\n\nThe user can also decide to use the scripts from `reinforce` in their python scripts e.g.\n\n```python\nimport adapatfx as afx\nplan_output = afx.multiple('oar', keys)\n```\n\n`adaptfx` also provides a GUI. However, it depends on `Tkinter`. It often comes installed, but if not you can find the relevant installation instructions [here](https://tkdocs.com/tutorial/install.html). E.g. in python and on Ubuntu, you would install it via\n\n```\n$ sudo apt install python3-tk\n```\n\n## Package Structure\n\nThe package is organized under the `src` folder. All relevant scripts that calculate the fractionation schemes are packed as functions in either `reinforce.py` or `reinforce_old.py`. Where `reinforce.py` holds the newest functions supporting more features and faster calculation. Older functions are also integrated with the CLI, but need to be updated.\n\n```\nadaptfx\n\u251c\u2500\u2500 src/adaptfx\n\u2502 \u251c\u2500\u2500 aft_propmt.py\n\u2502 \u251c\u2500\u2500 aft_utils.py\n\u2502 \u251c\u2500\u2500 aft.py\n\u2502 \u251c\u2500\u2500 constants.py\n\u2502 \u251c\u2500\u2500 maths.py\n\u2502 \u251c\u2500\u2500 planning.py\n\u2502 \u251c\u2500\u2500 radiobiology.py\n\u2502 \u251c\u2500\u2500 reinforce_old.py\n\u2502 \u251c\u2500\u2500 reinforce.py\n\u2502 \u2514\u2500\u2500 visualiser.py\n\u2514\u2500\u2500 work\n```\n\n## Description\n\n### The 2D algorithms\n\nThe function `max_tumor_bed_old` globally tracks OAR BED to satisfy constraints on the dose to the normal tissue, while attempting to maximize the BED delivered to the tumor.\n\n`min_oar_bed` and `min_oar_bed_old`, on the other hand, track tumor BED to achieve the tumor dose target and in doing so it minimizes the cumulative OAR BED.\n\nSince the state spaces for these two algorithms are essentially two-dimensional, they are the faster algorithm. But they may overshoot w.r.t. the dose delivered to the tumor/OAR, since only one of the structure's BED can be tracked, one has to decide whether reaching the prescribed tumor dose or staying below the maximum OAR BED is more relevant.\n\nGenerally the OAR tracking is better suited for patients with anatomies where the OAR and tumor are close to each other and the prescribed dose may not be reached. When the OAR and tumor are farther apart, tracking the tumor BED and minimizing OAR BED can lead to reduced toxicity while achieving the same treatment goals.\n\n`frac_min` defines the function to track OAR BED and minimize the number of fractions in cases where there appears an exceptionally low sparing factor during the course of a treatment.\n\n### The 3D algorithms\n\nThe 3D algorithms in function `min_oar_max_tumor_old` track OAR BED and tumor BED simultaneously. In this version a prescribed tumor dose must be provided alongside an OAR BED constraint. The algorithm then tries smartly optimizes for a low OAR BED _and_ high tumor BED at the same time, while never compromising OAR constraints and always preferring to reduce normal tissue dose when achieving the treatment objectives.\n\nThe algorithms are based on an inverse-gamma prior distribution. To set up this distribution a dataset is needed with prior patient data (sparing factors) from the same population.\n\nThere is a function to calculate the hyperparameters of the inverse-gamma distribution. But there is also the option to use a fixed probability distribution for the sparing factors. In this case, the probability distribution must be provided with a mean and a standard deviation, and it is not updated as more information is available. To check out how the hyperparameters influence the prior distribution, the `Inverse_gamma_distribution_preview.py` file has been included that allows direct modelling of the distribution.\n\n### GUI\n\nA last addition is made with graphical user interfaces that facilitate the use of the interpolation algorithms. There are two interfaces that can be run. In these interfaces all variables can be given to compute an adaptive fractionation plan for a patient. \n\n> :warning: Note:\\\n> The interfaces are not optimized, and thus it is not recommended using them to further develop extensions.\n\n### Reducing Number of Fractions\n\nFor the 2D algorithms there exist the possibility to reduce number of fractions. A constant $c$ can be chosen which introduces a reward (or rather a cost) linear to the number of fractions used to finish the treatment. The cost is added to the immediate reward returned by the environment in the current fraction. There exist a simulative model helping to estimate what the constant $c$ should be chosen in order for the treatment to finish on some target number of fractions $n_{\\text{targ}}$. The function can be found [here](src/adaptfx/radiobiology.py) in `c_calc`.\n\n### Probability Updating\n\nThe DP algorithm relies on a description of the environment to compute an optimal policy, in this case the probability distribution of the sparing factor $P(\\delta)$, which we assume to be a Gaussian distribution truncated at $0$, with patient-specific parameters for mean and standard deviation. At the start of a treatment, only two sparing factors are available for that patient, from the planning scan and the first fraction. In each fraction, an additional sparing factor is measured, which can be used to calculate updated estimates $\\mu_t$ and $\\sigma_t$ for mean and standard deviation, respectively.\n\n#### No Updating\n\nIn case where the probability is not updated the parameters $\\mu_t$ and $\\sigma_t$ of the normal distribution can be fixed.\n\n#### Maximum a posteriori estimation\n\nIn each fraction $t$, a maximum likelihood estimator of the mean of the sparing factor distribution and an estimator for the standard deviation (following a chi-squared distribution) is used. Both estimators are used to constitute the updated normal distribution in fraction $t$.\n\nHowever, the standard deviation may be severely under- or overestimated if calculated from only two samples at the very beginning of the treatment. Therefore, we assume a population based prior for the standard deviation and compute the maximum a posterior estimator of $\\sigma_t$ via Bayesian inference. As the sparing factors are assumed to follow a normal distribution with unknown variance, a gamma distribution is chosen as prior to estimate the standard deviation $\\sigma$.\n\n#### Posterior predicitve distribution\n\nApart from using a gamma prior for the standard deviation, a full Bayesian approach can be employed with an inverse-gamm distribution as a conjugate prior for the variance. The resulting posterior predictive distribution is a student t-distribution. With this approach instead of using the gamma prior to estimate, the probability distribution is estimated from an updated t-distribution. The results are slightly different compared to the maximum a posteriori estimation.\n\n### Additional Data\n\nThe two additional folders (`DVH_figures`, `Patientdata_paper`) contain the DVH data and figures of the 10 patients that were included in the paper.\n\n## Extended Functionality\n\nThe algorithms allow to choose some extra parameters to specify extra constraints. The suggested parameters are specified for a 5 fraction SBRT plan where there are not constraints on the maximum or minimum dose:\n\n- Chose the amount of fractions. Instead of just calculating for the case of a 5-fractions SBRT treatment, the amount of fractions can be chosen freely (e.g. 30 fractions)\n- Fix a minimum and maximum dose: Limits the action space by forcing a minimum and maximum dose for each fraction. (e.g. 4-16 Gy)\n- Calculate optimal fraction size by tracking tumor BED: The 2D GUI has an additional extension, where one can optimize the optimal dose based on the prescribed tumor dose. (E.g., the clinician prescribes a tumor BED of 72 Gy. The program will try to minimize the OAR BED while aiming at the 72 Gy BED prescribed dose.)\n\n## Troubleshooting\n\n### No module named `_ctypes` on install\n\n**Problem:** on Linux distributions it happens that the `pip install .` command fails with the message:\n\n```\nTraceback (most recent call last):\n File \"\", line 1, in \n File \"/usr/local/lib/python3.10/some/module\", line 10, in \n import ctypes\n File \"/usr/local/lib/python3.10/ctypes/__init__.py\", line 7, in \n from _ctypes import Union, Structure, Array\nImportError: No module named '_ctypes'\n```\n\n**Solution:** with the specific package manager of the Linux distribution install `libffi-dev` development tool. E.g. in Fedora Linux and derivatives install this tool\n\n```\n$ sudo dnf install libffi-devel\n```\n\nOn Ubuntu:\n```\n$ sudo apt install libffi-dev\n```\n\n### No GUI backend for `matplotlib`\n\n**Problem:** on Linux or MacOS it could be that once `aft` is run the plots are not shown and there is an error message:\n\n\n```\nCollecting tkinter\n Could not find a version that satisfies the requirement tkinter (from versions: )\nNo matching distribution found for tkinter\n```\n\n**Solution:** on Fedora Linux and derivative distributions one could solve this by either installing python tkinter\n\n```\n$ sudo dnf install python3-tkinter\n```\n\non Ubuntu\n\n```\n$ sudo apt-get install python3-tk\n```\n\n**Solution:** on MacOS and Linux one could instead use `pip` to install `pyqt`\n\n```\n$ pip install pyqt5\n```\n\n\n## References\n\n[1]\nYoel Samuel P\u00e9rez Haas et al.;\n**Adaptive fractionation at the MR-linac**, *Physics in Medicine & Biology*, Jan. 2023, doi: https://doi.org/10.1088/1361-6560/acafd4\n",
"description_content_type": "text/markdown",
"docs_url": null,
"download_url": "",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "",
"keywords": "fractionation,adaptive radiotherapy,reinforcement-learning",
"license": "MIT",
"maintainer": "",
"maintainer_email": "",
"name": "adaptfx",
"package_url": "https://pypi.org/project/adaptfx/",
"platform": null,
"project_url": "https://pypi.org/project/adaptfx/",
"project_urls": {
"source": "https://github.com/openAFT/adaptfx"
},
"release_url": "https://pypi.org/project/adaptfx/0.2.1/",
"requires_dist": [
"numpy (==1.24.1)",
"scipy (==1.10.0)",
"matplotlib (==3.6.3)",
"pyqt6 (==6.4.0)",
"pandas (==1.5.2)",
"seaborn (==0.12.2)"
],
"requires_python": ">=3.10",
"summary": "Package for computing dose fractionation schemes in MR guided Adaptive Radiotherapy",
"version": "0.2.1",
"yanked": false,
"yanked_reason": null
},
"last_serial": 18576605,
"releases": {
"0.1.0": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d573123b9a0afb2a4b5665f36d7086d72037b5c0da4b6a0bb42761adaca5305b",
"md5": "1b0acdc96d53e2535e75747b3b679710",
"sha256": "ec3ab4f243d38d9f249de7ca517322afa6109695e4048d8567e61a22576bc530"
},
"downloads": -1,
"filename": "adaptfx-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1b0acdc96d53e2535e75747b3b679710",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 26140,
"upload_time": "2022-12-15T08:28:07",
"upload_time_iso_8601": "2022-12-15T08:28:07.868600Z",
"url": "https://files.pythonhosted.org/packages/d5/73/123b9a0afb2a4b5665f36d7086d72037b5c0da4b6a0bb42761adaca5305b/adaptfx-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "41f8ad6ea549b3545b0d7383d3a20dd2b41f2bbd668d1cc50ff18d799738737b",
"md5": "b625d7dbaaf8ef2a018e9c2337312cfa",
"sha256": "7f9696cf16db4f586ce9f39b3a3bcd360f50b0f7e43c1469e1ad34e2e8f2fb55"
},
"downloads": -1,
"filename": "adaptfx-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "b625d7dbaaf8ef2a018e9c2337312cfa",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 3616288,
"upload_time": "2022-12-15T08:28:09",
"upload_time_iso_8601": "2022-12-15T08:28:09.826125Z",
"url": "https://files.pythonhosted.org/packages/41/f8/ad6ea549b3545b0d7383d3a20dd2b41f2bbd668d1cc50ff18d799738737b/adaptfx-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"0.1.1": [
{
"comment_text": "",
"digests": {
"blake2b_256": "98af934c09d106469571473002f6ffd6954e90bdd7fd15f79deacd670c5cbddf",
"md5": "8faeab0fd2108f4c666fe2d55c453222",
"sha256": "268c303a8ef32781f56af0a5a60f97b4098e52864030a96f7ecb1b0345b2c8ff"
},
"downloads": -1,
"filename": "adaptfx-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8faeab0fd2108f4c666fe2d55c453222",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 26525,
"upload_time": "2023-01-25T14:28:15",
"upload_time_iso_8601": "2023-01-25T14:28:15.818464Z",
"url": "https://files.pythonhosted.org/packages/98/af/934c09d106469571473002f6ffd6954e90bdd7fd15f79deacd670c5cbddf/adaptfx-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a5629cded6611f4b6609e27724f6646fa964fda830585a9beb25ab4af094fdfa",
"md5": "23a2ed410e250e140ebf29ea7a68575a",
"sha256": "19904a06158b050ecb1161b80747fc0d362206a179d506891afe43a643821552"
},
"downloads": -1,
"filename": "adaptfx-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "23a2ed410e250e140ebf29ea7a68575a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 3593540,
"upload_time": "2023-01-25T14:28:17",
"upload_time_iso_8601": "2023-01-25T14:28:17.603786Z",
"url": "https://files.pythonhosted.org/packages/a5/62/9cded6611f4b6609e27724f6646fa964fda830585a9beb25ab4af094fdfa/adaptfx-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"0.2.0": [
{
"comment_text": "",
"digests": {
"blake2b_256": "24a889a312cea33a661c4314d7143553b1130e5cda6c133af13c64036bb6d55d",
"md5": "c6a1c4909274f2e3e4ca5893a7833dde",
"sha256": "47b086d3e2bf73854e2d99046e2349e4c58db01ac00743daf2e616186730844a"
},
"downloads": -1,
"filename": "adaptfx-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c6a1c4909274f2e3e4ca5893a7833dde",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 26686,
"upload_time": "2023-02-01T18:07:57",
"upload_time_iso_8601": "2023-02-01T18:07:57.547773Z",
"url": "https://files.pythonhosted.org/packages/24/a8/89a312cea33a661c4314d7143553b1130e5cda6c133af13c64036bb6d55d/adaptfx-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "71434845b1908f5ecaad982942aea2b9d15ac9320373337c7a6bd060291814ff",
"md5": "c24e30773005b2d920059f23ba90de34",
"sha256": "5fc33429b73cb2e74d4d5ce285b072c8d35945f776ff3f68388ff4079b435c1e"
},
"downloads": -1,
"filename": "adaptfx-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "c24e30773005b2d920059f23ba90de34",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 3593471,
"upload_time": "2023-02-01T18:07:58",
"upload_time_iso_8601": "2023-02-01T18:07:58.881342Z",
"url": "https://files.pythonhosted.org/packages/71/43/4845b1908f5ecaad982942aea2b9d15ac9320373337c7a6bd060291814ff/adaptfx-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"0.2.1": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b8c4694877789da869c6b0b13dc0d31d6cd9ff243d99656abfbb1f1d8dc45fbc",
"md5": "9b3e9955391a0144dc10abcc7eb5129d",
"sha256": "71cd8e1c3556d1e0b5ee1d24e0bb416b4852d3f2964b2414b0fbffc2d880164a"
},
"downloads": -1,
"filename": "adaptfx-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9b3e9955391a0144dc10abcc7eb5129d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 37225,
"upload_time": "2023-06-20T15:01:12",
"upload_time_iso_8601": "2023-06-20T15:01:12.437198Z",
"url": "https://files.pythonhosted.org/packages/b8/c4/694877789da869c6b0b13dc0d31d6cd9ff243d99656abfbb1f1d8dc45fbc/adaptfx-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5c0338c5c9445c6d04c7693c67aee5c37376bc8acf4ee6e3492765f42da9341b",
"md5": "7f45bba1671f280053fdc993f4391119",
"sha256": "ff7e1f3aeb45dba169a0e3d4cb3ce3b6ff8024231f85f656b967d120c72d8f4f"
},
"downloads": -1,
"filename": "adaptfx-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "7f45bba1671f280053fdc993f4391119",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 3603598,
"upload_time": "2023-06-20T15:01:14",
"upload_time_iso_8601": "2023-06-20T15:01:14.788962Z",
"url": "https://files.pythonhosted.org/packages/5c/03/38c5c9445c6d04c7693c67aee5c37376bc8acf4ee6e3492765f42da9341b/adaptfx-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b8c4694877789da869c6b0b13dc0d31d6cd9ff243d99656abfbb1f1d8dc45fbc",
"md5": "9b3e9955391a0144dc10abcc7eb5129d",
"sha256": "71cd8e1c3556d1e0b5ee1d24e0bb416b4852d3f2964b2414b0fbffc2d880164a"
},
"downloads": -1,
"filename": "adaptfx-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9b3e9955391a0144dc10abcc7eb5129d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 37225,
"upload_time": "2023-06-20T15:01:12",
"upload_time_iso_8601": "2023-06-20T15:01:12.437198Z",
"url": "https://files.pythonhosted.org/packages/b8/c4/694877789da869c6b0b13dc0d31d6cd9ff243d99656abfbb1f1d8dc45fbc/adaptfx-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5c0338c5c9445c6d04c7693c67aee5c37376bc8acf4ee6e3492765f42da9341b",
"md5": "7f45bba1671f280053fdc993f4391119",
"sha256": "ff7e1f3aeb45dba169a0e3d4cb3ce3b6ff8024231f85f656b967d120c72d8f4f"
},
"downloads": -1,
"filename": "adaptfx-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "7f45bba1671f280053fdc993f4391119",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 3603598,
"upload_time": "2023-06-20T15:01:14",
"upload_time_iso_8601": "2023-06-20T15:01:14.788962Z",
"url": "https://files.pythonhosted.org/packages/5c/03/38c5c9445c6d04c7693c67aee5c37376bc8acf4ee6e3492765f42da9341b/adaptfx-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"vulnerabilities": []
}