Electrocardiography

What does this channel measure?

From the ECG signal measures such as the heart rate, the interbeat interval, the heart rate variability and the T-wave amplitude are computed. The main variable extracted from this channel is the interbeat interval (IBI) which is the length of time between two successive heartbeats.

ANSLAB uses the saved IBIs from this channel to analyze the raw data of several other channels, so it is important to have a clean ECG file.

[Top]

Analysis procedure

After opening a raw data file, ANSLAB shows the filtered ECG for the first few seconds (5 by default; can be changed in the settings) of the data along with some estimated criteria. The automatic threshold criterion for detecting R-waves that was applied to the differentiated ECG is also depicted in the figure.

This threshold can be changed in the menu to make it more conservative (reducing false positives in noisy files) or more progressive (reducing false negatives in noisy files). You can also change the amplitude difference amount (rise) and the time window in which this difference has to be reached (default: 37 ms).

In case of very noisy data you can try using a differentiating algorithm for r-wave detection. This method is less prone to movement artifacts and baseline drifts, and you can adjust parameters of this detection process using the given adjustment dialogs.

Hint
It is possible rerun the R-wave detection algorithm at a later point, by using the 'resume at'-dropdown menu next to the 'resume'-button: Selecting '0' will restart the analysis without reloading the data. Thus, if you thoroughly edited the raw ecg signal, you can have ANSLAB check again the edited signal for R-Waves.
Moreover, this graph can help identifying sampling rate related problems: if in the displayed 5 seconds, you find more than 10 or less than 3 R-waves, it is likely that ANSLAB has wrong information about the sampling rate.

After accepting (or changing) the threshold (and other settings), ANSLAB calculates the IBI time series for the entire data file. The filtered ECG and R-wave detection accuracy can be inspected by switching the display mode from 'Event' to 'Raw'. In 'Raw' mode ANSLAB denotes each R-wave found with a vertical red line. The distance between vertical lines corresponds to the IBI. Typical values range from about 500-1300 ms. Variations of about 200-300 ms as part of normal heart rate variability within about 5 minutes are almost always normal. The following screenshot shows an example for an IBI trace:

The goal of editing ECG files is to make sure that ANSLAB has correctly identified the points in time for all R-waves. For spectral analysis of heart rate variability single spikes can seriously distort the spectral estimates. Thus, for this also certain subclinical or clinical arrhythmias (e.g. ectopic beats) need to be interpolated in some way (see below for details on r-wave editing).

Once the editing is completed, hit 'resume' to continue ecg processing. The next type of display, T-wave amplitudes, rarely requires editing since most outliers will be averaged out. After hitting 'resume' once more, you can choose 'Save reduced data' to save extracted variables to a file or 'quit' to exit editing without saving.
Notes on analyzing Respiratory Sinus Arrhythmia (RSA)
RSA generally should be analyzed in ANSLAB using the spectral-analysis tool. You can however get a glimpse of RSA during the ecg-analysis: when the IBI has been calculated, activate the PSD - option in the display-section of ANSLAB the command window. This will cause ANSLAB to transform the IBI trace to a uniform sampling rate and run a specific kind of spectral analysis (power-spectral-density) on this new signal.

RSA can then be quantified by measuring the power of three standard frequency bands (very low frequencies: 0.025 to 0.07 Hz; low frequencies: 0.07 to 0.15 Hz; high frequencies: 0.15 to 0.5 Hz. These bands can be visualized by activating the 'RSA bands'-option in the display section. Moreover, they are also printed to the MATLAB command window, from where you can copy and paste the values to a text file.

The PSD analysis results shown are based on the signal part shown in the data window allowing you to select the data segment of interest by modifying position and size of the displayed segment. Moreover, you can remove a general trend in the IBI-signal prior to PSD-calculation by using the 'trend'- and 'detrend'-options in the display section.

[Top]

What kind of artifacts are common in this channel?

When editing, you are looking for abnormalities in height of the spikes displayed in the IBI window. Artifacts in this data series, which appear as unusually low or high spikes, are misidentified or unidentified R-waves. A misidentified R-wave will appear in the first window as either 2 very short IBIs or 1 very short IBI coupled with an unusually long IBI.

If an R-wave is missing, you will see an unusually high IBI value, i.e. a high spike in the IBI series. The IBI then typically is twice as long as the average IBI for a subject. For example, an IBI that exceeds a threshold greather than 1400 would suggest a missed R-wave for most subjects.

ANSLAB displays a file entirely in one window. Depending on file length, artifacts may be quite obvious or more ambiguous. The shorter the file, the more subtle artifacts may appear. Always use the vertical axis (IBI in ms) when considering whether the signal contains a spike of unusual length.

[Top]

How are artifacts removed?

When you spot what appears to be an outlier in the graph use the 'define segments'-button on the command window and define segments for suspicious spikes in the signal. The best length for an interval is about 15-20 seconds. This will allow you to see both the overall pattern of R-waves and the individual irregularities. When finished, the defined intervals will be shown, highlighted with a grey background color.

You can then navigate between these intervals by using the 'segment' section on the command window. Push the '<<'-button to go to the first interval. The zoom will be set automatically such that the selected interval will cover the entire data window. Then push the 'Event/Raw'-toggle-button to switch to the raw ECG and the actually detected R-waves.

If the intervals defined are not ideal you may redefine intervals by again pressing the 'define segments'-button. If you wish to view the whole signal at once before redefining segments, press the 'total interval'-button in the 'zoom'-section.

Usually, what you will find is that one of the R-waves has not been detected because of some distortion in the data. A misidentified R-wave appears as a vertical line that ‘misses’ the nearest R-wave or a vertical line, which has mistaken a movement/technical artifact for an R-wave. It is almost always obvious where an R-wave should be.

Remove incorrect identifications by using the 'delete'-button in the editing section of the command window and click close to the vertical line. Insert the correct or missing R-wave with the 'insert'-button and then click in the signal where you want to insert the event.

There are also other editing options, suited for a number of special problems in ecg-editing: Carry out the editing for all segments you have defined earlier (you can easily navigate through all suspicious parts of the signal by using the controls in the navigation section).

Please keep in mind that the distances between R-waves do not have to be uniform. Hence, it is usually not recommended to remove correctly identified R-waves just to make the distance between them even. Editing in such a case should only be considered if the outlier distances are due to arrhythmic cardiac activity and you want to analyze heart rate variability later on.

By switching back to the 'Event'-display ANSLAB will redisplay the IBI trace with the changes made in raw mode. If the editing has been done correctly, the unusual spikes and dips should be gone now. If there are new abnormal spikes, the editing process can be repeated. Sometimes smaller artifacts, not as prominent as the ones in the first editing run, now show up as unusual.

A very quick way of outlier editing is the 'connect'-button which works differently in case of the IBI-trace as compared to other signal types (and only at the first analysis resume point). Use it to draw a rectangle around the good part of the data. Values inside the time span of the drawn rectangle with values above or below the drawn rectangle will be interpolated. Moreover, and this is the special part of the 'connect'-tool when used to edit an IBI trace, R-Wave markers are inserted automatically at corresponding locations.

Once all editing of the IBI trace is done, press 'resume' to continue with the next analysis step. The data window will now show the T-wave amplitudes (TWA), the RR intervals and the R-spike to T-wave (RT) intervals:

NOTE: the T-waves are always re-detected, no matter if you are editing a file for the first time or if you are loading already edited data. In other words: if you are editing T-waves this information is not loaded when loading already edited data but the T-waves are detected based on the IBI trace.

Similar to the IBI editing, you again may define segments to be able to easily jump to suspicious signal parts.


   



The T-waves are marked in red, the place where the R-wave was detected (but is now cut out) is marked in grey in the lower graph, that shows the original ECG. Here, you should focus on misdetected T-waves, mostly due to artifacts. Those will often be manifested by outliers, i.e. spikes. Go to the suspicious intervals. If in the data you cannot detect the T-wave (zoom in to make sure), but the program has detected T-waves, you should delete those. To do that, you can either use the delete -button as for R-wave-editing, or you can use the exlusion box-button. You do not have to be very accurate because typically the averaging over periods will overcome single outliers. Generally, you don’t have to insert any events. If you are done, push 'resume' and select "Save reduced data (existing files will be overwritten)" if you want to save your changes. That's it!

[Top]

What qualities must be preserved in editing?

The most important element of ECG editing is consistent and accurate identification of R-waves. Unlike other parameters that are often just used to compute minute-by-minute means, any outlier in the IBI affects the quality of the heart rate variability analysis.

[Top]

Special cases

Sometimes the ECG signal is unusual and the standard detection parameters do not work well. In ANSLAB, you will see a window that shows extremely long intervals between R-waves. Or ANSLAB will display a flat IBI line if no R-waves have been detected at all. This can usually be solved easily. Instead of manually inserting every R-wave, you can choose another threshold for R-spike detection. More advanced MATLAB users may also edit the header of the the R-spike detection program file to use other settings for the detection algorithm.

Changing one or more of the following detection parameters might help: If changing these settings does not significantly increase the number of R-waves detected, you can experiment raising or lowering 'Backward Comparison Point' and 'Increase from point in mV'.

[Top]

Extended options

If you want to open already edited data, check the 'load edited data'-option must be checked in the ecg options. When a raw file is opened for ecg analysis, ANSLAB then first checks whether analysis results are already available (inside the ecg subfolder in the study folder). If this is the case, the ecg analysis is not carried out again but the results from the previous analysis are loaded instead.

If no ecg measurement is available and the heart rate is calculated from a different cardiovascular channel such a pulse or blood pressure, you can still use the ecg module for IBI editing purposes. To do this, check the 'skip r-wave detection, take r-times from analysis'-option in the ecg options and enter the alternative analysis name, the channel subfolder name, the signal name, the signal type and the sampling rate of the signal to be used to allow ANSLAB to load the r-wave times from a different file. When now opening a raw data file for ecg analysis, ANSLAB will not try to load ecg raw data from the data file. Instead ANSLAB will search for a mat-file in the directory of the alternative analysis specified which belongs to the same subject and run as the selected raw file and has been processed as one entire datafile (adding 00 as segment number to the file name). If the file is found, ANSLAB will try to load the variable specified (the signal name) from this file, assuming the specified sampling rate. You can then edit the signal and save it by hitting the resume-button. Since no raw data is loaded, no data is displayed when switching to raw mode, except for the r-wave markers when zooming in sufficiently close.

[Top]

Analysis based on Polar data

If there are no raw ECG signals available ANSLAB also allows to carry out the ECG analysis based on text files containing either IBI values or r-times (see Data preparation).

The most efficient way of performing the analysis with such data is as follows:
  1. Rename all your Polar data text files to adhere to the ANSLAB naming convention and ensure that the file extension is '.txt' (see Data preparation)
  2. Create a batch file containing the text files and load it (see Main menu)
  3. Select 'Import IBI data' from the 'Tools'-menu. You will be prompted to choose the folder where the resulting .mat files should be stored. Create and choose the subfolder 'ecg' inside the ecg subfolder of your study folder. After the folder has been chosen, ANSLAB creates the .mat files for all the text files in the batch.
  4. In the 'TXT analysis options' (in the main menu 'tools -> options') enter 1000 Hz for the sampling rate and 1 for the column for the ecg data (EC).
  5. Finally, adjust the ecg analysis options. Check the option to skip the r-detection and specify 'ecg' in the analysis field. Furthermore specify the subfolder name 'ecg', choose the signal type 'RT' and signal name 'rt', and specify the sampling rate in the field SR (1000). The last step is to set the analysis sampling rate to 1000 Hz (otherwise the scale of the time axis will be wrong).
Note: Steps 4 and 5 have to be carried out only once per study since the respective options are stored in the options for your study.

In order to run an analysis (either batch or manual) ensure that the file format chosen is 'TXT'. Now you can open your Polar data text files like any other raw file and run the ecg analysis.

[Top]