Module pkGUI
Expand source code
#!/usr/bin/env python
# coding: utf-8
# In[9]:
#Import Everything
class pkGUI:
"""The pkGUI object creates a GUI of size x by y to display the optimization of parameters for PK models."""
def __init__ (self, xdim = 512, ydim = 320, numParam = 4, Flow = 1, Vp = 0.1, Visf = 0.5, PS = 0.15):
"""Initializes the GUI with default size 512 by 320 pixels and one button to start optimization.
Parameters
----------
xdim : int
xdim is used for defining the x dimension of your GUI size.
ydim : int
ydim is used for defining the y dimension of your GUI size.
numParam: int
numParam is the number of parameters you want to optimize for the model. Defaults to 4.
Flow : double
Flow is the flow of plasma through the blood vessel in mL/(mL*min). Defaults to 1.
Vp : double
Vp is the volume of plasma in mL. Defaults to 0.1.
Visf : double
Visf is the volume of interstitial fluid in mL. Defaults to 0.5.
PS : double
PS is the permeability-surface area constant in mL/(g*min). Defaults to 0.15.
"""
self.xdim = xdim
self.ydim = ydim
self.numParam = numParam
self.Flow = Flow
self.Vp = Vp
self.Visf = Visf
self.PS = PS
#build GUI with dims x, y
#build button in center named Optimize!
def slider(numParam = 4, labels = ['Flow', 'Vp', 'Visf', 'PS']):
"""Adds a slider for each parameter to the GUI with labels as their names.
Parameters
----------
numParam : int
numParam is defaulted to 4 (self.numParam) and is used for defining the number of sliders in th GUI.
labels : str[]
labels are defaulted to Flow, Vp, Visf, and PS, and are used for naming the sliders.
"""
#Creates and sliders with names for each model.
#EVENT: move sliders = move parameter values and change model
def IOBoxes(numParam = 4):
"""Creates text boxes for initial guesses and output text boxes for final parameter values.
Parameters
----------
numParam : int
numParam is defaulted to 4 (self.numParam) and is used for defining the number of text boxes in th GUI.
"""
#Creates text boxes for initial guesses
#Creates text boxes for displaying output (optimized) values.
def passValues(paramName, paramVal):
"""If a parameter is changed from slider, it will pass the changes to the Model object and text boxes.
Parameters
----------
paramName : str
paramName is the name of the parameter that changed.
paramVal : double
paramVal is the new value of the parameter that is passed to the model and text boxes.
"""
self.paramName = paramVal
#update text box output
#update model
def getValues(paramName, model):
"""Get the parameter value of paramName from model model.
Parameters
----------
paramName : str
paramName is the name of the parameter that changed.
model : model object
model is the model you want to get values from.
"""
#call object for value
def dispModel(objModel):
"""Displays a Model object in GUI.
Parameters
----------
objModel : Model object
objModel will be either a 1 Comp or 2 Comp model and will be displayed in the GUI.
"""
#Displays model in GUI
# In[ ]:
Classes
class pkGUI (xdim=512, ydim=320, numParam=4, Flow=1, Vp=0.1, Visf=0.5, PS=0.15)
-
The pkGUI object creates a GUI of size x by y to display the optimization of parameters for PK models.
Initializes the GUI with default size 512 by 320 pixels and one button to start optimization. Parameters
xdim
:int
- xdim is used for defining the x dimension of your GUI size.
ydim
:int
- ydim is used for defining the y dimension of your GUI size.
numParam
:int
- numParam is the number of parameters you want to optimize for the model. Defaults to 4.
Flow
:double
- Flow is the flow of plasma through the blood vessel in mL/(mL*min). Defaults to 1.
Vp
:double
- Vp is the volume of plasma in mL. Defaults to 0.1.
Visf
:double
- Visf is the volume of interstitial fluid in mL. Defaults to 0.5.
PS
:double
- PS is the permeability-surface area constant in mL/(g*min). Defaults to 0.15.
Expand source code
class pkGUI: """The pkGUI object creates a GUI of size x by y to display the optimization of parameters for PK models.""" def __init__ (self, xdim = 512, ydim = 320, numParam = 4, Flow = 1, Vp = 0.1, Visf = 0.5, PS = 0.15): """Initializes the GUI with default size 512 by 320 pixels and one button to start optimization. Parameters ---------- xdim : int xdim is used for defining the x dimension of your GUI size. ydim : int ydim is used for defining the y dimension of your GUI size. numParam: int numParam is the number of parameters you want to optimize for the model. Defaults to 4. Flow : double Flow is the flow of plasma through the blood vessel in mL/(mL*min). Defaults to 1. Vp : double Vp is the volume of plasma in mL. Defaults to 0.1. Visf : double Visf is the volume of interstitial fluid in mL. Defaults to 0.5. PS : double PS is the permeability-surface area constant in mL/(g*min). Defaults to 0.15. """ self.xdim = xdim self.ydim = ydim self.numParam = numParam self.Flow = Flow self.Vp = Vp self.Visf = Visf self.PS = PS #build GUI with dims x, y #build button in center named Optimize! def slider(numParam = 4, labels = ['Flow', 'Vp', 'Visf', 'PS']): """Adds a slider for each parameter to the GUI with labels as their names. Parameters ---------- numParam : int numParam is defaulted to 4 (self.numParam) and is used for defining the number of sliders in th GUI. labels : str[] labels are defaulted to Flow, Vp, Visf, and PS, and are used for naming the sliders. """ #Creates and sliders with names for each model. #EVENT: move sliders = move parameter values and change model def IOBoxes(numParam = 4): """Creates text boxes for initial guesses and output text boxes for final parameter values. Parameters ---------- numParam : int numParam is defaulted to 4 (self.numParam) and is used for defining the number of text boxes in th GUI. """ #Creates text boxes for initial guesses #Creates text boxes for displaying output (optimized) values. def passValues(paramName, paramVal): """If a parameter is changed from slider, it will pass the changes to the Model object and text boxes. Parameters ---------- paramName : str paramName is the name of the parameter that changed. paramVal : double paramVal is the new value of the parameter that is passed to the model and text boxes. """ self.paramName = paramVal #update text box output #update model def getValues(paramName, model): """Get the parameter value of paramName from model model. Parameters ---------- paramName : str paramName is the name of the parameter that changed. model : model object model is the model you want to get values from. """ #call object for value def dispModel(objModel): """Displays a Model object in GUI. Parameters ---------- objModel : Model object objModel will be either a 1 Comp or 2 Comp model and will be displayed in the GUI. """
Methods
def IOBoxes(numParam=4)
-
Creates text boxes for initial guesses and output text boxes for final parameter values. Parameters
numParam
:int
- numParam is defaulted to 4 (self.numParam) and is used for defining the number of text boxes in th GUI.
Expand source code
def IOBoxes(numParam = 4): """Creates text boxes for initial guesses and output text boxes for final parameter values. Parameters ---------- numParam : int numParam is defaulted to 4 (self.numParam) and is used for defining the number of text boxes in th GUI. """
def dispModel(objModel)
-
Displays a Model object in GUI. Parameters
objModel
:Model
object
- objModel will be either a 1 Comp or 2 Comp model and will be displayed in the GUI.
Expand source code
def dispModel(objModel): """Displays a Model object in GUI. Parameters ---------- objModel : Model object objModel will be either a 1 Comp or 2 Comp model and will be displayed in the GUI. """
def getValues(paramName, model)
-
Get the parameter value of paramName from model model.
Parameters
paramName
:str
- paramName is the name of the parameter that changed.
model
:model
object
- model is the model you want to get values from.
Expand source code
def getValues(paramName, model): """Get the parameter value of paramName from model model. Parameters ---------- paramName : str paramName is the name of the parameter that changed. model : model object model is the model you want to get values from. """
def passValues(paramName, paramVal)
-
If a parameter is changed from slider, it will pass the changes to the Model object and text boxes. Parameters
paramName
:str
- paramName is the name of the parameter that changed.
paramVal
:double
- paramVal is the new value of the parameter that is passed to the model and text boxes.
Expand source code
def passValues(paramName, paramVal): """If a parameter is changed from slider, it will pass the changes to the Model object and text boxes. Parameters ---------- paramName : str paramName is the name of the parameter that changed. paramVal : double paramVal is the new value of the parameter that is passed to the model and text boxes. """ self.paramName = paramVal
def slider(numParam=4, labels=['Flow', 'Vp', 'Visf', 'PS'])
-
Adds a slider for each parameter to the GUI with labels as their names. Parameters
numParam
:int
- numParam is defaulted to 4 (self.numParam) and is used for defining the number of sliders in th GUI.
labels
:str
[]- labels are defaulted to Flow, Vp, Visf, and PS, and are used for naming the sliders.
Expand source code
def slider(numParam = 4, labels = ['Flow', 'Vp', 'Visf', 'PS']): """Adds a slider for each parameter to the GUI with labels as their names. Parameters ---------- numParam : int numParam is defaulted to 4 (self.numParam) and is used for defining the number of sliders in th GUI. labels : str[] labels are defaulted to Flow, Vp, Visf, and PS, and are used for naming the sliders. """