Skip to content

MarekWadinger/diabetes_simulator

Repository files navigation

Diabetes Simulator

A MATLAB/Simulink-based simulation tool for modeling and analyzing the dynamics of glucose and insulin in diabetic subjects. This project focuses on developing and validating compartment models using real-world Continuous Glucose Monitoring (CGM) data.

Table of Contents

Introduction

Diabetes is a complex metabolic disorder that requires careful monitoring and management of blood glucose and insulin levels. This project aims to simulate the physiological processes involved in glucose uptake and insulin absorption by constructing compartment models and validating them using CGM data. The developed simulator helps in understanding the dynamics of glycemia and in estimating key model parameters.

Project Overview

The Diabetes Simulator is built upon three interconnected subsystems:

  1. Glucose Absorption Subsystem (GAM):
    Models the uptake of glucose from the digestive tract into the bloodstream. It captures the dynamics of glucose appearance (Ra(t)) and its storage/distribution (D(t)) using differential equations.

  2. Bergman's Minimal Model (BMM):
    Represents the dynamic behavior of glucose concentration in the plasma. It accounts for the impact of insulin on glucose utilization and distribution, estimating insulin sensitivity and glucose effectiveness.

  3. Insulin Absorption Subsystem (IAM):
    Simulates the absorption of insulin from the subcutaneous tissue into the bloodstream using compartmental models. It considers the injection rate, distribution, and degradation of insulin.

These subsystems work together to provide a comprehensive simulation of the metabolic processes in a diabetic subject.

System Models

Glucose Absorption Subsystem (GAM)

  • Purpose:
    Simulate the process by which glucose is absorbed from the gastrointestinal tract into the blood.

  • Key Components:

    • Glucose appearance rate (Ra(t)): Input to the Bergman model.
    • Glucose compartment (D(t)): Represents the glucose present in the system.
  • Mathematical Modeling:
    The subsystem is described by differential equations that balance the rate of glucose intake and absorption efficiency.

Bergman's Minimal Model (BMM)

  • Purpose:
    Estimate the dynamic interplay between glucose concentration and insulin action.

  • Key Components:

    • Glucose concentration (G(t)) and active insulin effect (X(t)).
    • Incorporates the effects of insulin sensitivity and glucose effectiveness.
  • Mathematical Modeling:
    The model employs differential equations to simulate how insulin modulates glucose utilization.

Insulin Absorption Subsystem (IAM)

  • Purpose:
    Model the kinetics of insulin absorption from subcutaneous injections to the plasma.

  • Key Components:

    • Insulin injection rate (v(t)) and its compartmental distribution.
    • Decay rate of insulin in the bloodstream.
  • Mathematical Modeling:
    A series of interconnected compartments describe the movement and decay of insulin, using a set of differential equations.

Simulation

The overall simulator integrates the three subsystems within MATLAB and Simulink. The output of the glucose absorption subsystem (Ra(t)) feeds into Bergman’s minimal model, while the insulin absorption subsystem contributes to the simulated plasma insulin concentration. Graphical outputs include:

  • Comparison between measured CGM glycemia and simulated glucose concentration.
  • Analysis of glucose absorption and insulin profiles over time.

Parameter Identification

To calibrate the model, key parameters are identified using MATLAB's fminsearch function (Nelder-Mead simplex method). The objective is to minimize the sum of squared differences between the CGM data and the model outputs over a time window of 400–1400 minutes. The parameters of interest are:

  • Glucose efficiency (S) [1/min]
  • Time constant (T) [min]

The optimization process iteratively adjusts these parameters until convergence, ensuring the model closely fits the observed data.

Results and Discussion

  • Optimization Outcome:
    The parameter identification converged after 41 iterations with a sum of squared errors of 758.55.

  • Parameter Comparison:
    Initial guesses and optimized values were compared, highlighting the influence of the working time range on the parameter estimation.

  • Model Accuracy:
    Differences between simulated and observed glycemic data suggest the presence of external disturbance variables. It is recommended to reduce the working time range to minimize these disturbances and improve parameter accuracy.

  • Further Analysis:
    Additional simulations with different time ranges are discussed in Appendix A of the full documentation.

Usage

  1. Clone the Repository:

    git clone https://github.com/MarekWadinger/diabetes_simulator.git
  2. Open the Project:

    Open the project in MATLAB 2021b or later.

  3. Run the Simulation:

    Launch the Simulink model to visualize the simulation outputs.

  4. Review the Results:

    Compare the simulation outputs with the measured data as demonstrated in the included graphs and tables.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

  • Bc. Marek Wadinger: Project author
  • Prof. Ing. Ivan Sekaj, PhD.: Course supervisor
  • Ing. Marián Tárník, PhD.: Lab instructor

For the full project details in Slovak, please refer to the MW_BKYB-03_zadanie.pdf document.

About

Simulation tool for modeling and analyzing the dynamics of glucose and insulin in diabetic subjects.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages