Data Organization in ECG Analysis: Separate Leads or Individual Si... (2024)

24 views (last 30 days)

Show older comments

rawaa mejri about 10 hours ago

  • Link

    Direct link to this question

    https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals

  • Link

    Direct link to this question

    https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals

Commented: Star Strider about 3 hours ago

Dear Matlab Community,

I am currently in the process of planning data organization for an ECG analysis using the PTB-XL dataset, and I would like to seek your advice and expertise on a specific question.

When it comes to data organization, is it recommended to use each lead separately (12 leads --> 12 columns)? Or would it be preferable to adopt an approach where each row represents a distinct ECG signal?

I would greatly appreciate insights and recommendations from those who have experience in this area.

Thank you very much for your valuable contribution.

Best regards,

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

Answers (1)

Star Strider about 6 hours ago

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#answer_1463331

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#answer_1463331

I am not certain what you want to do, or what question you are asking. In general, EKG data are analysed column-wise, with a time vector (generally beginning at zero with regular sampling intervals and a sampling frequency at least 256 Hz and 1 kHz if possible) for the first column, and each lead being successive columns, ordered characteristically as Data Organization in ECG Analysis: Separate Leads or Individual Si... (3) . This also is the way MATLAB data matrices in general are organised.

10 Comments

Show 8 older commentsHide 8 older comments

rawaa mejri about 6 hours ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171671

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171671

Thank you for your response @Star Strider ,

To clarify, Do we use a single temporal vector for all (one column only), or do we create a temporal vector for each lead? For instance, for lead I, do we have a column called time_I (12 leads -> 12 temporal vectors)? Is that correct? Or do we have a single temporal vector (one column only) for all 12 leads (12 columns)?

Star Strider about 5 hours ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171691

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171691

My pleasure!

I’m not sure what you mean by ‘temporal vector’. There is characteristically one time vector in the first column, and each corresponding EKG lead in columns 2-13 (2-14 if Data Organization in ECG Analysis: Separate Leads or Individual Si... (6) is included). All the leads are collected and recorded at the same times, those times given in the first-column time vector.

Collectting them serially is not appropriate, because natural variations in heart rate in a normal, healthy heart make the serial records ininterpretable when aggregated. They must all be collected and recorded at the same times.

rawaa mejri about 5 hours ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171696

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171696

Thanks a lot for your help !

I understand! Just one last question: in the PTB-XL dataset, I have a .dat file and a .hea file. I suppose I should use the .hea file to extract the leads. Regarding the time vector, should I generate it based on the sampling frequency provided?

Star Strider about 4 hours ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171721

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171721

Open in MATLAB Online

My pleasure!

I am not familiar with that dataset. If you do not already have a time vector provided with it, you can create one using the linspace function —

EKG = rand(10,12); % EKG Data

Fs = 256; % Sampling Frequency

Time = linspace(0, size(EKG,1)-1, size(EKG,1)).'/Fs; % Synthetic Time Vector

EKG_Matrix = [Time EKG]

EKG_Matrix = 10x13

0 0.4856 0.4760 0.7745 0.4151 0.9988 0.3865 0.1495 0.0096 0.3425 0.5348 0.8598 0.7829 0.0039 0.2463 0.4456 0.8281 0.5107 0.2525 0.9103 0.6471 0.9814 0.8694 0.4492 0.7721 0.6395 0.0078 0.0309 0.3216 0.8742 0.5227 0.1697 0.0887 0.3554 0.8075 0.9444 0.6633 0.4132 0.8197 0.0117 0.8595 0.4542 0.1945 0.4590 0.8822 0.3897 0.8010 0.4530 0.7423 0.4072 0.3338 0.5004 0.0156 0.6430 0.4124 0.0590 0.6767 0.2136 0.2213 0.6985 0.4550 0.9520 0.1370 0.3643 0.0842 0.0195 0.2821 0.6850 0.2601 0.8432 0.0871 0.4847 0.4177 0.0077 0.2032 0.9331 0.3941 0.1442 0.0234 0.8091 0.6667 0.7804 0.9966 0.2299 0.6895 0.8777 0.4294 0.6993 0.5283 0.4722 0.7945 0.0273 0.3704 0.8445 0.5042 0.5735 0.3571 0.5817 0.5753 0.2384 0.2834 0.7878 0.5440 0.5434 0.0312 0.7034 0.0919 0.8106 0.9310 0.7157 0.6494 0.4306 0.1360 0.6325 0.9629 0.2411 0.9952 0.0352 0.4809 0.0332 0.9774 0.0175 0.4227 0.0604 0.3911 0.7998 0.9508 0.4208 0.3304 0.4006

<mw-icon class=""></mw-icon>

<mw-icon class=""></mw-icon>

figure

plot(EKG_Matrix(:,1), EKG_Matrix(:,2:end)+[1:size(EKG_Matrix,2)-1]*2)

grid

ylim('padded')

xlabel('Time')

legend(compose('Lead %s',["I","II","III","aV_R","aV_L","aV_F","V_1","V_2","V_3","V_4","V_5","V_6"]), 'Location','eastoutside')

Data Organization in ECG Analysis: Separate Leads or Individual Si... (9)

.

rawaa mejri about 4 hours ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171741

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171741

Thank you again for your invaluable assistance. Following your recommendations, I have selected the first example and tried it out. Here are the signals; based on your experience, are they correct? Here are the data in the file .hea:

00001_lr 12 100 1000

00001_lr.dat 16 1000.0(0)/mV 16 0 -119 1508 0 I

00001_lr.dat 16 1000.0(0)/mV 16 0 -55 723 0 II

00001_lr.dat 16 1000.0(0)/mV 16 0 64 64758 0 III

00001_lr.dat 16 1000.0(0)/mV 16 0 86 64423 0 AVR

00001_lr.dat 16 1000.0(0)/mV 16 0 -91 1211 0 AVL

00001_lr.dat 16 1000.0(0)/mV 16 0 4 7 0 AVF

00001_lr.dat 16 1000.0(0)/mV 16 0 -69 63827 0 V1

00001_lr.dat 16 1000.0(0)/mV 16 0 -31 6999 0 V2

00001_lr.dat 16 1000.0(0)/mV 16 0 0 63759 0 V3

00001_lr.dat 16 1000.0(0)/mV 16 0 -26 61447 0 V4

00001_lr.dat 16 1000.0(0)/mV 16 0 -39 64979 0 V5

00001_lr.dat 16 1000.0(0)/mV 16 0 -79 832 0 V6

here the first rows of data :

Data Organization in ECG Analysis: Separate Leads or Individual Si... (11)

rawaa mejri about 4 hours ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171746

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171746

here are the ecg signal , leads :

Data Organization in ECG Analysis: Separate Leads or Individual Si... (13)

Data Organization in ECG Analysis: Separate Leads or Individual Si... (14)

rawaa mejri about 4 hours ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171751

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171751

@Star Strider Thanks a lot

Star Strider about 2 hours ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171806

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171806

Open in MATLAB Online

My pleasure!

That appears to be correct, and the timing appears to be approppriate (about 66 bpm).

The only change I would make is the order of the plots. The most common arrangement is something like this —

EKG = rand(100,12); % EKG Data

Fs = 256; % Sampling Frequency

Time = linspace(0, size(EKG,1)-1, size(EKG,1)).'/Fs; % Synthetic Time Vector

EKG_Matrix = [Time EKG];

Leads = ["I","II","III","aV_R","aV_L","aV_F","V_1","V_2","V_3","V_4","V_5","V_6"];

figure

tiledlayout(6,2)

for k = 1:6

nexttile(2*k-1)

plot(EKG_Matrix(:,1), EKG_Matrix(:,k+1))

grid

title(Leads(k))

end

for k = 1:6

nexttile(2*k)

plot(EKG_Matrix(:,1), EKG_Matrix(:,k+6))

grid

title(Leads(k+6))

end

Data Organization in ECG Analysis: Separate Leads or Individual Si... (17)

Another common format —

figure

tiledlayout(3,4)

for k = 1:3

nexttile(4*k-3)

plot(EKG_Matrix(:,1), EKG_Matrix(:,k+1))

grid

title(Leads(k))

end

for k = 1:3

nexttile(4*k-2)

plot(EKG_Matrix(:,1), EKG_Matrix(:,k+4))

grid

title(Leads(k+3))

end

for k = 1:3

nexttile(4*k-1)

plot(EKG_Matrix(:,1), EKG_Matrix(:,k+7))

grid

title(Leads(k+6))

end

for k = 1:3

nexttile(4*k)

plot(EKG_Matrix(:,1), EKG_Matrix(:,k+10))

grid

title(Leads(k+9))

end

Data Organization in ECG Analysis: Separate Leads or Individual Si... (18)

That would actually look corect if I had your data to plot.

.

rawaa mejri about 2 hours ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171831

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171831

Thanks a lot for your help !

Star Strider about 2 hours ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171836

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2122541-data-organization-in-ecg-analysis-separate-leads-or-individual-signals#comment_3171836

My pleasure!

Sign in to comment.

Sign in to answer this question.

See Also

Tags

  • signal processing
  • ptb-xl dataset
  • data organization
  • ecg
  • leads

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


Data Organization in ECG Analysis: Separate Leads or Individual Si... (21)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

Contact your local office

Data Organization in ECG Analysis: Separate Leads or Individual Si... (2024)

References

Top Articles
Latest Posts
Article information

Author: Duncan Muller

Last Updated:

Views: 6427

Rating: 4.9 / 5 (79 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Duncan Muller

Birthday: 1997-01-13

Address: Apt. 505 914 Phillip Crossroad, O'Konborough, NV 62411

Phone: +8555305800947

Job: Construction Agent

Hobby: Shopping, Table tennis, Snowboarding, Rafting, Motor sports, Homebrewing, Taxidermy

Introduction: My name is Duncan Muller, I am a enchanting, good, gentle, modern, tasty, nice, elegant person who loves writing and wants to share my knowledge and understanding with you.