Patient

class Patient(patient_characteristic: list, co_base: float = None, hr_base: float = None, map_base: float = None, model_propo: str = 'Schnider', model_remi: str = 'Minto', model_nore: str = 'Beloeil', model_atra: str = 'WardWeatherleyLago', model_bis: str = 'Bouillon', model_loc: str = 'Kern', model_tof: str = 'Weatherley', model_hemo: str = 'Su', ts: float = 1, hill_param: list = None, atracurium_model_params: dict = None, atracurium_hill_params: dict = None, random_PK: bool = False, random_PD: bool = False, co_update: bool = False, truncated: bool = None)

Bases: object

Define a Patient class able to simulate Anesthesia process.

Parameters:
Patient_characteristic: list

Patient_characteristic = [age (yr), height(cm), weight(kg), sex(0: female, 1: male)]

co_basefloat, optional

Initial cardiac output. The default is 6.5L/min.

hr_basefloat, optional

Initial heart rate. The default is 60 beat/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’.

model_norestr, optional

Name of the norepinephrine PK Model. The default is ‘Beloeil’.

model_atracuriumstr, optional

Name of the atracurium PK Model. The default is ‘WardWeatherleyLago’.

model_bisstr, optional

Name of the BIS PD Model. The default is ‘Bouillon’.

model_locstr, optional

Name of the LOC PD Model. The default is ‘Kern’

model_tof,str, optional

Name of the TOF PD Model. The default is ‘Weatherley’.

model_hemostr, optional

Name of the hemodynamic model. The default is ‘Su’.

tsfloat, optional

Sampling time (s). The default is 1.

hill_paramlist

Parameter of the BIS model (Propo Remi interaction) list [C50p_BIS, C50r_BIS, gamma_BIS, beta_BIS, E0_BIS, Emax_BIS, Delay_BIS]. If Delay_BIS is not provided it is assumed equal to 0. The default is None.

atracurium_model_paramsdict, optional

For “WardWeatherleyLago”: dict {‘V1’, ‘V2’, ‘Cl’, ‘t12_alpha’, ‘t12_beta’, ‘ke0’, ‘tau’}. If it is not provided average values are used.

atracurium_hill_paramsdict, optional

For “WardWeatherleyLago”: dict {‘c50’, ‘gamma’}. If it is not provided average values are used.

random_PKbool, optional

Add uncertainties in the Propofol 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.

truncatedbool, optional

Use truncated normal distribution (between [-3, +3] std) for the random parameters. The default is False.

Attributes:
agefloat

Age of the patient (yr).

heightfloat

Height of the patient (cm).

weightfloat

Weight of the patient (kg).

sexbool

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_remistr

Name of the norepinephrine PK model.

model_atracuriumstr

Name of the atracurium PK model.

model_bisstr

Name of the BIS PD model.

model_locstr

Name of the LOC PD model

model_tofstr

Name of the TOF PD model.

model_hemostr

Name of the hemo model.

hill_paramlist

Parameter of the BIS model (Propo Remi interaction) list [C50p_BIS, C50r_BIS, gamma_BIS, beta_BIS, E0_BIS, Emax_BIS, Delay_BIS]. If Delay_BIS is not provided it is assumed equal to 0.

atracurium_model_paramsdict, optional
For “WardWeatherleyLago”:

dict {‘V1’, ‘V2’, ‘Cl’, ‘t12_alpha’, ‘t12_beta’, ‘ke0’, ‘tau’}

atracurium_hill_paramsdict, optional
For “WardWeatherleyLago”:

dict {‘c50’, ‘gamma’}

random_PKbool

Add uncertainties in the Propofol 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 internal variables at each sampling time in a data frame.

lbmfloat

Lean body mass (kg).

propo_pkCompartmentModel

4-comparments model for Propofol.

remi_pkCompartmentModel

4-comparments model for Remifentanil.

nore_pkCompartmentModel

1-comparments model for Norepinephrine.

atracurium_pkCompartmentModel

4-comparments model for Atracurium.

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.

tof_pdTOF_model

Hill curve model for tof computation.

datapd.DataFrame

Dataframe containing all the internal variables at each sampling time.

bisfloat

Bispectral index (%).

tolfloat

Tolerance of laryngoscopy probability (0-1).

cofloat

Cardiac output (L/min).

mapfloat

Mean arterial pressure (mmHg).

toffloat

Neuromuscular blockade level (%).

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.

bis_delay_maxfloat

Maximum value of the BIS delay caused by signal quality index expressed in (s).

bis_delay_buffer: array

Buffer of BIS values to simulate delay.

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: ndarray | None = None, u_remi: ndarray | None = None, u_nore: ndarray | None = None, u_atra: ndarray | None = None, disturbances: ndarray | None = None, x0_propo: array | None = None, x0_remi: array | None = None, x0_nore: array | None = None, x0_atra: array | None = None, interp=False) DataFrame

Simulates the patient model using the drugs infusions profiles provided as inputs.

Parameters:
u_proponumpy array, optional

Propofol infusion rate (mg/s). Must be a 1D array.

u_reminumpy array, optional

Remifentanil infusion rate (µg/s). Must be a 1D array.

u_norenumpy array, optional

Norepinephrine infusion rate (µg/s). Must be a 1D array.

u_atranumpy array, optional

Atracurium infusion rate (µg/s). Must be a 1D array.

disturbancesnumpy array, optional

2D numpy array with disturbance vector, axis 1=signals; axis 2= Time. Default is null.

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.

x0_atranumpy array, optional

Initial state of the atracurium PK model. The default is zeros.

interpbool, optional

Whether to use zero-order-hold (False, the default) or linear (True) interpolation for the input array.

Returns:
pandas.Dataframes

Dataframe with all the data.

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.

Warning, this option does not work if the co_update option is set to True.

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_given_state(x0_atra: ndarray)

Initialize the atracurium linear model at the given state.

Parameters:
x0numpy array

Initial state vector of the atracurium linear model.

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 (%).

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).

one_step(u_propo: float = 0, u_remi: float = 0, u_nore: float = 0, u_atra: float = 0, sqi: float = 100, blood_rate: float = 0, dist: list = None) 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.

u_atrafloat, optional

Atracurium 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), TPR (mmHg.min/mL), SV (mL), HR (beat/min)]. The default is [0]*6.

noisebool, optional

bool to add measurement noise on the outputs. The default is True.

Returns:
bisfloat

Bispectral index(%).

loc: float,

Loss of consciousness

cofloat

Cardiac output (L/min).

mapfloat

Mean arterial pressure (mmHg).

tolfloat

Tolerance of Laryngoscopy index (0-1).

toffloat

Neuromuscular Blockade level (%)