User Tools

Site Tools


tecnica:misc:contec_ecg_file_format

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tecnica:misc:contec_ecg_file_format [2020/11/29 06:41] – [File Header] niccolotecnica:misc:contec_ecg_file_format [2020/12/31 14:03] (current) – [Contec ECG90A Electrocardiograph - ECG File Format] niccolo
Line 1: Line 1:
 ====== Contec ECG90A Electrocardiograph - ECG File Format ====== ====== Contec ECG90A Electrocardiograph - ECG File Format ======
  
-This is my approach in the **reverse engineering** of **ECG file format** saved by the **[[http://www.contecmed.com/index.php?option=com_virtuemart&page=shop.product_details&flypage=flypage.tpl&category_id=11&product_id=97&Itemid=588|ECG90A]]** Electrocardiograph device, produced by **[[http://www.contecmed.com/|Contec]]**. Here you can find a **[[ecg_contec_90a|review]]** (in Italian) of the device.+This is my approach in the **reverse engineering** of **ECG file format** saved by the **[[http://www.contecmed.com/index.php?option=com_virtuemart&page=shop.product_details&flypage=flypage.tpl&category_id=11&product_id=97&Itemid=588|ECG90A]]** Electrocardiograph device, produced by **[[http://www.contecmed.com/|Contec]]**. The device can store an ECG case into the **microSD card**. During the ECG session, just choose the **Store** option as the print format, and then press the **Start** button.
  
-The device can store an ECG case into the **microSD card**. During the ECG session, just choose the **Store** option as the print format, and then press the **Start** button.+Here you can find a **Python program** to draw PDF or PNG electrocardiograms from ECG files: **[[https://github.com/RigacciOrg/ecg-contec|ecg-contec GitHub repository]]**.
  
 +Here you can find a **review** (in Italian) of the device: **[[ecg_contec_90a]]**.
 ===== File Header ===== ===== File Header =====
  
Line 56: Line 57:
 ===== Footer ===== ===== Footer =====
  
-After the data payload, the file is closed by **37 zero bytes**. This means two entire rows of zero samples, plus 5 zero bytes.+After the data payload, the file is closed by **37 bytes**. Generally they are **all zeros bytes**, but in some cases I have found a different value at position 26 (counting from 0): **0x0116** or **0x0016**. The different word is present in cases which does not have any obvious difference from the others.
  
-===== To Test an Confirm ===== +So it seems that the end of data can be detected by **an entire row of zeros** (16 bytes), or just skipping the last 37 bytes of the file
- +===== Electrodes connection detection =====
-FIXME Hypothesis to be confirmed: +
- +
-  - Confirm that **lead II** starts acquiring with just right arm and left leg electrodes (red and green). No: connection of the black electrode is required for the device to aknowledge that RA (right arm) is connected. No data is plotted untill all the four limb electrodes are in place. +
-  - Confirm that **lead III** starts acquiring with just left arm and the left leg electrodes (yellow and green). No: no data is plotted untill all the four limb electrodes are in place. +
-  - Confirm that leads **I****avL**, **avR** and **avF** starts acquiring with just three electrodes: red yellow and green. No: no data is plotted untill all the four limb electrodes are in place. +
-  - Confirm that **V1**, ..., **V6** starts acquiring with just the relative chest electrode and the right leg one (black)+
-  - Confirm that **V1**, ..., **V6** are in the expected order in data series.+
  
 +  - **Detection of connected electrodes**. The device requires that both the **right arm red** (RA) and **right leg black** elecrodes are connected to acknowledge that the red electrode is in place (the flashing RA red label disappear). However no ECG graph is traced unitll all the four limb leads are connected.
 +  -  Actually the **ECG90A requires that all the four limb electrodes are connected** to start acquiring something. In theory: to acquire **lead II** the **right arm** and the **left leg** electrodes should be sufficient; to acquire **lead III** the **left arm** and the **left leg** electrodes should be sufficient. This is because they are bipolar leads into the Einthoven triangle.
 +  - Also leads **I**, **avL**, **avR** and **avF** are plotted only when all the four limb electrodes are in place.
 +  - Leads **V1**, ..., **V6** starts acquiring with just the relative chest electrode and the right leg one (black).
  
 ===== Calculating the missing leads ===== ===== Calculating the missing leads =====
  
-Here are my hypothesis on how to calculate the leads not found into the data series. The guess must be validated by some strong evidences. FIXME+Here are the **formulas to calculate the values for leads** not included into the data series.
  
 From the formulas of voltages of **[[wp>Electrocardiography#Limb_leads|Limb_leads]]**, we have: From the formulas of voltages of **[[wp>Electrocardiography#Limb_leads|Limb_leads]]**, we have:
Line 109: Line 107:
 === SCP-ECG === === SCP-ECG ===
  
-The **[[wp>SCP-ECG]]** (Standard Communications Protocol for Computer-Assisted Electrocardiography) is the European standard for communication of resting ECGs. SCP-ECG (as per the accepted [[https://www.iso.org/standard/46493.html|ISO standard 11073-91064:2009]]) is widely accepted even if limited to short term resting ECG. Starting with version V3.0 (year 2014), the standard also provides support for the storage of continuous, **long-term ECG** recordings.+The **[[wp>SCP-ECG]]** (Standard Communications Protocol for Computer-Assisted Electrocardiography) is the European standard for communication of resting ECGs. SCP-ECG (as per the accepted **[[https://www.iso.org/standard/46493.html|ISO standard 11073-91064:2009]])** is widely accepted even if limited to short term resting ECG. Free documentation about the format is scarce, even the historical **[[https://webstore.ansi.org/standards/aami/ansiaamiec712001|ANSI/AAMI EC71:2001]]** is available only at astronomical price. 
 + 
 +The format is rather complicated; it can contain raw or **Huffman compressed** data, it allows custom and multiple Huffman tables, data sequences can be actual values or first or **second differences**, can store **QRS** and **rhythm data**, rhythm data can be stored as plain values or as **reference beat subtraction**, bimodal compression can be used too. In the face of all these complications, **only 65535 bytes** can be stored for each data set, which means that this format is **not suitable** for recordings lasting **more than thirty seconds**! 
 + 
 +Starting with version V3.0 (year 2014), the standard also provides support for the storage of continuous, **long-term ECG** recordings.
  
 === HL7 aECG === === HL7 aECG ===
Line 135: Line 137:
   * **[[https://pypi.org/project/dicom-ecg-plot/|Python Dicom ECG plot]]**   * **[[https://pypi.org/project/dicom-ecg-plot/|Python Dicom ECG plot]]**
   * **[[https://ecg.galliera.it/|DICOM ECG Viewer on-line]]** based on the Dicom ECG plot software   * **[[https://ecg.galliera.it/|DICOM ECG Viewer on-line]]** based on the Dicom ECG plot software
 +  * **[[https://www.edfplus.info/specs/edf.html|Full specification of EDF]]**
 +  * **[[http://ems12lead.com/2014/03/10/understanding-ecg-filtering/|Understanding ECG Filtering]]**
 +
 +  * **[[https://stackoverflow.com/questions/25191620/creating-lowpass-filter-in-scipy-understanding-methods-and-units|Creating lowpass filter in SciPy - understanding methods and units]]**
 +  * **[[https://stackoverflow.com/questions/13740348/how-to-apply-a-filter-to-a-signal-in-python/13740532|How To apply a filter to a signal in python]]**
 +  * **[[https://dsp.stackexchange.com/questions/49460/apply-low-pass-butterworth-filter-in-python|Apply Low pass Butterworth filter in Python]]**
 +  * **[[https://medium.com/analytics-vidhya/how-to-filter-noise-with-a-low-pass-filter-python-885223e5e9b7|How to filter noise with a low pass filter — Python]]**
 +  * **[[https://medium.com/swlh/noise-removal-for-a-better-fast-fourier-transformation-284918d4250f|Noise Removal For A Better Fast Fourier Transformation]]**
 +  * **[[https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.iirnotch.html|Design second-order IIR notch digital filter]]**
  
   * **Debian GNU/Linux Software**   * **Debian GNU/Linux Software**
Line 145: Line 156:
     * **[[https://www.teuniz.net/edfbrowser/]]**     * **[[https://www.teuniz.net/edfbrowser/]]**
     * **[[http://www.ecg-soft.com/ecgviewer/ecgviewer.htm]]**     * **[[http://www.ecg-soft.com/ecgviewer/ecgviewer.htm]]**
 +  * **Python Libraries**
 +    * **[[https://medium.com/analytics-vidhya/how-to-filter-noise-with-a-low-pass-filter-python-885223e5e9b7|How to filter noise with a low pass filter — Python]]**
 +    * **[[https://dsp.stackexchange.com/questions/49460/apply-low-pass-butterworth-filter-in-python|Apply Low pass Butterworth filter in Python]]**
 +    * **[[https://stackoverflow.com/questions/25191620/creating-lowpass-filter-in-scipy-understanding-methods-and-units|Creating lowpass filter in SciPy - understanding methods and units]]**
 +    * **[[https://dsp.stackexchange.com/questions/19084/applying-filter-in-scipy-signal-use-lfilter-or-filtfilt|Applying filter in scipy.signal: Use lfilter or filtfilt?]]**
 +    * **[[https://github.com/dy1901/ecg_plot|ECG plot]]**
  
tecnica/misc/contec_ecg_file_format.1606628505.txt.gz · Last modified: 2020/11/29 06:41 by niccolo