Simulator module
- class Patient(patient_characteristic: list, co_base: float = 6.5, map_base: float = 90, model_propo: str = 'Schnider', model_remi: str = 'Minto', model_bis: str = 'Bouillon', ts: float = 1, hill_param: list | None = None, random_PK: bool = False, random_PD: bool = False, co_update: bool = False, save_data_bool: bool = True)
Bases:
objectDefine a Patient class able to simulate Anesthesia process.
- Parameters:
- Patient_characteristic: list
Patient_characteristic = [age (yr), height(cm), weight(kg), gender(0: female, 1: male)]
- co_basefloat, optional
Initial cardiac output. The default is 6.5L/min.
- map_basefloat, optional
Initial Mean Arterial Pressure. The default is 90mmHg.
- model_propostr, optional
Name of the Propofol PK Model. The default is ‘Schnider’.
- model_remistr, optional
Name of the Remifentanil PK Model. The default is ‘Minto’.
- tsfloat, optional
Samplling time (s). The default is 1.
- BIS_paramlist, optional
Parameter of the BIS model (Propo Remi interaction) list [C50p_BIS, C50r_BIS, gamma_BIS, beta_BIS, E0_BIS, Emax_BIS]. The default is None.
- random_PKbool, optional
Add uncertainties in the Propodfol and Remifentanil PK models. The default is False.
- random_PDbool, optional
Add uncertainties in the BIS PD model. The default is False.
- co_updatebool, optional
Turn on the option to update PK parameters thanks to the CO value. The default is False.
- save_data_boolbool, optional
Save all interns variable at each sampling time in a data frame. The default is True.
- Attributes:
- agefloat
Age of the patient (yr).
- heightfloat
Height of the patient (cm).
- weightfloat
Weight of the patient (kg).
- genderbool
0 for female, 1 for male.
- co_basefloat
Initial cardiac output (L/min).
- map_basefloat
Initial mean arterial pressure (mmHg).
- tsfloat
Sampling time (s).
- model_propostr
Name of the propofol PK model.
- model_remistr
Name of the remifentanil PK model.
- model_bisstr
Name of the BIS PD model.
- hill_paramlist
Parameter of the BIS model (Propo Remi interaction) list [C50p_BIS, C50r_BIS, gamma_BIS, beta_BIS, E0_BIS, Emax_BIS].
- random_PKbool
Add uncertainties in the Propodfol and Remifentanil PK models.
- random_PDbool
Add uncertainties in the BIS PD model.
- co_updatebool
Turn on the option to update PK parameters thanks to the CO value.
- save_data_boolbool
Save all interns variable at each sampling time in a data frame.
- lbmfloat
Lean body mass (kg).
- propo_pkCompartmentModel
6-comparments model for Propofol.
- remi_pkCompartmentModel
5-comparments model for Remifentanil.
- nore_pkCompartmentModel
1-comparments model for Norepinephrine.
- bis_pdBIS_model
Surface-response model for bis computation.
- tol_pdTOL_model
Hierarchical model for TOL computation.
- hemo_pdHemo_PD_model
Hemodynamic model for CO and MAP computation.
- datapd.DataFrame
Dataframe containing all the intern variables at each sampling time.
- bisfloat
Bispectral index (%).
- tolfloat
Tolerance of laryngospie probability (0-1).
- cofloat
Cardiac output (L/min).
- mapfloat
Mean arterial pressure (mmHg).
- blood_volumefloat
Blood volume (L).
- bis_noise_stdfloat
Standard deviation of the BIS noise.
- co_noise_stdfloat
Standard deviation of the CO noise.
- map_noise_stdfloat
Standard deviation of the MAP noise.
- add_noise()
Add noise on the outputs of the model (except TOL).
The MAP and CO noises are considered white noise while the BIS noise is filtered. The filter of the BIS noise is a second order low pass filter with a cut-off frequency of 0.03 Hz.
- blood_loss(fluid_rate: float = 0)
Actualize the patient parameters to mimic blood loss.
- Parameters:
- fluid_ratefloat, optional
Fluid rates from blood volume (mL/min), negative is bleeding while positive is a transfusion. The default is 0.
- Returns:
- None.
- find_bis_equilibrium_with_ratio(bis_target: float, rp_ratio: float = 2) tuple[float, float]
Find the input of Propofol and Remifentanil to meet the BIS target at the equilibrium with a fixed ratio between drugs rates.
Solve the optimization problem:
\[J = (bis - bis_{target})^2\]Where \(bis\) is the BIS computed from the pharmacodynamic model. And with the constraints:
\[u_{propo} = u_{remi} * rp_{ratio}\]\[A_{propo} x_{propo} + B_{propo} u_{propo} = 0\]\[A_{remi} x_{remi} + B_{remi} u_{remi} = 0\]- Parameters:
- bis_targetfloat
BIS target (%).
- rp_ratiofloat
remifentanil over propofol rates ratio. The default is 2.
- Returns:
- u_propofloat:
Propofol infusion rate (mg/s).
- u_remifloat:
Remifentanil infusion rate (µg/s).
- find_equilibrium(bis_target: float, tol_target: float, map_target: float) tuple[float, float, float]
Find the input to meet the targeted outputs at the equilibrium.
Solve the optimization problem to find the equilibrium input for BIS - TOL:
\[min_{C_{p,es}, C_{r,es}} \frac{||BIS_{target} - BIS||^2}{100^2} + ||TOL_{target} - TOL||^2\]Then compute the concentration of Noradrenaline to meet the MAP target.
Finally, compute the input of Propofol, Remifentanil and Noradrenaline to meet the targeted concentration.
- Parameters:
- bis_targetfloat
BIS target (%).
- tol_targetfloat
TOL target ([0, 1]).
- map_target:float
MAP target (mmHg).
- Returns:
- u_propofloat:
Propofol infusion rate (mg/s).
- u_remifloat:
Remifentanil infusion rate (µg/s).
- u_norefloat:
Norepinephrine infusion rate (µg/s).
- full_sim(u_propo: array | None = None, u_remi: array | None = None, u_nore: array | None = None, x0_propo: array | None = None, x0_remi: array | None = None, x0_nore: array | None = None) DataFrame
Simulate the patient model with the given inputs.
- Parameters:
- u_proponumpy array, optional
Propofol infusion rate (mg/s).
- u_reminumpy array, optional
Remifentanil infusion rate (µg/s).
- u_norenumpy array, optional
Norepinephrine infusion rate (µg/s).
- x0_proponumpy array, optional
Initial state of the propofol PK model. The default is zeros.
- x0_reminumpy array, optional
Initial state of the remifentanil PK model. The default is zeros.
- x0_norenumpy array, optional
Initial state of the norepinephrine PK model. The default is zeros.
- Returns:
- pandas.Dataframes
Dataframe with all the data.
- init_dataframe()
Initilize the dataframe variable.
- initialized_at_given_input(u_propo: float = 0, u_remi: float = 0, u_nore: float = 0)
Initialize the patient Simulator at the given input as an equilibrium point.
For each drug, the equilibrium state is computed from the input. Then this state is used to intitialze each drug pharmacokinetic model.
- Parameters:
- u_propofloat, optional
Propofol infusion rate (mg/s). The default is 0.
- u_remifloat, optional
Remifentanil infusion rate (µg/s). The default is 0.
- u_norefloat, optional
Norepinephrine infusion rate (µg/s). The default is 0.
- Returns:
- None.
- initialized_at_maintenance(bis_target: float, tol_target: float, map_target: float) tuple[float, float, float]
Initialize the patient model at the equilibrium point for the given output value.
- Parameters:
- bis_targetfloat
BIS target (%).
- rass_targetfloat
RASS target ([0, -5]).
- map_target:float
MAP target (mmHg).
- Returns:
- u_propofloat:
Propofol infusion rate (mg/s).
- u_remifloat:
Remifentanil infusion rate (µg/s).
- u_norefloat:
Norepinephrine infusion rate (µg/s).
- one_step(u_propo: float = 0, u_remi: float = 0, u_nore: float = 0, blood_rate: float = 0, dist: list = [0, 0, 0], noise: bool = True) tuple[float, float, float, float]
Simulate one step time of the patient.
- Parameters:
- u_propofloat, optional
Propofol infusion rate (mg/s). The default is 0.
- u_remifloat, optional
Remifentanil infusion rate (µg/s). The default is 0.
- u_norefloat, optional
Norepinephrine infusion rate (µg/s). The default is 0.
- blood_ratefloat, optional
Fluid rates from blood volume (mL/min), negative is bleeding while positive is a transfusion. The default is 0.
- distlist, optional
Disturbance vector on [BIS (%), MAP (mmHg), CO (L/min)]. The default is [0]*3.
- noisebool, optional
bool to add measurement noise on the outputs. The default is True.
- Returns:
- bisfloat
Bispectral index(%).
- cofloat
Cardiac output (L/min).
- mapfloat
Mean arterial pressure (mmHg).
- tolfloat
Tolerance of Laringoscopy index (0-1).
- save_data(inputs: list = [0, 0, 0])
Save all current intern variable as a new line in self.dataframe.
PK models module
- class CompartmentModel(Patient_characteristic: list, lbm: float, drug: str, model: str | None = None, ts: float = 1, random: bool = False, x0: list | None = None, opiate=True, measurement='arterial')
Bases:
objectPKmodel class modelize the PK model of propofol, remifentanil or norepinephrine drug. Simulate the drug distribution in the body.
Use a 6 compartement model for propofol, a 5 compartement model for remifentanil, and a 1 compartement model for norepinephrine. The model is a LTI model with the form:
\[x(k+1)= Ax(k) + Bu(k)\]\[y(k) = Cx(k)\]The state vector is the concentration of the drug in each compartement in the following order: blood, muscles, fat, BIS effect-site, MAP effect-site 1, MAP effect-site 2. The output of the model is the BIS effect-site concentration.
- Parameters:
- Patient_characteristic: list
Patient_characteristic = [age (yr), height(cm), weight(kg), gender(0: female, 1: male)]
- lbmfloat
lean body mass index.
- drugstr
can be “Propofol”, “Remifentanil” or “Norepinephrine”.
- modelstr, optional
Could be “Schnider” [Schnider1999], “Marsh_initial”[Marsh1991], “Marsh_modified”[Struys2000], “Shuttler”[Schuttler2000] or “Eleveld”[Eleveld2018] for Propofol. “Minto”[Minto1997], “Eleveld”[Eleveld2017] for Remifentanil. only “Beloeil”[Beloeil2005] for Norepinephrine. The default is “Minto” for Remifentanil and “Schnider” for Propofol.
- tsfloat, optional
Sampling time, in s. The default is 1.
- randombool, optional
bool to introduce uncertainties in the model. The default is False.
- x0list, optional
Initial concentration of the compartement model. The default is np.ones([4, 1])*1e-4.
- opiatebool, optional
For Elelevd model for propofol, specify if their is a co-administration of opiate (Remifentantil) in the same time. The default is True.
- measurementstr, optional
For Elelevd model for propofol, specify the measuremnt place for blood concentration. Can be either ‘arterial’ or ‘venous’. The default is ‘arterial’.
- Attributes:
- tsfloat
Sampling time, in s.
- drugstr
can be “Propofol”, “Remifentanil” or “Norepinephrine”.
- A_initlist
Initial value of the matrix A.
- B_initlist
Initial value of the matrix B.
- v1float
Volume of the first compartement.
- continuous_syscontrol.StateSpace
Continuous state space model.
- discrete_syscontrol.StateSpace
Discrete state space model.
- xlist
State vector.
- ylist
Output vector (hypnotic effect site concentration).
References
[Schnider1999]T. W. Schnider et al., “The Influence of Age on Propofol Pharmacodynamics,” Anesthesiology, vol. 90, no. 6, pp. 1502-1516., Jun. 1999, doi: 10.1097/00000542-199906000-00003.
[Marsh1991]B. Marsh, M. White, N. morton, and G. N. C. Kenny, “Pharmacokinetic model Driven Infusion of Propofol in Children,” BJA: British Journal of Anaesthesia, vol. 67, no. 1, pp. 41–48, Jul. 1991, doi: 10.1093/bja/67.1.41.
[Struys2000]M. M. R. F. Struys et al., “Comparison of Plasma Compartment versus Two Methods for Effect Compartment–controlled Target-controlled Infusion for Propofol,” Anesthesiology, vol. 92, no. 2, p. 399, Feb. 2000, doi: 10.1097/00000542-200002000-00021.
[Schuttler2000]J. Schüttler and H. Ihmsen, “Population Pharmacokinetics of Propofol: A Multicenter Study,” Anesthesiology, vol. 92, no. 3, pp. 727–738, Mar. 2000, doi: 10.1097/00000542-200003000-00017.
[Eleveld2018]D. J. Eleveld, P. Colin, A. R. Absalom, and M. M. R. F. Struys, “Pharmacokinetic–pharmacodynamic model for propofol for broad application in anaesthesia and sedation” British Journal of Anaesthesia, vol. 120, no. 5, pp. 942–959, mai 2018, doi:10.1016/j.bja.2018.01.018.
[Minto1997]C. F. Minto et al., “Influence of Age and Gender on the Pharmacokinetics and Pharmacodynamics of Remifentanil: I. Model Development,” Anesthesiology, vol. 86, no. 1, pp. 10–23, Jan. 1997, doi: 10.1097/00000542-199701000-00004.
[Eleveld2017]D. J. Eleveld et al., “An Allometric Model of Remifentanil Pharmacokinetics and Pharmacodynamics,” Anesthesiology, vol. 126, no. 6, pp. 1005–1018, juin 2017, doi: 10.1097/ALN.0000000000001634.
[Beloeil2005]H. Beloeil, J.-X. Mazoit, D. Benhamou, and J. Duranteau, “Norepinephrine kinetics and dynamics in septic shock and trauma patients,” BJA: British Journal of Anaesthesia, vol. 95, no. 6, pp. 782–788, Dec. 2005, doi: 10.1093/bja/aei259.
- full_sim(u: list, x0: array | None = None) list
Simulate PK model with a given input.
- Parameters:
- ulist
Infusion rate (mg/s for Propofol, µg/s for Remifentanil and Norepinephrine).
- x0numpy array, optional
Initial state. The default is None.
- Returns:
- numpy array
List of the states value during the simulation. (µg/mL for Propofol and ng/mL for Remifentanil and Norepinephrine).
- one_step(u: float) list
Simulate one step of PK model.
\[x^+ = Ax + Bu\]\[y = Cx\]- Parameters:
- ufloat
Infusion rate (mg/s for Propofol, µg/s for Remifentanil).
- Returns:
- numpy array
Actual effect site concentration (µg/mL for Propofol and ng/mL for Remifentanil and Norepinephrine).
- update_param_CO(CO_ratio: float)
Update PK coefficient with a linear function of Cardiac output value.
- Parameters:
- COfloat
Ratio of Current CO relatively to initial CO.
- Returns:
- None.
- update_param_blood_loss(v_ratio: float)
Update PK coefficient to mimic a blood loss.
Update the blodd volume compartment
- Parameters:
- v_ratiofloat
blood volume as a fraction of init volume, 1 mean no loss, 0 mean 100% loss.
- Returns:
- None.
PD models module
- class BIS_model(hill_model: str = 'Bouillon', hill_param: list | None = None, random: bool = False)
Bases:
objectSurface Response model to link Propofol and Remifentanil blood concentration to BIS.
equation:
\[BIS = E0 + Emax * \frac{U^\gamma}{1+U^\gamma}\]\[U = \frac{U_p + U_r}{1 - \beta \theta + \beta \theta^2}\]\[U_p = \frac{C_{p,es}}{C_{p,50}}\]\[U_r = \frac{C_{r,es}}{C_{r,50}}\]\[\theta = \frac{U_p}{U_r+U_p}\]- Parameters:
- hill_modelstr, optional
‘Bouillon’ [Bouillon2004] and ‘Aubouin’ [Aubouin2023] are available. Ignored if hill_param is specified. Default is ‘Bouilllon’.
- hill_paramlist, optional
Parameter of the Hill model (Propo Remi interaction) list [c50p_BIS, c50r_BIS, gamma_BIS, beta_BIS, E0_BIS, Emax_BIS]:
c50p_BIS : Concentration at half effect for propofol effect on BIS (µg/mL)
c50r_BIS : Concentration at half effect for remifentanil effect on BIS (ng/mL)
gamma_BIS : slope coefficient for the BIS model,
beta_BIS : interaction coefficient for the BIS model,
E0_BIS : initial BIS,
Emax_BIS : max effect of the drugs on BIS.
The default is None.
- randombool, optional
Add uncertainties in the parameters. Ignored if Hill_cruv is specified. The default is False.
- tsfloat, optional
Sampling time, in s. The default is 1.
- Attributes:
- c50pfloat
Concentration at half effect for propofol effect on BIS (µg/mL).
- c50rfloat
Concentration at half effect for remifentanil effect on BIS (ng/mL).
- gammafloat
slope coefficient for the BIS model.
- betafloat
interaction coefficient for the BIS model.
- E0float
initial BIS.
- Emaxfloat
max effect of the drugs on BIS.
- hill_paramlist
Parameter of the Hill model (Propo Remi interaction) list [c50p_BIS, c50r_BIS, gamma_BIS, beta_BIS, E0_BIS, Emax_BIS]
- c50p_initfloat
Initial value of c50p, used for blood loss modelling.
References
[Bouillon2004]T. W. Bouillon et al., “Pharmacodynamic Interaction between Propofol and Remifentanil Regarding Hypnosis, Tolerance of Laryngoscopy, Bispectral Index, and Electroencephalographic Approximate Entropy,” Anesthesiology, vol. 100, no. 6, pp. 1353–1372, Jun. 2004, doi: 10.1097/00000542-200406000-00006.
[Aubouin2023]A. Aubouin et al., “Comparison of Multiple Kalman Filter and Moving Horizon Estimator for the Anesthesia Process” draft 2023.
- compute_bis(c_es_propo: float, c_es_remi: float) float
Compute BIS function from Propofol and Remifentanil effect site concentration.
- Parameters:
- cepfloat
Propofol effect site concentration µg/mL.
- cerfloat
Remifentanil effect site concentration ng/mL
- Returns:
- BISfloat
Bis value.
- inverse_hill(BIS: float, c_es_remi: float = 0) float
Compute Propofol effect site concentration from BIS and Remifentanil effect site concentration.
- Parameters:
- BISfloat
BIS value.
- cerfloat, optional
Effect site Remifentanil concentration (ng/mL). The default is 0.
- Returns:
- cepfloat
Effect site Propofol concentration (µg/mL).
- plot_surface()
Plot the 3D-Hill surface of the BIS related to Propofol and Remifentanil effect site concentration.
- update_param_blood_loss(v_ratio: float)
Update PK coefficient to mimic a blood loss.
Update the c50p parameters thanks to the blood volume ratio. The values are estimated from [Johnson2003].
- Parameters:
- v_lossfloat
blood volume as a fraction of init volume, 1 mean no loss, 0 mean 100% loss.
- Returns:
- None.
References
[Johnson2003]K. B. Johnson et al., “The Influence of Hemorrhagic Shock on Propofol: A Pharmacokinetic and Pharmacodynamic Analysis,” Anesthesiology, vol. 99, no. 2, pp. 409–420, Aug. 2003, doi: 10.1097/00000542-200308000-00023.
- class Hemo_PD_model(nore_param: list | None = None, propo_param: list | None = None, remi_param: list | None = None, random: bool = False, co_base: float = 6.5, map_base: float = 90)
Bases:
objectModelize the effect of Propofol, Remifentanil, Norepinephrine on Mean Arterial Pressure and Cardiac Output.
Use the addition of sigmoid curve to model the effect of each drugs on MAP and CO. The following articles are used to define the parameters of the model:
Norepinephrine to MAP: [Beloeil2005]
Noepinephrine to CO: [Monnet2011]
Propofol to MAP: [Jeleazcov2011]
Propofol to CO: [Fairfield1991]
Remifentanil to MAP: [Standing2010]
Remifentanil to CO: [Chanavaz2005]
- Parameters:
- nore_paramlist, optional
List of hill curve parameters for Norepinephrine action [Emax_map, c50_map, gamma_map, Emax_co, c50_co, gamma_co]. The default is None.
- propo_paramlist, optional
List of hill curve parameters for Propofol action [emax_SAP, emax_DAP, c50_map_1, c50_map_2, gamma_map_1, gamma_map_2, Emax_co, c50_co, gamma_co]. The default is None.
- remi_paramlist, optional
List of hill curve parameters for Relifentanil action [Emax_map, c50_map, gamma_map, Emax_co, c50_co, gamma_co]. The default is None.
- randombool, optional
Add uncertainties in the parameters. The default is False.
- co_base: float, optional
Baseline Cardiac output (L/min). The default is 6.5 L/min.
- map_base: float, optional
Baseline mean arterial pressure (mmHg). The default is 90mmHg.
- Attributes:
- co_basefloat
Baseline cardiac output.
- map_basefloat
Baseline mean arterial pressure.
- emax_nore_mapfloat
Maximal effect of Norepinephrine on MAP.
- c50_nore_mapfloat
Concentration of Norepinephrine that produce half of the maximal effect on MAP.
- gamma_nore_mapfloat
Slope of the sigmoid curve for Norepinephrine effect on MAP.
- emax_nore_cofloat
Maximal effect of Norepinephrine on CO.
- c50_nore_cofloat
Concentration of Norepinephrine that produce half of the maximal effect on CO.
- gamma_nore_cofloat
Slope of the sigmoid curve for Norepinephrine effect on CO.
- emax_propo_SAPfloat
Maximal effect of Propofol on SAP.
- emax_propo_DAPfloat
Maximal effect of Propofol on DAP.
- emax_propo_cofloat
Maximal effect of Propofol on CO.
- c50_propo_map_1float
Concentration of Propofol that produce half of the maximal effect on MAP.
- c50_propo_map_2float
Concentration of Propofol that produce half of the maximal effect on MAP.
- gamma_propo_map_1float
Slope of the sigmoid curve for Propofol effect on MAP.
- gamma_propo_map_2float
Slope of the sigmoid curve for Propofol effect on MAP.
- c50_propo_cofloat
Concentration of Propofol that produce half of the maximal effect on CO.
- gamma_propo_cofloat
Slope of the sigmoid curve for Propofol effect on CO.
- emax_remi_mapfloat
Maximal effect of Remifentanil on MAP.
- emax_remi_cofloat
Maximal effect of Remifentanil on CO.
- c50_remi_mapfloat
Concentration of Remifentanil that produce half of the maximal effect on MAP.
- gamma_remi_mapfloat
Slope of the sigmoid curve for Remifentanil effect on MAP.
- c50_remi_cofloat
Concentration of Remifentanil that produce half of the maximal effect on CO.
- gamma_remi_cofloat
Slope of the sigmoid curve for Remifentanil effect on CO.
- mapfloat
Mean arterial pressure.
- cofloat
Cardiac output.
References
[Beloeil2005]H. Beloeil, J.-X. Mazoit, D. Benhamou, and J. Duranteau, “Norepinephrine kinetics and dynamics in septic shock and trauma patients,” BJA: British Journal of Anaesthesia, vol. 95, no. 6, pp. 782–788, Dec. 2005, doi: 10.1093/bja/aei261.
[Monnet2011]X. Monnet, J. Jabot, J. Maizel, C. Richard, and J.-L. Teboul, “Norepinephrine increases cardiac preload and reduces preload dependency assessed by passive leg raising in septic shock patients” Critical Care Medicine, vol. 39, no. 4, p. 689, Apr. 2011, doi: 10.1097/CCM.0b013e318206d2a3.
[Jeleazcov2011]C. Jeleazcov, M. Lavielle, J. Schüttler, and H. Ihmsen, “Pharmacodynamic response modelling of arterial blood pressure in adult volunteers during propofol anaesthesia,” BJA: British Journal of Anaesthesia, vol. 115, no. 2, pp. 213–226, Aug. 2015, doi: 10.1093/bja/aeu553.
[Fairfield1991]J. E. Fairfield, A. Dritsas, and R. J. Beale, “HAEMODYNAMIC EFFECTS OF PROPOFOL: INDUCTION WITH 2.5 MG KG-1,” British Journal of Anaesthesia, vol. 67, no. 5, pp. 618–620, Nov. 1991, doi: 10.1093/bja/67.5.618.
[Standing2010]J. F. Standing, G. B. Hammer, W. J. Sam, and D. R. Drover, “Pharmacokinetic–pharmacodynamic modeling of the hypotensive effect of remifentanil in infants undergoing cranioplasty,” Pediatric Anesthesia, vol. 20, no. 1, pp. 7–18, 2010, doi: 10.1111/j.1460-9592.2009.03174.x.
- compute_hemo(c_es_propo: list, c_es_remi: float, c_es_nore: float) tuple[float, float]
Compute current MAP and CO using addition of hill curv, one for each drugs.
- Parameters:
- c_es_propolist
Propofol concentration on both hemodynamic effect site concentration µg/mL.
- c_es_remifloat
Remifentanil hemodynamic effect site concentration µg/mL.
- c_es_norefloat
Norepinephrine hemodynamic effect site concentration µg/mL.
- Returns:
- mapfloat
Mean arterial pressure (mmHg), without blood loss.
- cofloat
Cardiac output (L/min), without blood loss.
- class TOL_model(model: str = 'Bouillon', model_param: list | None = None, random: bool = False)
Bases:
objectHierarchical model to link druf effect site concentration to Tolerance of Laringoscopy.
The equation are:
\[postopioid = preopioid * \left(1 - \frac{C_{r,es}^{\gamma_r}}{C_{r,es}^{\gamma_r} + (C_{r,50} preopioid)^{\gamma_r}}\right)\]\[TOL = \frac{C_{p,es}^{\gamma_p}}{C_{p,es}^{\gamma_p} + (C_{p,50} postopioid)^{\gamma_p}}\]- Parameters:
- modelstr, optional
Only ‘Bouillon’ is available. Ignored if model_param is specified. The default is ‘Bouillon’.
- model_paramlist, optional
Model parameters, model_param = [c50p, c50p, gammaP, gammaR, Preopioid intensity]. The default is None.
- randombool, optional
Add uncertainties in the parameters. Ignored if model_param is specified. The default is False.
- Attributes:
- c50pfloat
Concentration at half effect for propofol effect on BIS (µg/mL).
- c50rfloat
Concentration at half effect for remifentanil effect on BIS (ng/mL).
- gamma_pfloat
Slope of the Hill function for propofol effect on TOL.
- gamma_rfloat
Slope of the Hill function for remifentanil effect on TOL.
- pre_intensityfloat
Preopioid intensity.
- compute_tol(c_es_propo: float, c_es_remi: float) float
Return TOL from Propofol and Remifentanil effect site concentration.
Compute the output of the Hirarchical model to predict TOL from Propofol and Remifentanil effect site concentration. TOL = 1 mean very relaxed and will tolerate laryngoscopie while TOL = 0 mean fully awake and will not tolerate.
- Parameters:
- cepfloat
Propofol effect site concentration µg/mL.
- cerfloat
Remifentanil effect site concentration ng/mL
- Returns:
- TOLfloat
TOL value.
- plot_surface()
Plot the 3D-Hill surface of the BIS related to Propofol and Remifentanil effect site concentration.
- fsig(x, c50, gam)
Disturbances module
- compute_disturbances(time: float, dist_profil: str = 'realistic', start_step: float = 600, end_step: float = 1200) list
Give the value of the distubance profil for a given time.
- Parameters:
- timefloat
Time: in seconde.
- dist_profilstr, optional
disturbance profil, can be: ‘realistic’, ‘simple’, ‘step’ or “null”. The default is ‘realistic’.
- start_stepfloat, optional
start time of the step distuebance (seconds). The default is 600s.
- end_stepfloat, optional
End time of the step distuebance (seconds). The default is 1200s.
- Returns:
- list
dist_bis, dist_map, dist_co: respectively the additive disturbance to add to the BIS, MAP and CO signals.
Metrics module
- compute_control_metrics(time: list, bis: list, phase: str = 'maintenance', start_step: float = 600, end_step: float = 1200)
Compute metrics for closed loop anesthesia.
This function compute the control metrics initially proposed in [Ionescu2008].
- Parameters:
- timelist
List of time value (s).
- bislist
List of BIS value over time.
- phasestr, optional
Control phase, can be “maintenance”, ‘induction” or “total”. The default is ‘maintenance’.
- start_step: float, optional
Start time of the step disturbance, for maintenance and total phase. The default is 600s.
- end_step: float, optional
End time of the step disturbance, for maintenance and total phase. The default is 1200s.
- Returns:
- dfpd.DataFrame
Dataframe containing the computed metrics: TT : float
Observed time-to-target (in minute) required for reaching first time the target interval of [55,45] BIS values.
- BIS_NADIR: float
for “induction” or “total” phase. The lowest observed BIS value during induction phase.
- ST10: float
for “induction” or “total” phase. Settling time (in minute) on the reference BIS value, defined within ± 5BIS(i.e., between 45 and 55 BIS)and stay within this BIS range.
- ST20: float
for “induction” or “total” phase. Settling time (in minute) on the reference BIS value, defined within ± 10BIS(i.e., between 40 and 60 BIS) and stay within this BIS range.
- US: float
for “induction” or “total” phase. Undershoot, defined as the BIS value that exceeds the limit of the defined BIS interval, namely, the 45 BIS value.
- TTpfloat
Time to target (in minute) after the positive step disturbance.
- BIS_NADIRp: float
for “maintenance” or “total” phase. Minimum BIS vamue after the positive step disturbance.
- TTpn: float
for “maintenance” or “total” phase. Time to target (in minute) after the negative step disturbance.
- BIS_NADIRn: float
for “maintenance” or “total” phase. Maximum BIS vamue after the negative step disturbance.
References
[Ionescu2008]C. M. Ionescu, R. D. Keyser, B. C. Torrico, T. D. Smet, M. M. Struys, and J. E. Normey-Rico, “Robust Predictive Control Strategy Applied for Propofol Dosing Using BIS as a Controlled Variable During Anesthesia,” IEEE Transactions on Biomedical Engineering, vol. 55, no. 9, pp. 2161–2170, Sep. 2008, doi: 10.1109/TBME.2008.923142.
- intergal_absolut_error(time: list, bis: list, bis_target: float = 50)
Compute the integral of the absolute error.
This function compute the integral of the absolute error between the BIS value and the target value.
- Parameters:
- timelist
List of time value (s).
- bislist
List of BIS value over time.
- bis_targetfloat, optional
Target BIS value. The default is 50.
- Returns:
- IAEfloat
Integral of the absolute error.
- new_metrics_induction(time: list, bis: list)
Compute new metrics for induction of closed loop anesthesia.
This function compute new metrics for closed loop anesthesia.
- Parameters:
- timelist
List of time value (s).
- bislist
List of BIS value over time.
- Returns:
- dfpd.DataFrame
Dataframe containing the computed metrics: IAE : float
Integral of the absolute error.
- Sleep_Timefloat
Time to reach BIS < 60 and stay below 60 (minutes).
- Low BIS timefloat
Time passed with BIS < 40 (seconds).
- Lowest BISfloat
Lowest BIS value.
- Settling timefloat
Time to reach BIS < 60 and stay within [40, 60] (minutes).
- new_metrics_maintenance(time: list, bis: list)
Compute new metrics for maintenance of closed loop anesthesia.
- Parameters:
- timelist
List of time value (s).
- bislist
List of BIS value over time.
- Returns:
- dfpd.DataFrame
Dataframe containing the computed metrics: IAE : float
Integral of the absolute error.
- Time out of rangefloat
Time passed with BIS out of [40, 60] (seconds).
- Lowest BISfloat
Lowest BIS value.
- Highest BISfloat
Highest BIS value.
TCI controller module
- class TCIController(patient_info: list, drug_name: str, model_used: str, drug_concentration: float = 10, maximum_rate: float = 500, sampling_time: float = 1, control_time: float = 10, target_compartement: str = 'effect_site')
Bases:
objectImplement the control algorithm coded in the TCI device Orchestra PRIMUS, from [Shafer1992].
Warning: This code has been retro enginering and does not came from an official source.
- Parameters:
- patient_infolist
Patient information = [age (yr), height (cm), weight (kg), gender( 0= female, 1 = male)].
- drug_namestr
Can be either ‘Propofol’ or ‘Remifentanil’.
- drug_concentrationfloat
drug concentration in the seringue (mg/ml for Propofol and µg/ml for remifentanil).
- model_usedstr
Could be “Minto”, “Eleveld” for Remifentanil, “Schnider”, “Marsh_initial”, “Marsh_modified”, “Shuttler” or “Eleveld” for Propofol.
- maximum_ratefloat
Maximum drug rate in ml/hr.
- sampling_timefloat, optional
Sampling time of the model for the calculs. The default is 1s.
- control_timefloat, optional
Sampling time of the controller, must be a multiple of the sampling time. The default is 10s.
- target_compartementstr, optional
Can be either “plasma” or “effect_site”. The default is ‘effect_site’.
- Attributes:
- sampling_timefloat
Sampling time of the model for the calculs.
- control_timefloat
Sampling time of the controller.
- drug_concentrationfloat
drug concentration in the seringue (mg/ml for Propofol and µg/ml for remifentanil).
- target_idint
index of the target compartment in the state vector.
- infusion_maxfloat
Maximum drug rate in mg/s or µg/s.
- Adnp.array
Discretized state matrix of the mode with the sampling time of the model.
- Bdnp.array
Discretized input matrix of the model.
- Ad_controlnp.array
Discretized state matrix of the model with the sampling time of the controller.
- Bd_controlnp.array
Discretized input matrix of the model with the sampling time of the controller.
- Celist
List of the effect site concentration after a 10s infusion.
- infusion_ratefloat
Last control move chosen.
- xnp.array
Array to store the patient state at simulation time.
- targetfloat
Target concentration.
References
[Shafer1992]Shafer and K. M. Gregg, “Algorithms to rapidly achieve and maintain stable drug concentrations at the site of drug effect with a computer-controlled infusion pump,”0 Journal of Pharmacokinetics and Biopharmaceutics, vol. 20, no. 2, pp. 147–169, Apr. 1992, doi: 10.1007/BF01070999.
- one_step(target: float = 0) float
Implement one_step of the model. It must be called each sampling time.
- Parameters:
- targetfloat, optional
target concentration (µg/ml for propofol, ng/ml for Remifentanil). The default is 0.
- Returns:
- infusion rate: float
infusion rate in ml/hr.