Comments (3)
Hi,
Sorry for the late reply. For now, you can only specify carbohydrate in the CustomScenario.
To have a scenario where the patient takes carb but no insulin, you need to implement a dummy controller yourself, like this (this is also in Rreadme doc). This dummy controller does not inject any insulin.
from simglucose.simulation.user_interface import simulate
from simglucose.controller.base import Controller, Action
class MyController(Controller):
def __init__(self, init_state):
self.init_state = init_state
self.state = init_state
def policy(self, observation, reward, done, **info):
'''
Every controller must have this implementation!
----
Inputs:
observation - a namedtuple defined in simglucose.simulation.env. For
now, it only has one entry: blood glucose level measured
by CGM sensor.
reward - current reward returned by environment
done - True, game over. False, game continues
info - additional information as key word arguments,
simglucose.simulation.env.T1DSimEnv returns patient_name
and sample_time
----
Output:
action - a namedtuple defined at the beginning of this file. The
controller action contains two entries: basal, bolus
'''
self.state = observation
action = Action(basal=0, bolus=0)
return action
def reset(self):
'''
Reset the controller state to inital state, must be implemented
'''
self.state = self.init_state
ctrller = MyController(0)
simulate(controller=ctrller)
Or you might want to keep the basal, but not injecting bolus. You can set bolus to be always 0 here
For the other way around, it is a bit tricky. Still in the basal_bolus_controller, you can get the meal info here
you can do something like, when the meal > 0, your bolus is still 0, but you keep a counter, like after 10 time steps (if sample time is 5min, then it is 50 minutes later), you can set bolus > 0 (make sure the patient don't take any meal at this time).from simglucose.
Hi @jxx123,
Many thanks for your reply. I have a few things to clarify in your reply:
-
You mentioned that from the CustomScenario controller, I can set the insulin (bolus) to zero, while the carbs (basal) to non-zero (scenario where the patient takes carb but no insulin); which I was able to implement successfully. In the second response, you alternatively mention about the modification that I can do on the basal_bolus_ctroller.py file to achieve the same thing ("your answer: Or you might want to keep the basal, but not injecting bolus. You can set bolus to be always 0 here"). What exactly is the difference between your first suggestion and this one ?. I guess it achieves the same result in two different ways right ? (one through a custom controller and other through a direct change in the code, which requires to build the package manually after applying these changes to basal_bolus_ctroller.py). Am I correct ?. If not, can you please elaborate the difference between those two approaches ?
-
For the other scenario, where you inject the insulin (bolus) but not taking any carbs (basal), wouldn't it be possible to just set the basal to 0 in basal_bolus_ctrller.py, like:
return Action(basal=0, bolus=bolus)
And I assume it's not possible to write a custom controller for this scenario right ?
Regards,
Kasun
from simglucose.
Hi Kasun,
-
There is no big difference between using your own custom controller or built-in basal_bolus_controller. I was saying that if you need to keep the basal (so the glucose can stay stay stable), you can just change the built-in basal_bolus_controller by keeping the basal but setting bolus to 0.
-
I guess you might be confused with the meaning of "basal" and "bolus". They both refer to insulin. Basal is a small amount of insulin that patient always need to inject, and bolus is the big amount of insulin that patients need to take at the meal time to offset the meal effect. If you want to inject insulin but not taking any carbs, you can just set basal and bolus to an amount you like in a custom controller (or basal_bolus_controller), but the tricky part is controller does not know the simulation time. If you want to set insulin to 2U at 7 am, the controller does not know when is 7 am in the simulation. A way to do this is that you can keep a counter in your custom controller to count the time step, and set the bolus (or basal) to an amount you like at the desired time.
Thanks,
Jinyu
from simglucose.
Related Issues (20)
- How did you obtain the parameters in vpatient_params.csv? HOT 4
- Documentation for each param in vpatient_params.csv HOT 5
- Are there currently any differences in the simulator between basal and bolus HOT 2
- How to set up the input/Controller in this repo to determine the basal rate with only insulin input (without meal)? HOT 7
- Input meal size different from recorded meal size HOT 4
- How to start simulator HOT 2
- Error in risk_index HOT 2
- The reward function encourages short episodes HOT 2
- Units in the Meal Absoption Model HOT 6
- Report function does not work HOT 2
- Controller is not reset during simulation of patients HOT 5
- Scenario with no meal in gym env HOT 2
- How to correctly implement the use of OpenAI Gym - reset() and step() methods are not implemented (NotImplementedError on google Colab)
- Dbar Modification HOT 3
- whether there is paper related to this project or not?
- Input meal size given in (g/min) instead of expected (g)
- Import Error
- Risk index calculation error in report generation
- Risk Index probably incorrect HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simglucose.