Skip to content

Parse Rhythmia point signals

Full example code: examples/parser/rhythmia_point_signal.py

Note

You need an advanced Rhythmia export for the matlab file to contain signal data. By default, signals are not part of the exported data.

We can easily parse and visualise the point signals after parsing the matlab file.

from dgmr.parser import RhythmiaReader

mat_file = "path_to_your_matlab_file"
data = RhythmiaReader.load_mat_file(matfile)

# Single point
point_id = 22
signal_data = RhythmiaReader.load_signal(data, point_id)

# Multiple points
point_idx = [22, 23, 24]
signals_data = RhythmiaReader.load_signals(data, 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

ecg_data = signal_data["ECG"]
timesteps = np.arange(len(ecg_data))

fig, ax = plt.subplots(figsize=(8, 6))
ax.plot(timesteps, ecg_data)
plt.show()

Types of singal of a single point

Or the signal of multiple points. In this case, the ECG signal.

import numpy as np
import matplotlib.pyplot as plt

ecg_data = signals_data["ECG"]
ecg_array = np.array(ecg_data.tolist())
timesteps = np.arange(ecg_array.shape[1])

fig, ax = plt.subplots(figsize=(8, 6))
for arr in ecg_array:
    ax.plot(timesteps, arr)
plt.show()

Types of singal of a single point