Skip to content

Python code for downloading data from a Contec CMS50D+ pulse oximeter

License

Notifications You must be signed in to change notification settings

timegrid/CMS50Dplus7

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contec CMS50D+ Pulse Oximeter v7.0 Data Interface
=================================================

This python script contains a GUI and CLI to access realtime and storage data
from a Contec CMS50D+ pulse oximeter (Communication Protocol v7.0).

Features
--------

CLI
- Print realtime data
- Dump realtime/storage data (CSV)

GUI
- Interactive plots of realtime/storage data
- Save plots (Image)
- Save/Load data (CSV)

Requirements
------------

- python (>=3.8)
- python modules
    - python-dateutil (>=2.8.1)
    - pyserial (>=3.4)
    - matplotlib (>=3.3.0)

Installation
------------

For virtualenv:

    $git clone https://github.com/timegrid/CMS50Dplus7.git
    $cd CMS50Dplus7
    $python -m venv env
    $source env/bin/activate
    $pip install -r requirements.txt

Syntax
------

usage: cms50dplus7.py [-h] [-c] [-d {realtime,storage}] [-p PORT] [-f FILENAME]
                      [-s STARTTIME] [-t]

Contec CMS50D+ v7.0 Data Interface (c) 2020 Alexander Blum, (c) 2015 atbrask

optional arguments:
  -h, --help            show this help message and exit
  -c, --cli             Use CLI mode.
  -p PORT, --port PORT  Virtual serial port of the device.
  -d {realtime,storage}, --datatype {realtime,storage}
                        Type of data.
  -f FILENAME, --filename FILENAME
                        Output CSV file.
  -s STARTTIME, --starttime STARTTIME
                        Start time for storage mode data [any parsable format].
  -t, --testdata        Use testdata, do not connect to the device.

The default port is /dev/ttyUSB0.
The default filename for the CLI storage dump is 'storage-<timestamp>.csv'.
The default starttime for the CLI storage dump is now().
The starttime may be any format parsable by dateutil.parser.

For CLI storage data you'll have to provide a starttime as the device doesn't
provide any historic timestamps at all.

Examples
--------

Start the GUI:

    $./cms50dplus7.py

Start the GUI, connect to port initially:

    $./cms50dplus7.py -p /dev/someport

Print realtime data on CLI:

    $./cms50dplus7.py -c

Dump realtime data via CLI by providing a filename:

    $./cms50dplus7.py -c -f 'realtime.csv'

Dump storage data via CLI, connect to port, set starttime:

    $./cms50dplus7.py -c -p '/dev/someport' -d storage -s '01.01.1970 00:00:00'

Samplerate
----------

In storage mode we assume a sample rate of 1 Hz.
In realtime data mode the device will sample at 60 Hz.

In the GUI all datapoints are always preserved internally and during save/load,
although the plotting may use a different samplerate to decrease the CPU load.
While recording, only those datapoints within the range of the plot are plotted.
When stopped, the whole timespan is used eventually. If the CPU load feels still
too high, you might try to set:
- 'CMS50DplusGui.plot_samplerate' to around 1-10 Hz
- 'CMS50DplusGui.plot_refreshrate' to around 100-1000 ms.

Tests
-----

The unittests cover most of the device functions and parsers but not the GUI.
To run the unittests:

    $./test.py

For manual testing without a device, provide the -t(estdata) flag

    $./cms50dplus7.py -t
    $./cms50dplus7.py -t -c

The code was written and tested with a Pulox PO-250 device.

Credit
------

This script is based on the CLI code by atbrask at https://github.com/atbrask/CMS50Dplus
for the Communication Protocol v5.0 and updated for v7.0 according to 
https://github.com/InfantLab/Contec-Pulse-Oximeter-in-Matlab/blob/master/Communication%20protocol%20of%20pulse%20oximeter%20V7.0.pdf

About

Python code for downloading data from a Contec CMS50D+ pulse oximeter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%