jxx123 / simglucose

A Type-1 Diabetes simulator implemented in Python for Reinforcement Learning purpose
MIT License
232 stars 111 forks source link

insulin unit and basal dosage #7

Closed indrakur closed 3 years ago

indrakur commented 5 years ago

I wonder about insulin unit used in this simulator.

Other thing is basal dosage in basal-bolus controller. The calculation is: basal = u2ss * BW / 6000 What is the standard used in this controller? Also I can not find out what is u2ss. It is better if there is explanation about variables.

Thank you.

jxx123 commented 5 years ago

The basal I use (basal = u2ss BW / 6000) is under unit "U/min", where 1 U/min = 6000 pmol/L. "u2ss" is the steady state insulin rate per kilogram, and its unit is pmol/(L kg).

Documentation is really an issue. I need to find time to address that. Thanks!

EemeIi commented 3 years ago

Hey @jxx123!

Further, in controller/basal_bolus_ctrller.py, line 56:

bolus = bolus / env_sample_time

scales the bolus from "U/env_sample" to "U/min", right? Then, in simulation/env.py, there is

insulin += tmp_insulin / self.sample_time

again, so the stored output is divided by env_sample_time. The division from this line should be omitted, right?

jxx123 commented 3 years ago

Hey @jxx123!

Further, in controller/basal_bolus_ctrller.py, line 56:

bolus = bolus / env_sample_time

scales the bolus from "U/env_sample" to "U/min", right? Then, in simulation/env.py, there is

insulin += tmp_insulin / self.sample_time

again, so the stored output is divided by env_sample_time. The division from this line should be omitted, right?

Hi @EemeIi , the reason to divide bolus by env_sample_time is that the original bolus is the total amount (U), and the division is to convert it to rate (U/min).

For the line insulin += tmp_insulin / self.sample_time, the purpose is just to compute the average insulin rate in the sample time (see this comment). The reason for this is that the patient simulation sample time is 1 minute (see the mini_step function), but I would like to support arbitrary sample time in the simulator, hence I record the average values for all the variables including insulin.

OneBirding commented 3 years ago

Hello, can you write down and upload the detailed documentation of the algorithm in your spare time?

jxx123 commented 3 years ago

Hi I have added the documentation for the controller. I closed this issue for now, please feel free to reopen it if there is anything unclear. Thanks.

KeAWang commented 2 years ago

1 U/min = 6000 pmol/L

@jxx123 How can this be? The right hand side has no units of time. Should u2ss be instead pmol/L/min since it's a rate?

zjp-zjp-zjp commented 1 year ago

Hi, I'm wondering how u2ss is calculated? Or it's an independent parameter that needs to be input instead of calculated?