Parse CARTO point signals
Full example code: examples/parser/carto_point_signal.py
Each datapoint has a corresponding ECG export file, for example 1-AT1260_P66_ECG_Export.txt. We can parse the point signals (Unipolar, bipolar, CS and ECG) from this file.
from dgmr.parser import CartoReader
pointfile = "path_to_your_point_signal_file"
signal_data = CartoReader.load_signal(pointfile)
print(signal_data[:5])
Output:
Unipolar Bipolar CS ECG
0 2.067 -0.075 0.003 -0.027
1 2.073 -0.087 -0.003 -0.024
2 2.079 -0.102 0.000 -0.024
3 2.082 -0.117 0.003 -0.021
4 2.082 -0.126 0.003 -0.021
We can also load the signals of multiple points by supplying the root file name (map name) and point idx. For example, if our map is called 1-AT1260 and we want to load signals of points with id 66, 67 and 68, the corresponding files will be
1-AT1260_P66_ECG_Export.txt1-AT1260_P66_ECG_Export.txt1-AT1260_P66_ECG_Export.txt
root = "your_folder" # Folder where the export files are located
filetag = "your_map_name" # Root file name
point_idx = [66, 67, 68]
signals_data = CartoReader.load_signals(root, filetag, point_idx)
Visualization
Using matplotlib, we can easily visualize the signals of a single point using the parsed data.
import numpy as np
import matplotlib.pyplot as plt
# Different channels of a single point
channels = ["Unipolar", "Bipolar", "CS", "ECG"]
fig, axs = plt.subplots(nrows=4)
for i, col in enumerate(channels):
arr = np.array(signal_data[col])
axs[i].plot(arr, label=col)
axs[i].legend(loc="upper right")
plt.tight_layout()
plt.show()

Or the same signal of multiple points. In this case, the ECG signal.
import numpy as np
import matplotlib.pyplot as plt
# ECG channel of different points
ecg_data = signals_data["ECG"]
ecg_array = np.array(ecg_data.tolist())
timesteps = np.arange(ecg_array.shape[1])
fig, ax = plt.subplots(figsize=(12,5))
for arr in ecg_array:
ax.plot(timesteps, arr)
plt.show()
