<jupyter_start><jupyter_text>Generating Abnormal 12-leads ECGThis example can be referenced by [citing the package](https://github.com/neuropsychology/NeuroKitcitation).<jupyter_code>import numpy as np
import neurokit2 as nk
import matplotlib.pyplot as plt
# This "decorative" cell should be hidden from the docs once this is implemented:
# https://github.com/microsoft/vscode-jupyter/issues/1182 
plt.rcParams['figure.figsize'] = [15, 5]  # Bigger images
plt.rcParams['font.size']= 14<jupyter_output><empty_output><jupyter_text>Normal Multi-lead ECGWe can generate a normal multi-lead ECG signal with the following code:<jupyter_code>ecg12 = nk.ecg_simulate(duration=10, method="multileads")

# Visualize results
ecg12[0:10000].plot(subplots=True);<jupyter_output><empty_output><jupyter_text>Abnormal Multi-lead ECGAbnormal ECG can be generated by modifying the simulation parameters. We will draw random parameters from a distribution.<jupyter_code># Normal parameters (used by default)
# ===================================
# t, the starting position along the circle of each interval in radius
ti = np.array((-70, -15, 0, 15, 100))
# a, the amplitude of each spike
ai = np.array((1.2, -5, 30, -7.5, 0.75))
# b, the width of each spike
bi = np.array((0.25, 0.1, 0.1, 0.1, 0.4))

# Add noise
# ===============
ti = np.random.normal(ti, np.ones(5) * 3)
ai = np.random.normal(ai, np.abs(ai / 5))
bi = np.random.normal(bi, np.abs(bi / 5))

ecg12 = nk.ecg_simulate(duration=10, method="multileads", ti=ti, ai=ai, bi=bi)

# Visualize results
ecg12[0:10000].plot(subplots=True);<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15773067331670823, 'fraction_numerical': 0.0442643391521197, 'mean_word_length': 5.772151898734177, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '644944', 'license': 'MIT', 'n_tokens_mistral': 624, 'n_tokens_neox': 559, 'n_words': 151, 'path': 'docs/examples/ecg_generate_12leads/ecg_generate_12leads.ipynb', 'repo_name': 'danibene/NeuroKit', 'size': '1604'}