diff --git a/pk_optimizer/pk1Comp.ipynb b/pk_optimizer/pk1Comp.ipynb deleted file mode 100644 index b6512f2782f88e57f65f38f39e03040a47d40c1c..0000000000000000000000000000000000000000 --- a/pk_optimizer/pk1Comp.ipynb +++ /dev/null @@ -1,168 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "# Import commands\n", - "from scipy.stats import gamma\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "#%matplotlib inline\n", - "from scipy.integrate import odeint \n", - "import math as math\n", - "\n", - "class pk1Comp:\n", - " \n", - " \"\"\"The pk1Comp object is a one compartment PK model that outputs graphs of mass of tracer over time.\"\"\"\n", - "\n", - " def __init__ (self, numParam = 4, Flow = 1, Vp = 0.1, Visf = 0.5, PS = 0.15):\n", - " \n", - " \"\"\"Initializes the model with default parameter values for flow, Vp, Visf, and PS.\n", - " Parameters\n", - " ---------- \n", - " numParam: int\n", - " numParam is the number of parameters you want to optimize for the model. Defaults to 4.\n", - " \n", - " Flow : double\n", - " Flow is the flow of plasma through the blood vessel in mL/(mL*min). Defaults to 1.\n", - " \n", - " Vp : double\n", - " Vp is the volume of plasma in mL. Defaults to 0.1.\n", - " \n", - " Visf : double\n", - " Visf is the volume of interstitial fluid in mL. Defaults to 0.5.\n", - " \n", - " PS : double\n", - " PS is the permeability-surface area constant in mL/(g*min). Defaults to 0.15. \n", - " \"\"\"\n", - " \n", - " # Declare Variables for initial conditions\n", - " self.numParam = numParam\n", - " self.Flow = Flow\n", - " self.Vp = Vp\n", - " self.Visf = Visf\n", - " self.PS = PS\n", - " C0 = 0 # Initial concentration of tracer in plasma\n", - " tmax = 10 #Time in seconds\n", - " dt = 0.1 #Time step\n", - " a = 2. # Alpha for gamma distribution\n", - " rv = gamma(a, loc = 2, scale = 0.65) #input function\n", - "\n", - " # Define the time array\n", - " time = np.arange(0, tmax + dt, dt)\n", - " \n", - " # Derivative function\n", - " def derivs(curr_vals, time):\n", - " \"\"\"Finds derivatives of ODEs.\n", - " \n", - " Parameters\n", - " ---------- \n", - " curr_vals : double[]\n", - " curr_vals it he current values of the variables we wish to \"update\" from the curr_vals list.\n", - " \n", - " time : double[]\n", - " time is our time array from 0 to tmax with timestep dt.\n", - " \n", - " Returns\n", - " -------\n", - " dc_dt : double[]\n", - " contains the derivative of concentrations with respect to time.\n", - " \"\"\"\n", - "\n", - " # Define value of input function Cin\n", - " Cin = rv.pdf(time) \n", - "\n", - " # Unpack the current values of the variables we wish to \"update\" from the curr_vals list\n", - " C = curr_vals\n", - "\n", - " # Right-hand side of odes, which are used to computer the derivative\n", - " dC_dt = flow*(Cin - C)/Vol\n", - " #Cout = C\n", - " return dC_dt\n", - " \n", - " def getPlot(self):\n", - " \"\"\"Plots the solution of the solved ODEs.\n", - " \n", - " Parameters\n", - " ---------- \n", - " self : self\n", - " Passes variables needed from self. \n", - " \"\"\"\n", - " \n", - " # Plot the results using the values stored in the solution variable, \"sol\"\n", - " # Plot Cp using the \"0\" element from the solution\n", - " plt.figure(1)\n", - " plt.plot(time, rv.pdf(time), color = 'blue', label = 'Input Function')\n", - " plt.plot(time, sol[:,0],color=\"green\", label = 'Cout')\n", - "\n", - " # Plot Cisf using the \"1\" element from the solution\n", - " #plt.plot(time, sol[:,1],color=\"purple\", label = 'Cisf')\n", - " plt.xlabel('Time [s]')\n", - " plt.ylabel('Concentration [mM]')\n", - " plt.legend(loc = 'best')\n", - " plt.grid()\n", - " \n", - " def main(self):\n", - " \"\"\"Main function to run and solve ODEs\"\"\"\n", - " \n", - " # Store the initial values in a list\n", - " init = [C0]\n", - "\n", - " # Solve the odes with odeint\n", - " sol = odeint(derivs, init, time)\n", - "\n", - " #Mass_plasma = Vp * sol[:,0] #mass of tracer in plasma\n", - " #Mass_isf = Visf * sol[:,1] #mass of tracer in isf\n", - " #Tp = Vp/(flow + PS) # mean transit time\n", - " #E = 1 - np.exp(-PS/flow) #extraction fraction\n", - " #Q = Mass_plasma + Mass_isf\n", - "\n", - " #print('The mean transit time is ' + str(Tp))\n", - " #print('The extraction fraction is ' + str(E))\n", - "\n", - " # Plot mass of tracer using the \"2\" element from the solution\n", - " #plt.figure(2)\n", - " #plt.plot(time, Mass_plasma,color=\"red\", label = 'Plasma')\n", - " # Plot mass of tracer in tissue using the \"3\" element from the solution\n", - " #plt.plot(time, Mass_isf,color=\"black\", label = 'Interstitial Space')\n", - " #plt.plot(time, Q, color=\"blue\", label = 'Total mass')\n", - " #plt.xlabel('Time [s]')\n", - " #plt.ylabel('Mass [mg]')\n", - " #plt.legend(loc = 'best')\n", - " #plt.grid()\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}