Skip to content

ReplayBG logo

ReplayBG

A digital-twin based framework for the development and assessment of new algorithms for type 1 diabetes management.

🧬

Digital Twin

ReplayBG fits a physiological ODE model to a person's CGM + insulin + meal data (twinning), producing a personalized digital twin of their glucose–insulin system.

πŸ”¬

State of the Art

Built on validated T1D physiological models and a principled MAP identification procedure, and integrated with AGATA for standardized glucose-metric analysis.

⚑

Easy to Use

A tiny API β€” twin() and replay() β€” lets you ask what-if: what would this person's glucose have looked like with a different dose, a different meal, or a control algorithm in the loop?

What is ReplayBG?

ReplayBG is a digital-twin framework for Type 1 Diabetes (T1D) glucose dynamics. It works in two steps:

  1. Twinning β€” it fits a physiological model to a person's recorded CGM, insulin and meal data, estimating the parameter set (theta) that best explains that data. This fitted model is the digital twin.
  2. Replay β€” it forward-simulates the twin under counterfactual scenarios: a different insulin dose, a modified meal, a bolus calculator, a hypo-treatment policy, or a full control algorithm in the loop β€” and predicts the resulting glucose trace.
 raw DataFrame            Data class              Model (Numba jitclass)
 t, glucose, cho,   ─▢   SingleMealT1DData  ─▢   SingleMealT1DModel   ─┐
 bolus, basal, ...       MultiMealT1DData        MultiMealT1DModel     β”‚
                         MultiMealExtended…      MultiMealExtended…    β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”˜
        β”‚
        β”œβ”€β–Ά  rbg.twin()    MAP estimation (multi-start Powell + polish)  ─▢  theta (the digital twin)
        β”‚
        └─▢  rbg.replay()  forward simulation with theta                 ─▢  predicted glucose trace

Ready to build your first digital twin? Head to Getting Started.

Reference

If you use ReplayBG in your research, please cite:

G. Cappon, M. Vettoretti, G. Sparacino, S. Del Favero, and A. Facchinetti, "ReplayBG: A Digital Twin-Based Methodology to Identify a Personalized Model From Type 1 Diabetes Data and Simulate Glucose Concentrations to Assess Alternative Therapies," IEEE Transactions on Biomedical Engineering, vol. 70, no. 11, pp. 3227–3238, Nov. 2023, doi: 10.1109/TBME.2023.3286856.

@article{cappon2023replaybg,
  author  = {Cappon, Giacomo and Vettoretti, Martina and Sparacino, Giovanni and Del Favero, Simone and Facchinetti, Andrea},
  title   = {{ReplayBG}: A Digital Twin-Based Methodology to Identify a Personalized Model From Type 1 Diabetes Data and Simulate Glucose Concentrations to Assess Alternative Therapies},
  journal = {IEEE Transactions on Biomedical Engineering},
  volume  = {70},
  number  = {11},
  pages   = {3227--3238},
  year    = {2023},
  doi     = {10.1109/TBME.2023.3286856},
}

Supporting research

Research on ReplayBG development

Journal Papers

  • F. Prendin, A. Facchinetti, and G. Cappon "Data Augmentation via Digital Twins Enables the Development of Personalized Deep Learning Glucose Prediction Algorithms for Type 1 Diabetes in Poor Data Context" IEEE Journal of Biomedical Health Informatics, (under revision, submitted October 2024)
  • G. Cappon, and A. Facchinetti, "Digital twins in type 1 diabetes: A systematic review" Journal of Diabetes Science and Technology, online ahead of print, 2024, DOI: 10.1177/1932296824126211.
  • G. Cappon, M. Vettoretti, G. Sparacino, S. Del Favero, and A. Facchinetti "ReplayBG: a digital twin-based methodology to identify a personalized model from type 1 diabetes data and simulate glucose concentrations to assess alternative therapies", IEEE Transactions on Biomedical Engineering, vol. 70, no. 11, pp. 3105-3115, Nov 2023, DOI: 10.1109/TBME.2023.3286856

Conference papers and abstracts

  • G. Cappon, S. Del Favero, and A. Facchinetti "Extending the applicability of ReplayBG tool for digital twinning in type 1 diabetes from single-meal to multi-day scenarios" in the 24th Annual Diabetes Technology Meeting – DTM, Burlingame, CA, USA, October 15-17, 2024.
  • J. Leth, H. Ghazaleh, H. Peuscher, and G. Cappon "The potential of open-source software in diabetes research" in the 17th International Conference on Advanced Technology & Treatment for Diabetes – ATTD, Firenze, Italy, March 6-9, 2024 (invited oral presentation, speaker J. Leth).
  • H. Peuscher, G. Cappon, A. Cinar, J. Deichmann, H. Ghazaleh, H. Kaltenbach, L. Sandini, M. Siket, J. Xie, and X. Zhou "A survey on existing open-source projects in diabetes simulation" in the 17th International Conference on Advanced Technology & Treatment for Diabetes – ATTD, Firenze, Italy, March 6-9, 2024 (invited oral presentation, speaker J. Leth).
  • G. Cappon, M. Vettoretti, G. Sparacino, S. Del Favero, and A. Facchinetti "Expanding ReplayBG simulation methodology domain of validity to single day multiple meal scenarios" in the 15th International Conference on Advanced Technology & Treatment for Diabetes – ATTD, Barcelona, Spain, April 27-30, 2022.
  • G. Cappon, M. Vettoretti, G. Sparacino, S. Del Favero, and A. Facchinetti "ReplayBG provides reliable indications when used to assess meal bolus alterations in type 1 diabetes" in the 14th International Conference on Advanced Technology & Treatment for Diabetes – ATTD, Paris, France, June 2-6, 2021.
  • G. Cappon, A. Facchinetti, G. Sparacino, and S. Del Favero "ReplayBG: A novel in-silico framework to retrospectively assess new therapy guidelines for type 1 diabetes management" in the 20th Annual Diabetes Technology Meeting – DTM, Bethesda, Maryland, USA, November 12-14, 2020.
  • G. Cappon, A. Facchinetti, G. Sparacino, and S. Del Favero "A Bayesian framework to personalize glucose prediction in type 1 diabetes using a physiological model" in the 19th Annual Diabetes Technology Meeting – DTM, Bethesda, Maryland, USA, November 14-16, 2019.
  • G. Cappon, A. Facchinetti, G. Sparacino, and S. Del Favero "A Bayesian framework to identify type 1 diabetes physiological models using easily accessible patient data" in the 41th Annual International Conference of the IEEE Engineering in Medicine and Biology Society – EMBC, Berlin, Germany, July 23-27, 2019 (accepted for oral presentation, speaker G.Cappon).

Research using ReplayBG as component or validation tool

Journal Papers

  • E. Pellizzari, G. Cappon, G. Nicolis, G. Sparacino, and A. Facchinetti "Developing effective machine learning models for insulin bolus calculation in type 1 diabetes exploiting real-world data and digital twins" IEEE Transactions on Biomedical Engineering, online ahead of print, Nov 2025, DOI: 10.1109/TBME.2025.3648515
  • E. Pellizzari, F. Prendin, G. Cappon, G. Sparacino, and A. Facchinetti, "drCORRECT: An algorithm for the preventive administration of postprandial corrective insulin boluses in type 1 diabetes management" Journal of Diabetes Science and Technology, online ahead of print, 2023, DOI: 10.1177/19322968231221768
  • F. Prendin, J. Pavan, G. Cappon, S. Del Favero, G. Sparacino, and A. Facchinetti, "The importance of interpreting machine learning models for blood glucose prediction in diabetes: an analysis using SHAP" Scientific Reports, vol. 13, no. 1, pp. 16865, Oct 2023, DOI: 10.1038/s41598-023-44155-x.
  • G. Noaro, G. Cappon, M. Vettoretti, G. Sparacino, S. Del Favero, and A. Facchinetti "Machine-learning based model to improve insulin bolus calculation in type 1 diabetes therapy" IEEE Transactions on Biomedical Engineering, vol. 68, no. 1, pp. 247-255, Jan 2021. DOI: 10.1109/TBME.2020.3004031

Conference papers and abstracts

  • E. Pellizzari, M. Zanon, L. Cossu, P. Herrero, A. Facchinetti, and G. Cappon "Comparing Bayesian Methods for Robust Parameter Estimation in Type 1 Diabetes Digital Twins" in the 19th International Conference on Advanced Technology & Treatment for Diabetes – ATTD, Barcelona, Spain, March 11-14, 2026 (accepted for oral presentation).
  • L. Cossu, A. Ghiotto, E. Pellizzari, M. Martino, A. Deodati, R. Schiaffini, S. Cianfarani, A. Facchinetti, G. Sparacino, and G. Cappon "Development of a Web Interface for Type 1 Diabetes Therapy Simulation Based on Digital Twin" in the 19th International Conference on Advanced Technology & Treatment for Diabetes – ATTD, Barcelona, Spain, March 11-14, 2026 (accepted for oral presentation).
  • E. Pellizzari, O. Mujahid, F. Prendin, O. Bustos, G. Cappon, A. Facchinetti, and J. Vehi "Enhancing the physiological plausibility of GAN-generated blood glucose in type 1 diabetes with monotonicity constraints" in the 2025 IEEE International Conference on Metrology for eXtended Reality, Artificial Intelligence and Neural Engineering – MetroXRAINE, Ancona, Italy, October 22-24, 2025.
  • E. Pellizzari, G. Cappon, G. Sparacino, A. Deodati, R. Schiaffini, S. Cianfarani, and A. Facchinetti "Digital-twin based optimization of bolus insulin dosing in pediatric type 1 diabetes: an in silico feasibility study" in the 47th Annual International Conference of the IEEE Engineering in Medicine and Biology Society – EMBC, Copenhagen, Denmark, July 14-17, 2025.
  • L. Cossu, L. Semenzato, A. Facchinetti, and G. Cappon "Digital twin-based reinforcement learning for personalized mealtime insulin dosing in pediatric diabetes: A proof of concept" in the 47th Annual International Conference of the IEEE Engineering in Medicine and Biology Society – EMBC, Copenhagen, Denmark, July 14-17, 2025.
  • L. Cossu, E. Pellizzari, G. Cappon, A. Deodati, R. Schiaffini, G. Sparacino, S. Cianfarani, and A. Facchinetti "Enhancing pediatric type 1 diabetes therapy using TWIN, a clinical decision support system based on digital twins" in the 9th Congress of the National Group of Bioengineering – GNB, Palermo, Italy, Jun 16-18, 2025.
  • E. Pellizzari, G. Cappon, G. Sparacino, and A. Facchinetti "Digital twin-based adaptive optimization of basal insulin in pediatric patients: A feasibility study" in the 18th International Conference on Advanced Technology & Treatment for Diabetes – ATTD, Amsterdam, The Netherlands, March 19-22, 2025.
  • E. Pellizzari, G. Cappon, G. Nicolis, G. Sparacino, and A. Facchinetti "Exploiting real-world data and digital twins to develop effective formulas for dosing insulin boluses in type 1 diabetes therapy" in the 24th Annual Diabetes Technology Meeting – DTM, Burlingame, CA, USA, October 15-17, 2024.
  • F. Prendin, A. Facchinetti, and G. Cappon "Digital twin for data augmentation enables the development of accurate personalized deep glucose forecasting algorithms" in the 24th Annual Diabetes Technology Meeting – DTM, Burlingame, CA, USA, October 15-17, 2024.
  • E. Pellizzari, F. Prendin, G. Cappon, G. Sparacino, and A. Facchinetti "DR-CIB: An algorithm for the preventive administration of corrective insulin boluses in T1D based on dynamic risk concept and patient-specific timing" in the 23rd Annual Diabetes Technology Meeting – DTM, Online, November 1-4, 2023 (Gold Student Award, accepted for oral presentation, speaker E. Pellizzari).
  • G. Cappon, E. Pellizzari, L. Cossu, G. Sparacino, A. Deodati, R. Schiaffini, S. Cianfarani, and A. Facchinetti "System architecture of TWIN: A new digital twin-based clinical decision support system for type 1 diabetes management in children" in the 19th International Conference on Body Sensor Networks – BSN, Boston, MA, USA, October 9-11, 2023.
  • E. Pellizzari, F. Prendin, G. Cappon, G. Sparacino, and A. Facchinetti "A deep-learning based algorithm for the management of hyperglycemia in type 1 diabetes therapy" in the 19th International Conference on Body Sensor Networks – BSN, Boston, MA, USA, October 9-11, 2023.
  • G. Noaro, G. Cappon, G. Sparacino, and A. Facchinetti "An ensemble learning algorithm based on dynamic voting for targeting the optimal insulin dosage in type 1 diabetes management" in the 43rd Annual International Conference of the IEEE Engineering in Medicine and Biology Society – EMBC, Guadalajara, Mexico, October 31-4, 2021 (accepted for oral presentation, speaker G. Noaro).
  • G. Cappon, E. Pighin, F. Prendin, G. Sparacino, and A. Facchinetti "A correction insulin bolus delivery strategy for decision support systems in type 1 diabetes" in the 43rd Annual International Conference of the IEEE Engineering in Medicine and Biology Society – EMBC, Guadalajara, Mexico, October 31-4, 2021 (accepted for oral presentation, speaker G. Cappon).
  • G. Noaro, G. Cappon, M. Vettoretti, S. Del Favero, G. Sparacino, and A. Facchinetti "A new model for mealtime insulin dosing in type 1 diabetes: Retrospective validation on CTR3 dataset" in the 20th Annual Diabetes Technology Meeting – DTM, Bethesda, Maryland, USA, November 12-14, 2020 (accepted for oral presentation, speaker G. Noaro).
  • G. Noaro, G. Cappon, G. Sparacino, S. Del Favero, A. Facchinetti "Nonlinear machine learning models for insulin bolus estimation in type 1 diabetes therapy" in the 42nd Annual International Conference of the IEEE Engineering in Medicine and Biology Society – EMBC, Montreal, Canada, July 20-24, 2020 (accepted for oral presentation, speaker G. Noaro).