Converting a raw ECG .txt file

Hi there,

as (I think) many before I just downloaded and installed Octave to convert raw ECG Files into ECG graphs.

I use a Polar H10 with the polar equine app to check my horses heart.
The app itself has a great GUI with a live ECG monitor but unfortunately it saves the ECG data as .txt which I can’t convert (seem so). I tried some google solutions like

“data = importdata(‘HR_08.02.21_19.37.txt’)
x = data(:, 1);
y = data(:, 2);
plot(x, y, ‘b-’, ‘LineWidth’, 2);
title(‘ECG Signal’, ‘FontSize’, 20);
xlabel(‘Time’, ‘FontSize’, 20);
ylabel(‘Voltage’, ‘FontSize’, 20);
grid on;
% Enlarge figure to full screen.
set(gcf, ‘Units’, ‘Normalized’, ‘OuterPosition’, [0, 0.04, 1, 0.96]);”

But it displays error reports

x = data(:, 1);
y = data(:, 2);
error: data(_,2): out of bound 1 (dimensions are 1607x1)

plot(x, y, ‘b-’, ‘LineWidth’, 2);
error: ‘y’ undefined near line 1, column 1

title(‘ECG Signal’, ‘FontSize’, 20);
xlabel(‘Time’, ‘FontSize’, 20);
ylabel(‘Voltage’, ‘FontSize’, 20);
grid on;
% Enlarge figure to full screen.
set(gcf, ‘Units’, ‘Normalized’, ‘OuterPosition’, [0, 0.04, 1, 0.96]);

This is the mentioned file.

HR_08.02.21_19.37.txt (29.3 KB)

maybe someone can help me with this.

Thanks in advance :flushed:

You can skip header lines with importdata. See its documentation: doc importdata

For your file, try the following:

data = importdata('HR_08.02.21_19.37.txt', ' ', 6);

This will return a structure. You can access the data you are probably interested in with data.data.

data = importdata(‘C:\Users\Black\OneDrive\Documents\Polar\HR_08.02.21_19.37.txt’, ’ ', 6);
x = data(:, 1);
y = data(:, 2);
error: data(_,2): out of bound 1 (dimensions are 1x1)

plot(x, y, ‘b-’, ‘LineWidth’, 2);
error: ‘y’ undefined near line 1, column 1

title(‘ECG Signal’, ‘FontSize’, 20);
xlabel(‘Time’, ‘FontSize’, 20);
ylabel(‘Voltage’, ‘FontSize’, 20);
grid on;
% Enlarge figure to full screen.
set(gcf, ‘Units’, ‘Normalized’, ‘OuterPosition’, [0, 0.04, 1, 0.96]);

Still the same error reports

and if i just enter the first line nothing happens

Please, read what I wrote:

data = importdata('HR_08.02.21_19.37.txt', ' ', 6);
x = data.data(:, 1);
y = data.data(:, 2);

I’m not sure if the first two columns are what you are interested in. But I’m sure you’ll figure it out from there.

Unfortunately not so far… I’m pretty new to this whole topic. Sorry for the inconvenience

What did you try? And what errors/obstacles did you encounter?

Simply said I just “copy-pasted” the commands I found via google into the Octave GUI and thought I will achieve a result :sweat_smile: But it only opens the new window with the diagram axes

With the data you have collected, what are you expecting to see? What the plot should look like?

Leonardo

hopefully something like a real ECG plot :sweat_smile: :see_no_evil: or are the data insufficient? I literaly have no idea how to interprete the numbers in the txt file

if you run this command

data = importdata(‘HR_08.02.21_19.37.txt’, ’ ', 6);
HR = data.data(:,1);
RR = data.data(:,2);
ms = data.data(:,3);

you have values for HR, RR and ms.

The question is: “How to construct a ‘real’ ECG from RR data?”

I also found this: simulator of realistic ECG signal from rr data for matlab or python - Stack Overflow

but I have no idea of how it works.

Leonardo

P.S. “ms” seems to be the ‘real’ miliseconds of measure and RR (starting at i=2) is just ms(i) - ms(i-1)

Well, if you try to interpret the numbers in the text file, you need to have an idea what they mean.

Looking at the data, my guess would be that HR in the header stands for “heart rate”, RR might mean “repetition rate”, MS is probably the time in milliseconds and SKINCONTACT is kind of self explaining.

I’d try to plot(ms, HR) and check if that looks reasonable.