Skip to content

artmedlar/A1c-Animation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

A1C Simulation and Animation

A Python project that simulates and visualizes how HbA1c (glycated hemoglobin) levels change over time based on blood glucose patterns and red blood cell (RBC) lifecycles.

Features

Interactive Animation (a1c_animation.py)

  • Real-time RBC visualization: Watch red blood cells spawn, age, and change color based on glycation
  • Circadian glucose patterns: Toggle between realistic daily glucose cycles and manual glucose levels
  • Multiple lifespan models: Choose from gamma distribution (realistic), normal distribution, or fixed lifespans
  • Live statistics: Track RBC count, average age, glycation levels, and estimated A1c

Analytical Simulation (a1c_simulation.py)

  • Long-term modeling: Simulate A1c changes over 6 months
  • Glucose history tracking: Model how past glucose levels affect current A1c
  • Statistical analysis: Generate plots showing A1c trends over time

Scientific Background

This simulation models the biological process behind A1c testing:

  • Red blood cells live approximately 120 days (gamma distributed)
  • Glucose attachment occurs continuously during RBC lifespan
  • A1c measurement reflects average glucose over 2-3 months
  • Circadian patterns show realistic daily glucose fluctuations

Installation

  1. Clone this repository
  2. Install dependencies:
    pip install -r requirements.txt

Usage

Run the Interactive Animation

python a1c_animation.py

Controls:

  • Toggle "Use Circadian Glucose" to switch between realistic daily patterns and fixed glucose
  • Change "Lifespan Mode" to experiment with different RBC longevity models
  • Watch RBCs change from red to yellow as they accumulate glucose

Run the Analytical Simulation

python a1c_simulation.py

This will generate a plot showing how A1c estimates change over time based on glucose history.

Understanding the Visualization

  • Red circles: Fresh RBCs with low glycation
  • Yellow circles: Older RBCs with high glycation
  • RBC color gradient: Shows individual glycation levels
  • Estimated A1c: Calculated from average population glycation

Requirements

  • Python 3.11 (required for pygame compatibility)
  • NumPy (numerical computations)
  • Matplotlib (plotting for analytical simulation)
  • Pygame (graphics and real-time animation engine)
  • Pygame GUI (user interface elements for interactive controls)

Why Python 3.11 specifically?

This project requires Python 3.11 due to pygame compatibility constraints. Pygame currently does not support Python versions newer than 3.11, so please ensure you're using Python 3.11 specifically to avoid compatibility issues.

Educational Use

This simulation is designed for educational purposes to help understand:

  • How A1c testing works at a cellular level
  • Why A1c reflects 2-3 month glucose averages
  • The relationship between daily glucose patterns and long-term measurements
  • The biological variability in RBC lifespans

License

Open source - feel free to use and modify for educational purposes.

About

Interactive A1C simulation showing red blood cell glycation over time

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages