1
+ import pandas as pd
2
+ import numpy as np
3
+ import matplotlib .pyplot as plt
4
+ from scipy .signal import find_peaks
5
+
6
+ # Load the dataset with comma as delimiter
7
+ df = pd .read_csv ("lab5_Philco-L05.txt" , delimiter = "," )
8
+
9
+
10
+ time = df .iloc [:, 0 ]
11
+
12
+ # Get the Channel data
13
+ data = df .iloc [:, 1 ]
14
+
15
+ time_subset = time [:10000 ]
16
+
17
+ df_subset = data [:10000 ]
18
+
19
+
20
+ p_indices = [110 , 910 , 1670 , 2490 , 3300 , 4085 ]
21
+ q_indices = [219 , 1018 , 1785 , 2605 , 3400 , 4160 ]
22
+ r_indices = [257 , 1052 , 1825 , 2641 , 3450 , 4238 ]
23
+ s_indices = [284 , 1079 , 1851 , 2663 , 3474 , 4265 ]
24
+ t_indices = [460 , 1250 , 2020 , 2840 , 3650 , 4436 ]
25
+
26
+ # Plot the ECG signal
27
+ plt .figure (figsize = (10 , 6 ))
28
+ plt .plot (time_subset , df_subset , label = 'ECG Data' )
29
+ plt .xlabel ('Time' )
30
+ plt .ylabel ('Data' )
31
+ plt .title ('ECG Data from Joaquin Philco' )
32
+ plt .grid (True )
33
+
34
+
35
+ # Marking P Features
36
+ plt .scatter (time_subset [p_indices ], df_subset [p_indices ], color = 'black' , marker = 'x' , label = 'P' )
37
+
38
+ # Marking Q Features
39
+ plt .scatter (time_subset [q_indices ], df_subset [q_indices ], color = 'purple' , marker = 'x' , label = 'Q' )
40
+
41
+ # Marking R Features
42
+ plt .scatter (time_subset [r_indices ], df_subset [r_indices ], color = 'green' , marker = 'x' , label = 'R' )
43
+
44
+ # Marking S Features
45
+ plt .scatter (time_subset [s_indices ], df_subset [s_indices ], color = 'red' , marker = 'x' , label = 'S' )
46
+
47
+ # Marking T Features
48
+ plt .scatter (time_subset [t_indices ], df_subset [t_indices ], color = 'black' , marker = 'x' , label = 'T' )
49
+
50
+ plt .xlabel ('Time' )
51
+ plt .ylabel ('Data' )
52
+ plt .title ('ECG Data with QRS Features' )
53
+ plt .legend ()
54
+ plt .grid (True )
55
+ plt .show ()
0 commit comments