Skip to content
Open

1.1.1 #206

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .github/workflows/Blackformatter.yml

This file was deleted.

10 changes: 10 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: psf/black@stable
31 changes: 31 additions & 0 deletions .github/workflows/citests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test

on:
push:
pull_request:

jobs:
tests:
name: "Python ${{ matrix.python-version }}"
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]

steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"

- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install pipenv
pipenv install --dev
pipenv install coveralls --skip-lock

- name: Test with pytest
run: |
pipenv run pytest --cov=app
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ python:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
env:
global:
- PIPENV_VENV_IN_PROJECT=1
Expand Down
3 changes: 1 addition & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ black = "*"
pylint = "*"

[packages]
numpy = "*"

[requires]
python_version = "3.7"
python_version = "3.9"
477 changes: 258 additions & 219 deletions Pipfile.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions PyTCI/models/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Three:
""" Base 3 compartment model"""
"""Base 3 compartment model"""

def setup(self):

Expand Down Expand Up @@ -45,14 +45,14 @@ def from_clearances(self):
self.k31 = (self.k13 * self.v1) / self.v3

def give_drug(self, drug_milligrams):
""" add bolus of drug to central compartment """
"""add bolus of drug to central compartment"""
self.x1 = self.x1 + drug_milligrams / self.v1

def wait_time(self, time_seconds):
""" model distribution of drug between compartments over specified time period """
"""model distribution of drug between compartments over specified time period"""

def one_second(self):
""" time steps must be one second for accurate modelling """
"""time steps must be one second for accurate modelling"""

x1k10 = self.x1 * self.k10
x1k12 = self.x1 * self.k12
Expand All @@ -73,21 +73,21 @@ def one_second(self):
one_second(self)

def reset_concs(self, old_conc):
""" resets concentrations using python dictionary"""
"""resets concentrations using python dictionary"""
self.x1 = old_conc["ox1"]
self.x2 = old_conc["ox2"]
self.x3 = old_conc["ox3"]
self.xeo = old_conc["oxeo"]

def zero_comps(self):
""" sets all compartment concentrations to 0 """
"""sets all compartment concentrations to 0"""
self.x1 = 0
self.x2 = 0
self.x3 = 0
self.xeo = 0

def effect_bolus(self, target: float):
""" determines size of bolus needed over 10 seconds to achieve target at ttpe """
"""determines size of bolus needed over 10 seconds to achieve target at ttpe"""

# store concentrations so we can reset after search
old_conc = {"ox1": self.x1, "ox2": self.x2, "ox3": self.x3, "oxeo": self.xeo}
Expand All @@ -114,23 +114,23 @@ def effect_bolus(self, target: float):
return round(mgpersec * 10, 2)

def tenseconds(self, mgpersec: float):
""" gives set amount of drug every second for 10 seconds """
"""gives set amount of drug every second for 10 seconds"""
for _ in range(10):
self.give_drug(mgpersec)
self.wait_time(1)

return self.x1

def giveoverseconds(self, mgpersec: float, secs: float):
""" gives set amount of drug every second for user defined period"""
"""gives set amount of drug every second for user defined period"""
for _ in range(secs):
self.give_drug(mgpersec)
self.wait_time(1)

return self.x1

def plasma_infusion(self, target: float, time: int, period: int = 10):
""" returns list of infusion rates to maintain desired plasma concentration
"""returns list of infusion rates to maintain desired plasma concentration
inputs:
target: desired plasma concentration in ug/min
time: infusion duration in seconds
Expand Down Expand Up @@ -174,7 +174,7 @@ def plasma_infusion(self, target: float, time: int, period: int = 10):
return pump_instructions

def effect_target(self, target: float, time: int, period: int = 10):
""" returns list of infusion rates to maintain desired plasma concentration
"""returns list of infusion rates to maintain desired plasma concentration
inputs:
target: desired plasma concentration in units/ml
time: infusion duration in seconds
Expand Down
12 changes: 6 additions & 6 deletions PyTCI/models/dexmedetomidine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@


class Dexmed(Three):
""" base class for demedetomidine"""
"""base class for demedetomidine"""

pass


class Hannivoort(Dexmed):
def __init__(self, weight: int):
""" 3 compartment dexmedetomidine Pk model
"""3 compartment dexmedetomidine Pk model

Units:
weight(kg)

Reference:
Hannivoort, L, et al
Hannivoort, L, et al
Development of an Optimized Pharmacokinetic Model of Dexmedetomidine Using Target-controlled Infusion in Healthy Volunteers
Anesthesiology 8 2015, Vol.123, 357-367.
doi:10.1097/ALN.0000000000000740
Anesthesiology 8 2015, Vol.123, 357-367.
doi:10.1097/ALN.0000000000000740
"""

self.v1 = 1.78 * (weight / 70)
Expand Down Expand Up @@ -48,7 +48,7 @@ def __init__(self, height: int):
Dyck, JB, et al
Computer-controlled infusion of intravenous dexmedetomidine hydrochloride in adult human volunteers
Anesthesiology. 1993 May;78(5):821-8.
PMID:8098191 DOI:10.1097/00000542-199305000-00003
PMID:8098191 DOI:10.1097/00000542-199305000-00003
"""

self.v1 = 7.99
Expand Down
34 changes: 14 additions & 20 deletions PyTCI/models/propofol.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@


class Propofol(Three):
""" Base Class for Propofol 3 compartment model """
"""Base Class for Propofol 3 compartment model"""

pass


class Schnider(Propofol):
""" Implementation of the schnider model """
"""Implementation of the schnider model"""

# UNITS:
# age: years
Expand Down Expand Up @@ -44,7 +44,7 @@ def __init__(self, age, weight, height, sex):


class Marsh(Propofol):
""" Marsh 3 compartment Propofol Pk Model
"""Marsh 3 compartment Propofol Pk Model

Units required:
weight (kg)
Expand Down Expand Up @@ -113,7 +113,7 @@ class Paedfusor(Propofol):

Reference:
Absalom, A, Kenny, G
BJA: British Journal of Anaesthesia, Volume 95, Issue 1, 1 July 2005, Pages 110,
BJA: British Journal of Anaesthesia, Volume 95, Issue 1, 1 July 2005, Pages 110,
https://doi.org/10.1093/bja/aei567
"""

Expand Down Expand Up @@ -150,7 +150,7 @@ class Eleveld(Propofol):
Special methods for this model
.venous()
Switches from arterial(default) to venous targerting


.with_opiates()
models co-administration with opiates
Expand Down Expand Up @@ -193,16 +193,16 @@ def __init__(self, age: int, weight: float, height: int, sex: str):
theta18 = 0.68

def ageing(i, age):
""" ageing function"""
"""ageing function"""
return exp(i * (age - 35))

def sigmoid(x, e50, y):
""" sigmoid function from eleveld paper """
"""sigmoid function from eleveld paper"""
sig = (x ** y) / ((x ** y) + (e50 ** y))
return sig

def central(i):
""" central function """
"""central function"""
return sigmoid(i, theta12, 1)

# clearance maturation
Expand All @@ -225,13 +225,9 @@ def central(i):
v3ref = theta03

if sex == "m":
self.Q1 = (
theta04 * (weight / 70) ** 0.75 * (clmat / clmatref)
)
self.Q1 = theta04 * (weight / 70) ** 0.75 * (clmat / clmatref)
else:
self.Q1 = (
theta15 * (weight / 70) ** 0.75 * (clmat / clmatref)
)
self.Q1 = theta15 * (weight / 70) ** 0.75 * (clmat / clmatref)

self.Q2 = (
theta05 * (self.v2 / v2ref) ** 0.75 * (1 + theta16 * (1 - q3mat / q3matref))
Expand All @@ -244,19 +240,17 @@ def central(i):
self.setup()

def with_opiates(self):
""" switches the opiate parameters
using this method indicates opiates are being administered concurrently
"""switches the opiate parameters
using this method indicates opiates are being administered concurrently

"""
opiatesv3 = exp(self.theta13 * self.age)
opiatescl = exp(self.theta11 * self.age)

self.v3 *= opiatesv3
self.Q1 *= opiatescl

self.from_clearances()


self.from_clearances()

# def venous():
# """ switches the following parameters to target venous concentrations
Expand Down
8 changes: 4 additions & 4 deletions PyTCI/models/remifentanil.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class Remifentanil(Three):
""" Base Class for remifentanil models """
"""Base Class for remifentanil models"""

pass

Expand Down Expand Up @@ -48,11 +48,11 @@ class Eleveld(Remifentanil):

def __init__(self, age, weight, height, sex):
def ageing(i, age):
""" ageing function"""
"""ageing function"""
return exp(i * (age - 35))

def sigmoid(x, e50, y):
""" sigmoid function from eleveld paper """
"""sigmoid function from eleveld paper"""
sig = (x ** y) / ((x ** y) + (e50 ** y))
return sig

Expand Down Expand Up @@ -84,7 +84,7 @@ def sigmoid(x, e50, y):
if sex == "m":
Fsex = 1
elif sex == "f":
Fsex = 1 + Θ5 * sigmoid(age, 12, 6) * (1- sigmoid(age, 45, 6))
Fsex = 1 + Θ5 * sigmoid(age, 12, 6) * (1 - sigmoid(age, 45, 6))

self.v1 = v1ref * Fsize * ageing(Θ2, age)
self.v2 = v2ref * Fsize * ageing(Θ3, age) * Fsex
Expand Down
Loading