Skip to content

Home

CGM Data Processor Logo

Python Release Status Black isort Pylint Tests & Coverage Coverage licence: MIT


๐Ÿ“ What is CGM Data Processor?

CGM Data Processor is a Python-based toolkit for analysing diabetes-related data from multiple Continuous Glucose Monitoring (CGM) and treatment logging platforms, including XDrip+ and Freestyle Libre.

It aims to provide a standardised data model, supported by robust validation, gap detection, interpolation, and treatment processing, enabling researchers, patients, and developers to gain deeper insights into glucose trends and treatment dynamics.

This project is currently in pre-release, actively developed with the goal of becoming a fully documented, test-covered Python package suitable for real-world data analysis workflows and professional portfolio presentation.


๐Ÿ“ˆ Process Your Diabetes Data

Analyse consolidated diabetes data with confidence. Process CGM readings, insulin doses, carbohydrate intake, and treatment notes with repeatable, validated workflows designed for extensibility.


๐Ÿฉธ CGM Analysis Includes

  • Automatic gap detection
  • Configurable interpolation
  • Basic quality metrics (more planned)

๐Ÿ’‰ Treatment Data Support

  • Insulin bolus and basal events
  • Carbohydrate entries
  • Event and annotation handling

๐Ÿงช Data Pipeline Features

  • โœ… Automated file format detection
  • โœ… Cross-source alignment & merging
  • โœ… Metadata-preserving processing
  • โœ… Modular reader/processor architecture
  • โœ… Export-ready standardisation (CSV now, more to come)

๐Ÿš€ Quick Start

๐Ÿ“˜ Install CGM Data Processor โ€” see: ๐Ÿ‘‰ Installation Guide

The quickest way to run the tool during development is via the CLI entry point, using either the sample data, or your own backup files:

1
2
3
4
5
6
python -m src.cli sample_data/sample_libreview.csv \
    --debug                  # Display verbose output
    --interpolation-limit 6  # Max CGM gaps to fill (6 = 30 mins)
    --bolus-limit 10.0       # Max bolus insulin units
    --max-dose 20.0          # Max valid insulin dose
    --output ./my_analysis   # Output location
CLI Screenshot

This produces a set of validated, aligned CSV files suitable for onward analysis, dashboarding, or importing into statistical tools.

๐Ÿง  Using the Library in Python

from src.core.exceptions import DataProcessingError, ReaderError
from src.core.format_registry import FormatRegistry
from src.file_parser.format_detector import FormatDetector
from src.processors import DataProcessor
from src.readers import BaseReader

# Initialise format detection
registry = FormatRegistry()
detector = FormatDetector(registry)
processor = DataProcessor()
file_path = "example_data.sqlite"

# Process file
detected_format, _, _ = detector.detect_format(file_path)
reader = BaseReader.get_reader_for_format(detected_format, file_path)
with reader:
    table_data = reader.read_all_tables()
    if not table_data:
        raise ReaderError("No valid data found in file")
    try:
        processed_data = processor.process_tables(
            table_data=table_data,
            detected_format=detected_format,
        )
        if not processed_data:
            raise DataProcessingError("No data could be processed")

    except DataProcessingError as e:
        raise DataProcessingError(f"Failed to process data: {str(e)}") from e

More advanced configurations and workflows are covered in the ๐Ÿ“š API Reference


๐Ÿ“Š Example Output Structure

Example output structure

๐Ÿ› ๏ธ Roadmap to v1.0

Stage Target Status
โœ… Base architecture Readers, processors, CLI Available
โœ… CLI early usage Manual run from src root Available
โœ… Exports CSV currently supported Available
๐Ÿ”„ Test coverage โ‰ฅ 75% Ongoing
๐Ÿ”œ Summary statistics module Glucose metrics & treatment breakdowns Pending
๐Ÿ”œ Visual insights Time-series trends & stability graphs Pending
๐Ÿ“ฆ v1 release Published package + documentation Planned

๐Ÿค Contributing

Contributions, feedback, and ideas are welcome โ€” especially around:

  • Reader support for new formats

  • Statistical metrics

  • Visual analytics

  • Performance and robustness

  • Testing improvements

(Contribution guidelines will be available prior to first release.)


๐Ÿ›ก๏ธ Responsible Use

This tool is intended for retrospective data analysis only. It is not designed for real-time monitoring or medical decision-making. Always consult healthcare professionals for clinical guidance.

๐Ÿ“„ Licence

This project is licensed under the MIT Licence โ€” see full details here: MIT License