Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding initial blood glucose level as an input to the simulator #25

Open
celikalp opened this issue Feb 22, 2021 · 5 comments
Open

Adding initial blood glucose level as an input to the simulator #25

celikalp opened this issue Feb 22, 2021 · 5 comments

Comments

@celikalp
Copy link

celikalp commented Feb 22, 2021

How can I add initial fasting blood glucose as an input parameter to the simulator?

@celikalp
Copy link
Author

celikalp commented Feb 23, 2021

Gb is the initial fasting bg. I re-computed values of Gs, Gpb, Gtb, EGPb, Vm0 and it did the job. I used the paper to interpret the equations. Here is the code:

@classmethod
def withName(cls, name, **kwargs):
    '''
    Construct patient by name.
    Names can be
        adolescent#001 - adolescent#010
        adult#001 - adult#001
        child#001 - child#010
    '''
    patient_params = pd.read_csv(PATIENT_PARA_FILE)
    params = patient_params.loc[patient_params.Name == name].squeeze()
    # set fasting blood glucose if given in kwargs
    if 'fasting_bg' in kwargs and kwargs['fasting_bg'] is not None:
        params.Gb = kwargs['fasting_bg']
        params.Gpb = params.Gb * params.Vg
        params.EGPb = params.kp1 - params.kp2 * params.Gpb - params.kp3 * params.Ib
        Gtb = (params.Fsnc - params.EGPb + params.k1 * params.Gpb) / params.k2
        params.Vm0 = (params.EGPb - params.Fsnc) * (params.Km0 + Gtb) / Gtb
        params.iloc[5] = params.Gpb
        params.iloc[6] = Gtb
        params.iloc[14] = params.Gpb
    kwargs.pop('fasting_bg', None)
    return cls(params, **kwargs)

@celikalp celikalp changed the title Adding initial fasting blood glucose level as an input to the simulator Adding initial blood glucose level as an input to the simulator Feb 23, 2021
@celikalp
Copy link
Author

I think, @jxx123 you may want to fix #18.

@celikalp celikalp reopened this Mar 15, 2021
@jxx123
Copy link
Owner

jxx123 commented Mar 16, 2021

@aacelik Thanks! I will take a look. If you want to go head and fix it, please send me a pull request :)

@junzhuang-code
Copy link

junzhuang-code commented Jun 28, 2021

Hi @aacelik and @jxx123,

I'm interested in following up on this question. After this new feature added, is it possible for the user to select a new initial blood glucose level for the patient?

For example,
Patient adolescent#002 has an initial glucose level 152.41. I want to change this level to another number (let's say 120) at the beginning.
I read the repo and the article that you used to implement this repo. I attempted to change some parameters in "vpatient_params.csv" as follows: 1. Changed Vg and u2ss; 2. Changed from x0_1 to x0_13 and u2ss.
However, both attempts fail to fulfill this goal as the new BG keeps on increasing without any meal or insulin input.
I'm wondering whether or not I can change the initial glucose level of Patient adolescent#002 from 152.41 to 120 by using this new feature (or other features)?
If not, any parameters in "vpatient_params.csv" that I can change to achieve the same goal?
Please correct me if my understanding is imprecise.

Thanks for your reply in advance,


I think I've solved this issue. Forget my question.
Thanks,

@edger-asiimwe
Copy link
Contributor

Hi @aacelik and @jxx123,

I'm interested in following up on this question. After this new feature added, is it possible for the user to select a new initial blood glucose level for the patient?

For example, Patient adolescent#002 has an initial glucose level 152.41. I want to change this level to another number (let's say 120) at the beginning. I read the repo and the article that you used to implement this repo. I attempted to change some parameters in "vpatient_params.csv" as follows: 1. Changed Vg and u2ss; 2. Changed from x0_1 to x0_13 and u2ss. However, both attempts fail to fulfill this goal as the new BG keeps on increasing without any meal or insulin input. I'm wondering whether or not I can change the initial glucose level of Patient adolescent#002 from 152.41 to 120 by using this new feature (or other features)? If not, any parameters in "vpatient_params.csv" that I can change to achieve the same goal? Please correct me if my understanding is imprecise.

Thanks for your reply in advance,

I think I've solved this issue. Forget my question. Thanks,

@junzhuang-code where you able to achieve this. Wanted to work with a similar situation where I set my initial BG, lets say at 7am.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants