Skip to content

Create a Signals object

Full example code: examples/signal/signals_object.py

To create a signals object, we need an array of numbers representing our signal over time. For example

[-0.027 -0.024 -0.024 ... -0.018 -0.018 -0.018]

Rather than the signal of a single point, you can also pass multiple signals at once. Either the same type for multiple points or different types of signals of a single point. This allows to apply filters or set annotations on all signals at once.

[[-0.027 -0.024 -0.024 ... -0.018 -0.018 -0.018]
 [-0.12  -0.132 -0.144 ...  0.03   0.03   0.03 ]
 [-0.042 -0.039 -0.036 ... -0.009 -0.009 -0.009]]

Signals Object

To create your object, simply pass the array to the constructor. Both a single or 2d array will work. In our example, we have an ecg signals of 3 different points.

ecg_array = ... # Your array with signal data
ecg_signals = Signals(ecg_array)

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

Basic signals

Signals properties

To set properties of your signals which can later be used for filtering or annotations, we have setter methods.

print(Signals.__setters__)

will give you a full list of properties you can set.

Setters

ecg_signals = Signals(ecg_array)
ecg_signals.set_averaging_window_length(20)
ecg_signals.set_threshold(0.11)

We also allow chaining setter methods together.

ecg_signals = (
    Signals(ecg_array)
    .set_averaging_window_length(20)
    .set_threshold(0.11)
)

Or through the use of a dictionary.

properties = {
    "averaging_window_length": 20,
    "threshold": 0.11,
    "min_peak_distance": 100
}
ecg_signals = Signals(ecg_array)
ecg_signals.set_properties(properties)

Or any combination of the above.


← Previous: Signals Overview Next: Filter your signals →