Abstract

Keywords
Software programs for conducting computer simulations of virtual patients with type 1 diabetes mellitus (T1D) are essential tools for preclinical studies that are necessary for translating novel diabetes technologies to clinical studies.1-3 The necessity of simulation software for testing algorithms employed in diabetes technologies means that several software packages for simulation of virtual patients with T1D have been developed with diverse cohorts of virtual patients and various scenarios of meal consumption and insulin administration. The University of Virginia/Padova metabolic simulator, accepted by the Food and Drug Administration as a surrogate to preclinical animal studies, has evolved over several versions and is widely used to develop and evaluate glucose control algorithms.
There is a general trend in the broader scientific community, and the diabetes technologies field, to enhance the reproducibility of simulation results.4,5 This trend motivates the development of open-source software and libraries. Examples include a toolbox to analyze glucose data, a software package for digital twinning of patients, and an open-source framework for diabetes simulation. Furthermore, open-source closed-loop glucose control systems such as OpenAPS and AndroidAPS are developed. 6 We introduce the multivariable glucose-insulin-physiological-variables simulator (py-mgipsim), an open-source Python library freely available under a copyleft license for simulating a diverse heterogeneous virtual patient population with T1D under various scenarios involving meals and physical activities (Github link: https://github.com/illinoistech-itm/py-mgipsim).
A cohort of 20 virtual patients is available with each virtual patient taking a unique model parameter set and demographics information. The py-mgipsim software has implementations of multiple daily injection therapy, sensor-augmented pump therapy, and hybrid closed-loop automated insulin delivery systems. New control algorithms can be readily added to the py-mgipsim library to test algorithms for fully automated and multivariable closed-loop insulin delivery systems. Uncertainty in carbohydrate counting and stochasticity in meal and physical activity times can be incorporated in the simulations. Simulation scenarios can be exported and loaded to rerun saved scenarios later and generate reproducible simulations.
The py-mgipsim software library can be used through a user-friendly graphical user interface that renders the library accessible to the general population, a low-code environment with a command line interface for automation of repetitive simulation tasks and executing the library programmatically for flexibility. The results can be visualized in an interactive plot and the interface provides options for exporting the results. The state variables can be exported in an Excel file, the simulated scenario can be exported in a JSON file, and the glycemic metrics can be exported using the PYAGATA toolbox.
Figure 1 depicts the results of an exemplary one-day-long simulation of two virtual subjects on multiple daily injection therapy, with blood glucose (blue lines), meal consumption (black arrows), and heart rate (shaded pink) shown. The figures are customizable, and additional variables can be readily plotted. The software execution time is fast as the implementation is vectorized with respect to the cohort and just-in-time compiled. The whole cohort (20 subjects) using a sampling time of one-minute, fourth-order Runge-Kutta method, and seven-day-long simulation is executed in seconds. The open-source Python library py-mgipsim will accelerate the development and translation of algorithms for diabetes technologies.

Simulation results with py-mgipsim showing two virtual patients with a physical activity.
Footnotes
Abbreviations
T1D, type 1 diabetes mellitus; py-mgipsim, Python library of multivariable glucose-insulin-physiological-variables simulator
Declaration of Conflicting Interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: Financial support from the NIH under grants 1DP3DK101075, 1R01DK130049, and R01DK135116 and the JDRF under grants 2-SRA-2017-506-M-B and 3-APF-2022-1134-A-N made possible through collaboration between the JDRF and the Leona M. and Harry B. Helmsley Charitable Trust are gratefully acknowledged.
