Page 1 of 1

offline heart rate extraction from ECG signal

Posted: Sat Aug 09, 2008 5:14 pm
by mbinder
I have acquired raw ECG signals with EXG electrodes and now I'd like to extract /convert them into HR values.

Do you know any NI VI or any easy-to-implement algorithm for an offline HR data extraction from analog ECG data acquired with BioSemi ActiveTwo?

Any help greatly appreciated! :)


Posted: Mon Aug 11, 2008 6:23 pm
by Coen
A VI to calculate the heartrate from 2 EX channels is available for download from , I have written this VI a few years ago for online heartrate calculation (was included in some custom versions of ActiView), but you can of course use it in off-line applications just as well.

Best regards, Coen (BioSemi)

Posted: Wed Apr 20, 2011 10:43 am
by Pascal
I had quiet the same question as mbinder. I acquired ECG signals and are now trying to calculate them into HR values. Since I never used Labview before, I have some problems in reading and usign the VI. Is there a "how to" or sth similar I could use.

kind regards
pascal :)

Posted: Fri May 04, 2012 7:21 pm
by Teuniz
You can also use EDFbrowser to extract heartrate values from raw ECG-data.

Re: offline heart rate extraction from ECG signal

Posted: Wed Jan 04, 2017 5:28 pm
by echoinsist
Hi Coen,
The HR value you mentioned is heart rate variability? and how to use the VI to extract? Thanks in advance.


Re: offline heart rate extraction from ECG signal

Posted: Tue Apr 17, 2018 11:57 am
by liming
I am using EX8 electrode and CMS,DRL as reference to get my ECG data. However, i had some problem. The ECG diagram is good and R peaks were obvious in Actiview Two but when i receive the voltage data by c++ algorithm ,it seems not so clear,such as -35768, -25674,- 9.25596e+61,3.4825567e+06. As far as i know, the ECG voltage ranges from -0.6 to 0.6 mv. How could i get the correct data?
This is my c++ code acquiring ECG data from Actiview Two:
(32+8EX channels,256Hz)

buffer_idx = 0;
char data[MSGSIZE];
recv(sock, data, MSGSIZE, 0);

for (int channel = 0; channel < (32 + ; ++channel){
complex<double> sample[40];
double samp[40];
for (int m = 0; m < 2; ++m){
int offset = 3 * (m * (32 + + channel);
samp[channel] = (data[offset + 2] << 16);
samp[channel] += (data[offset + 1] << ;
samp[channel] += data[offset];
sample[channel] = samp[channel];

Look forward to your reply.

Re: offline heart rate extraction from ECG signal

Posted: Tue Apr 17, 2018 2:25 pm
by Coen
ECG/EEG/EMG is measured BETWEEN two (or more) electrodes. The signal of a single electrodes with respect to CMS (raw, unreferenced) is not a valid signal, see

So, for ECG use (at least) two electrodes on the chest and subtratc the signals in sofwtare.

The scaling for active electrode systems is:

32-bit words from USB-reciever: divide by 8192 (32*256) to convert to microVolt
24-bit words in the BDF file: divide by 32 to convert to microVolt

Note: custom systems for passive electrodes have 1/4th of the above gain (divide by respectively 32768 and 128)

Note that the system uses a DC amplifier. Therefore, the ECG/EEG/EMG signal is superimposed on a relatively large (typically several tens of milliVolt) electrode offset voltage. Use a high-pass filter or baseline correction to cancel the DC offset and extract the biopotentials.

Best regards, Coen (BioSemi)

Re: offline heart rate extraction from ECG signal

Posted: Thu Apr 19, 2018 4:22 am
by liming
Hi, Coen
Thank you for your reply! Now I am using EX7 and EX8 which are placed under my left and right collarbone to acquire ECG data. Reference electrode CMS on my left thumb and DRL on my right thumb, is that connection correct? I used c++ algorithm to get 24bits ECG data from Actiview via TCP/IP. So that is to say, i have to record EX7 and EX8 and calculate EX7-EX8,then the EX7-EX8 divided by(256*24)is final ECG(uv)?And what are the active electrodes and passive electrodes ?

Best regards,Lee

Re: offline heart rate extraction from ECG signal

Posted: Thu Apr 19, 2018 1:57 pm
by Coen
CMS on the center of the chest may give better CMRR, DRL can be anywhere on the body.

Divide the 24-bit results by 32 to scale the values to microVolt.

You are using active electrodes (preamp integrated with electrode), ignore the remark about passive electrodes.

Best regards, Coen (BioSemi)

Re: offline heart rate extraction from ECG signal

Posted: Fri Apr 20, 2018 3:03 am
by liming
Your reply is very useful to me.One last question. In the Bipolar Leads display mode, i could see very good ECG diagram like obvious R peaks and stable T wave(row EX7 - EX8).However, in Monopolor Display mode,the diagrams of EX7 and EX8 look like noise(no obvious peaks and troughs).Nevertheless, i can only record data of mono-channel. Should i just record EX7 and EX8 respectively without considering their diagrams and use EX7 subtracts EX8 ? Do you have other online method acquire EX7-EX8 in Bipolar Leads display mode directly?
Sincerely Yours

Re: offline heart rate extraction from ECG signal

Posted: Mon Apr 23, 2018 3:29 pm
by Coen
You should indeed record both E7 and E8 (use the "add 8 EX electrodes" in the TCP/IP tabpage) . The noise that you see in the raw E7 and E8 signals is mainly Common Mode (same noise for both channels). When you calculate E7-E8, then the Common Mode noise is canceled out, and the ECG remains (this is what ActiView does for the bipolar leads).

Best regards, Coen (BioSemi)