Software Open Access

R-DECO: An open-source Matlab based graphical user interface for the detection and correction of R-peaks

Jonathan Moeyersons Matthew Amoni Sabine Van Huffel Rik Willems Carolina Varon

Published: Sept. 8, 2020. Version: 1.0.0

When using this resource, please cite: (show more options)
Moeyersons, J., Amoni, M., Van Huffel, S., Willems, R., & Varon, C. (2020). R-DECO: An open-source Matlab based graphical user interface for the detection and correction of R-peaks (version 1.0.0). PhysioNet.

Additionally, please cite the original publication:

Moeyersons J, Amoni M, Van Huffel S, Willems R, Varon C. 2019. R-DECO: an open-source Matlab based graphical user interface for the detection and correction of R-peaks. PeerJ Computer Science 5:e226

Please include the standard citation for PhysioNet: (show more options)
Goldberger, A., Amaral, L., Glass, L., Hausdorff, J., Ivanov, P. C., Mark, R., ... & Stanley, H. E. (2000). PhysioBank, PhysioToolkit, and PhysioNet: Components of a new research resource for complex physiologic signals. Circulation [Online]. 101 (23), pp. e215–e220.


Many of the existing ECG toolboxes focus on the derivation of heart rate variability features from RR-intervals. By doing so, they assume correct detection of the QRS-complexes. However, it is highly likely that not all detections are correct. Therefore, it is recommended to visualize the actual R-peak positions in the ECG signal and allow manual adaptations.

As a solution, we present R-DECO, an easy-to-use graphical user interface for the detection and correction of R-peaks. Within R-DECO, the R-peaks are detected by an adaptation of the Pan-Tompkins algorithm. Instead of using all the pre-processing steps of the latter algorithm, the proposed algorithm uses only an envelope-based procedure to flatten the ECG and enhance the QRS-complexes. The algorithm obtained an overall sensitivity of 99.60% and positive predictive value of 99.69% on the MIT/BIH arrhythmia database. Additionally, R-DECO includes support for several input data formats for ECG signals, three basic filters, the possibility to load other R-peak locations and intuitive methods to correct ectopic, wrong, or missed heartbeats. All functionalities can be accessed via the graphical user interface and the analysis results can be exported as Matlab or Excel files. 

Through its easy-to-use-graphical user interface, R-DECO allows both clinicians and researchers to use all functionalities, without previous knowledge. R-DECO has been developed on Windows 10 using Matlab 2018a. GUIDE, MATLAB’s GUI development environment, was used to design the GUI of R-DECO. It has been tested and proven to be functional for older Matlab versions going back to Matlab 2016a.


R-DECO is the first step toward a complete ECG processing tool. At the moment, it focuses on accurate R-peak detection and intuitive correction options. Therefore, it is a complementary tool for existing heart rate variability (HRV) analysis toolboxes, which tend to focus on the computation of HRV metrics from RR-intervals. Although some toolboxes already provide the possibility to detect R-peaks, their possibility to correct R-peak annotations is rather limited [1-3]. Additionally, to the best of our knowledge, none of the existing toolboxes provide filtering, R-peak detection and correction all together.

The main advantage of R-DECO, according to the authors, is the easy-to-use, intuitive GUI. All actions are performed in one window, which simplifies the use and reduces the learning time.

Several extra features are being developed and will be released in future versions. We intend to add support for other input file formats, such as hierarchical data format 5 files, general data format files, etc. However, most improvements will be in the number of analysis options. Some of the first extra analysis options will be automatic signal quality detection, ECG derived respiration (EDR) and HRV-analysis.

Software Description

This section contains a description of R-DECO. The repository of the current software is hosted on GitLab [4].

The software package consists of three main folders: one folder with signal examples and two function folders. Unless you want to make changes to the codes, there is no need to access these folders. The main function is called 'R_DECO'. Execution of this function adds all the underlying folders and subfolders to the path and opens the GUI. 

The software allows to load data from a folder or from the matlab workspace. As an example, you could load 'Single_lead_ECG_250Hz.mat'. This is a .mat example file which can be found in the examples folder. The software first tries to find a sampling frequency, but if this is not present, it will prompt a question dialog in which you can input the sampling frequency. 

Before detecting the R-peaks, there are a couple of pre-processing steps that are available. Three basic filters are included in the program, a high, low and stopband filter. The order of the filters can be adjusted in the 'Preferences' tab. If you want to implement different filters, that is also possible in the 'filtersignal.m' code. Additionally, you can also select an analysis period. This might be useful if you have a long signal and only want to analyse a small section. 

R-peaks can be detected by pushing the 'Detect Peaks' button. This will call an algorithm for the detection of R-peaks which is developed in our group. The QRS-complexes are highlighted by an enveloping procedure and peaks are detected in the resulting signal. A more elaborate description can be found in the paper [5]. 

Hereafter, the peaks can be investigated. It is possible to use the zoom button, to have a closer look, or to change the range of the x-axis manually. The slider can be used to slide through the signal. 

The R-peak location can be corrected in a semi-automated or manual fashion. We included three semi-automated methods:

  • The first method creates a template QRS-complex, by taking the trimmed mean of all the beats. The user can manually indicate the correct location of the R-peak and this is matched with all heartbeats using cross-correlation.
  • The second method is called peak conversion. Sometimes it happens that when a peak is correctly annotated in the enveloped signal, it does not perfectly align with the peak in the raw signal. Peak conversion shifts the annotation towards the closest extremum. 
  • The third method allows the user to do a maximum, minimum or absolute maximum search in a pre-defined search window. 

The peaks can also be adjusted manually. This can be done by right clicking on the desired peak or by selecting one of the radio buttons. The user can add, adjust or delete peaks and the RR or HR traces are adjusted automatically. A more detailed description can be found in the paper. 

The resulting R-peak locations and respective RR-intervals can be exported as a .mat file or as an Excel workbook.

Installation and Requirements


  1. Install Matlab, if you have not already done so
  2. Download all files and folders
  3. Open Matlab and open the folder that contains the toolbox
  4. Open and run "R_DECO.m".


  • R-DECO requires Matlab and, more specifically, the signal processing toolbox of Matlab. 
  • It is not possible to run R-DECO using GNU Octave.

Usage Notes


  1. Open Matlab and open the folder that contains the toolbox.
  2. Open and run "R_DECO.m".
  3. Click the "From File" button in the "Data" panel in the top left corner.
  4. Open the "Examples" folder and subsequently open the "MATLAB" folder.
  5. Select and open "Single_lead_ECG_250Hz.mat".
  6. You will be prompted to enter the sampling frequency. Type 250 and press "OK".
  7. Based on visual inspection, baseline wander seems to be present. This can be investigated in the frequency domain by pressing the "Check PSD" button in the "Filter" panel. 
  8. Type 0.66 next to "High pass" and press the "Filter" button. This will high-pass filter the signal with a second order Butterworth filter.
  9. The difference with the original signal can be visually compared by checking the "Show original" checkbox.
  10. Press the "Define analysis period" button in the "Analysis Period" panel. 
    • If you go over the signal plot, this will prompt a vertical line, which represents the starting line of the analysis period. 
  11. Click and hold down the left mouse button at 00:03:00 and drag the cursor to 00:04:00. 
    • In case the window limits are not accurate, there are two options: 
      • Drag the start and stop line or the entire window to the desired location with your mouse. 
      • Type the desired start time and duration in the "Analysis Period" panel.
  12. Press the "Apply changes" button to confirm the analysis window. 
  13. Press the "Detect Peaks" button to detect the R-peaks.
  14. Use the default parameter values and press "OK" in the bottom right corner.  
  15. From the tachogram, the bottom plot, an ectopic can be observed at time point 00.03.18. Right click the R-peak in the signal plot and select the desired option to deal with it. 
  16. When finished with the adaptations, press the "Menu" button in the top left corner, go to "Export Results" and press "To Workspace". 
  17. Perform the desired follow-up analysis with the exported ECG signal, R-peaks and RR-intervals.


The research leading to these results has received funding from the European Research Council under the European Union’s Seventh Framework Programme (FP7/2007-2013) / ERC Advanced Grant: BIOTENSORS (n339804). This paper reflects only the authors’ views and the Union is not liable for any use that may be made of the contained information. RW is a Senior Clinical Investigator of the Research Foundation - Flanders (FWO).   

Grant details: Bijzonder Onderzoeksfonds KU Leuven (BOF): SPARKLE: IDO-10-0358, The effect of perinatal stress on the later outcome in preterm babies: C24/15/036, TARGID: C32-16-00364; Agentschap Innoveren & Ondernemen (VLAIO): Project: STW 150466 OSA + O&O HBC 2016 0184 eWatch; imec: SBO-2016, ICON: HBC.2016.0167 SeizeIT; European Research Council.

Conflicts of Interest

No conflicts of interest.


  1. Pichot V, Roche F, Celle S, Barthélémy J, Chouchou F. 2016. HRVanalysis: A Free Software for Analyzing Cardiac Autonomic Activity, Frontiers in Physiology, 7, 557,
  2. Niskanen J-P, Tarvainen MP, Ranta-aho PO, Karjalainen PA. 2004. Software for advanced HRV analysis. Comp Meth Programs Biomed, 76(1), 73-81.
  3. Kaufmann T, Sütterlin S, Schulz S, Vögele C. 2011. ARTiiFACT: a tool for heart rate artifact processing and heart rate variability analysis. Behavior Research Methods, 43(4), 1161-1170. doi:10.3758/s13428-011-0107-7
  4. R-DECO Code Repository on GitLab:
  5. Moeyersons J, Amoni M, Van Huffel S, Willems R, Varon C. 2019. R-DECO: an open-source Matlab based graphical user interface for the detection and correction of R-peaks. PeerJ Computer Science, 5(226),


Access Policy:
Anyone can access the files, as long as they conform to the terms of the specified license.

License (for files):
GNU General Public License version 3

Corresponding Author
You must be logged in to view the contact information.


Total uncompressed size: 930.6 KB.

Access the files
Folder Navigation: <base>
Name Size Modified
LICENSE.txt (download) 34.9 KB 2020-08-21 (download) 1.3 KB 2020-05-19
R_DECO.m (download) 1.9 KB 2020-05-19
SHA256SUMS.txt (download) 4.0 KB 2020-09-08