Skip to content

Add normilize function #12

Description

@NikolayTsvetkovv

In case if you have different values which need be plot for ECG let say some numbers like -23.000... or 3.000. It will be nice to have this function:

def normalize_data(ecg_data):
"""Normalize ECG data to the range of -1 to 1."""
ecg_data = (ecg_data - np.min(ecg_data)) / (np.max(ecg_data) - np.min(ecg_data))
ecg_data = 2 * ecg_data - 1 # Normalize to -1 to 1
return ecg_data

def plot_12(
ecg,
sample_rate=500,
title='ECG 12',
lead_index=lead_index,
lead_order=None,
columns=2,
speed=50,
voltage=20,
line_width=0.6
):
# Normalizing ECG data
ecg = [normalize_data(lead) for lead in ecg]

if not lead_order:
    lead_order = list(range(0, len(ecg)))

leads = len(lead_order)
seconds = len(ecg[0]) / sample_rate

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions