How to Smooth an Electrocardiogram (EKG) in Python (Complete Beginner)

Electrocardiograms, like all biosignals, can be noisy. We'll show you how to smooth them out and make them easier to read in Python. Then we can start labeling and measuring the waves of the EKG to identify the rhythm and find arrhythmias ("unhealthy" heartbeats) with code. Smoothing starts at 11:45. Everything before that introduces Kaggle, Python, and EKGs to beginners. DISCLAIMER: DANGER! This video is for illustrative purposes only. Do not use any information in this video or its associated code or tutorials to make medical decisions for yourself or others. This video was not created by a doctor. If you have any medical concerns, please contact a licensed physician. Kaggle notebook with Python code: https://www.kaggle.com/code/protobioe... We use the free coding website, Kaggle, to open a file of electrocardiogram (EKG) data and create a graph of real heartbeats. Once you have a free Kaggle account, you can write Python or R code directly on the website without having to download or install anything. Kaggle also has thousands of free datasets to analyze and play around with. Start coding here: https://kaggle.com *Timeline* 0:00 Danger Disclaimer 0:05 Refresher on EKGs and PQRST waves 0:48 The methods we'll use to smooth 1:34 About Kaggle 2:00 Creating a notebook on Kaggle 2:30 Quick intro to notebooks 3:00 Why we need to smooth the EKG 3:40 What heartbeats look like when they're "bad" 5:20 Start coding 5:43 Install and import the Neurokit library 7:20 Import the Pandas library (open CSV files) 8:15 Import the Matplotlib library (for graphing) 9:50 Open the CSV of EKG data with Pandas 12:15 Look at one channel of EKG voltage (actual heartbeat data) 12:52 Smooth the EKG with Neurokit 20:30 Graph the smoothed EKG (after Neurokit) 22:45 Smoothing with SciPy in general 23:30 Smooth with a median filter 26:20 Graph the smoothed EKG (after median filter) 27:35 Smooth with a Savitzky-Golay filter 30:57 Graph the smoothed EKG (after Savitzky-Golay) 31:18 Over- and under-smoothing biosignals/EKGs 33:55 Smooth with a Butterworth filter 34:18 Frequency filters and low-pass, high-pass, band-pass, etc. 36:00 The two step that Butterworth filters require 45:03 Graph the smooth EKG (after Butterworth) 46:10 Review 47:16 Outro *4 Different Methods We Use to Smooth an EKG* 1. Neurokit's ecg_process() function 2. median filter 3. Savitzky-Golay filter 4. Butterworth filter *Dataset* MIT-BIH Normal Sinus Rhythm Database (on Kaggle): https://www.kaggle.com/datasets/proto... *EKG Analysis in Python Series* How to Graph an EKG in Python:    • How to Graph an EKG with Python (Beginner)   How to Smooth (Filter) an EKG in Python (this video) How to Label the Waves of an EKG with Python:    • How to Find PQRST Waves in an EKG with Pyt...   *Learn More about EKGs* ECG Basics (NinjaNerd on Youtube):    • ECG Basics | How to Read & Interpret ECGs:...   ECG Guide (EMCrit): https://emcrit.org/ibcc/ecg/ ECG Basics (practical articles for paramedics and EMS): https://litfl.com/ecg-library/basics/ List of arrhythmias: https://litfl.com/ecg-library/diagnosis/ Please let us know if you have any questions. Thank you to Anthony Atkielski on Wikimedia for the graphic of a "normal sinus rhythm" heartbeat and to MothNik for the animation of Savitzky-Golay filters.