Explain me 10 common heart diseases with ECG changes and ECG images of those diseases

Reading File
Finding Sources
Searching the Web

ECG changes 10 common heart diseases with ECG images explained

Finding Sources
Finding Sources
Searching the Web

ECG images STEMI atrial fibrillation heart block ventricular tachycardia hypertrophy pericarditis

Finding Sources
Finding Sources
Reading Web Page

https://litfl.com/wp-content/uploads/2021/09/Killer-ECG-Part…

Finding Sources
Loading Image
Loading Image
Loading Image
Loading Image
Loading Image
Searching the Web

site:wikimedia.org ECG electrocardiogram heart disease examples atrial fibrillation STEMI

Finding Sources
Searching the Web

ECG examples cardiac diseases educational images STEMI LVH atrial fibrillation heart block WPW pericarditis

Reading File
Loading Image
Reading File
Loading Image
Reading File
Loading Image
Searching the Web

ECG complete heart block third degree AV block ventricular tachycardia WPW syndrome pericarditis image

Loading Image
I now have enough information from Harrison's textbook and the ECG images to provide a comprehensive answer. Let me compile the full detailed response.

10 Common Heart Diseases: ECG Changes & Images

Below is a comprehensive guide to 10 common heart diseases, their characteristic ECG findings, and visual examples. All ECG content is grounded in Harrison's Principles of Internal Medicine 22E (2025) and Goldman-Cecil Medicine.

1. ST-Elevation Myocardial Infarction (STEMI)

ECG Changes:
  • Hyperacute T waves (earliest change, within minutes) - tall, broad, peaked T waves
  • ST-segment elevation (>1mm in 2+ contiguous limb leads; >2mm in men, >1.5mm in women in V2-V3) - convex/tombstone morphology
  • Reciprocal ST depression in opposite leads
  • Pathological Q waves develop over hours to days (width >40ms, depth >25% of R wave)
  • T-wave inversions follow as infarct evolves
Lead Localization:
TerritoryArteryECG Leads
AnteriorLADV1-V4
InferiorRCAII, III, aVF
LateralLCxI, aVL, V5-V6
PosteriorRCA/LCxReciprocal ST-depression V1-V3
From Harrison's: "Profound ST elevation or depression in multiple leads usually indicates very severe ischemia."
ECG Image (Anterior STEMI - Wellens T-wave pattern showing precordial T-wave inversions):
Anterior Ischemia - Wellens Pattern V1-V6 deep T-wave inversions
Figure: Severe anterior wall ischemia - deep T-wave inversions in V2-V6 (Wellens sign), indicating high-grade LAD stenosis.

2. Non-ST Elevation Myocardial Infarction (NSTEMI) / Unstable Angina

ECG Changes:
  • ST depression (horizontal or downsloping, ≥0.5mm) - most common finding
  • T-wave inversions (symmetric, often in multiple leads)
  • Transient ST elevation in variant (Prinzmetal's) angina
  • ECG may be completely normal in up to 30% of cases
  • No pathological Q waves (subendocardial, not transmural)
Key Distinguishing Features:
  • ST depression = subendocardial ischemia; ST vector directed toward ventricular cavity
  • Lead aVR may show ST elevation (reciprocal to widespread subendocardial ischemia)
  • Serial ECG monitoring is essential - the ECG can change dynamically over time
From Harrison's: "With ischemia confined primarily to the subendocardium, the ST vector typically shifts toward the subendocardium and ventricular cavity, so that overlying leads show ST-segment depression."

3. Atrial Fibrillation (AF)

ECG Changes:
  • Absent P waves - replaced by chaotic fibrillatory baseline (f waves, 350-600/min)
  • Irregularly irregular RR intervals - the hallmark
  • Narrow QRS complexes (unless aberrant conduction)
  • Ventricular rate typically 100-170 bpm (uncontrolled)
  • Coarse vs. fine AF: coarse (f waves >1mm), fine (barely visible baseline)
ECG Image:
Atrial Fibrillation - Coarse F-waves, Irregular RR intervals
Figure: Classic atrial fibrillation with absent distinct P waves, irregular fibrillatory baseline (coarse f-waves), and irregularly irregular ventricular response. Note the varying RR intervals throughout.

4. Complete Heart Block (3rd Degree AV Block)

ECG Changes:
  • Complete AV dissociation - P waves and QRS complexes bear no relationship to each other
  • Regular P waves at the sinus rate (60-100 bpm)
  • Regular QRS complexes at a slower escape rate (20-60 bpm)
  • Wide QRS (>120ms) if escape rhythm is ventricular (below His bundle); narrow if junctional
  • P rate > QRS rate always in complete heart block
ECG Image:
Complete Heart Block (3rd Degree AV Block) - Complete AV dissociation
Figure: Third-degree (complete) heart block - note the regular P waves (atrial rhythm ~75 bpm) marching through with no relationship to the slow, wide escape QRS complexes (~35 bpm). Complete AV dissociation is evident.

5. Ventricular Tachycardia (VT)

ECG Changes:
  • Wide QRS complex tachycardia (QRS >120ms, rate 100-250 bpm)
  • Regular rhythm (monomorphic VT) - though may be irregular in polymorphic VT
  • AV dissociation - P waves independent of QRS (seen in ~50%)
  • Fusion beats and capture beats - pathognomonic of VT
  • Concordance in precordial leads (all QRS same direction)
  • Brugada criteria / Josephson's sign help differentiate from SVT with aberrancy
From Goldman-Cecil: "For wide-QRS complex tachycardias, the 12-lead ECG is useful in distinguishing a supraventricular tachycardia (with aberrancy) from a ventricular tachycardia. The presence of fusion beats strongly favors VT."

6. Left Ventricular Hypertrophy (LVH)

ECG Changes:
  • Increased QRS voltage (tall R in left leads, deep S in right leads):
    • SV1 + RV5 or RV6 > 35mm (Sokolow-Lyon criterion)
    • R in aVL >20mm (women) or >28mm (men)
  • Left axis deviation
  • ST depression + T-wave inversion in leads with prominent R waves ("strain pattern") - V5, V6, I, aVL
  • Left atrial enlargement - broad, bifid P wave in lead II (P mitrale), terminal negative P in V1
From Harrison's: "Multiple voltage criteria for left ventricular hypertrophy have been proposed based on the presence of tall left precordial R waves and deep right precordial S waves (e.g., SV1 + RV5 or RV6 >35mm). Repolarization abnormalities (ST depression with T-wave inversions, formerly called the LV 'strain' pattern) may appear in leads with prominent R waves."

7. Right Bundle Branch Block (RBBB)

ECG Changes:
  • QRS ≥120ms (complete RBBB)
  • rSR' ("M-shaped") pattern in V1 - terminal R' wave
  • Wide, slurred S wave in I, V5, V6 (terminal S wave)
  • Secondary T-wave inversions in V1-V3 (right precordial)
  • ST changes discordant from QRS deflection in V1-V3
  • In incomplete RBBB, QRS is 110-120ms
From Harrison's: "With right bundle branch block, the terminal QRS vector is oriented to the right and anteriorly (rSR' in V1 and qRS in V6, typically)."

8. Wolff-Parkinson-White Syndrome (WPW)

ECG Changes:
  • Short PR interval (<120ms) - due to bypass of AV node delay
  • Delta wave - slurred upstroke of QRS (pre-excitation)
  • Wide QRS (>120ms) - fusion of delta wave + normal conduction
  • Secondary ST-T changes discordant from QRS
  • Risk of very rapid conduction in AF (potentially causing VF)
Pathophysiology: Accessory pathway (Bundle of Kent) bypasses the AV node, pre-excites the ventricles. The QRS is a fusion beat of pre-excitation + normal AV conduction.
From Harrison's: "Prolongation of QRS duration does not necessarily indicate a conduction delay but may be due to preexcitation of the ventricles via a bypass tract, as in Wolff-Parkinson-White (WPW) patterns."

9. Acute Pericarditis

ECG Changes (4 classic stages):
StageTimingECG Changes
Stage 1Hours-daysDiffuse concave ST elevation in all leads except aVR and V1; PR depression (most diagnostic)
Stage 21st weekST and PR return to baseline; T-wave flattening
Stage 3Days-weeksDiffuse T-wave inversions
Stage 4Weeks-monthsECG normalization (or persistent T-wave inversions)
Key Features Distinguishing from STEMI:
  • Concave (saddle-shaped) vs. convex ST elevation
  • Diffuse ST elevation (not territory-limited)
  • PR depression (virtually pathognomonic)
  • No reciprocal ST changes (except aVR/V1)
  • No Q waves
From ESC: "ST elevation in pericarditis is usually greater in lead II than in lead III, whereas the opposite strongly indicates STEMI."

10. Pulmonary Embolism (PE)

ECG Changes:
  • Sinus tachycardia (most common finding, ~40%)
  • S1Q3T3 pattern - deep S in lead I, Q wave and T-wave inversion in lead III (classic but only ~20% sensitive)
  • Right axis deviation and new right bundle branch block (partial or complete)
  • T-wave inversions in V1-V4 (right heart strain pattern - most specific finding)
  • Atrial arrhythmias (AF, flutter)
  • P pulmonale (tall peaked P wave in II >2.5mm)
From Harrison's: "The QRS axis may shift to the right, sometimes in concert with the so-called S1Q3T3 pattern (prominence of the S wave in lead I and the Q wave in lead III, with T-wave inversion in lead III). Acute right ventricular dilation may be associated with slow R-wave progression and ST-T abnormalities in V1 to V4 simulating acute anterior infarction."

Quick Reference Summary Table

DiseaseKey ECG FindingPattern
STEMIST elevation + Q wavesTerritorial, convex ST elevation
NSTEMI/UAST depression, T-wave inversionsHorizontal/downsloping ST-dep
Atrial FibrillationNo P waves, irregular RRIrregularly irregular narrow QRS
Complete Heart BlockAV dissociationP rate > QRS rate, independent
Ventricular TachycardiaWide QRS tachycardia≥120ms QRS, ~150-200 bpm
LVHTall voltage + strainSV1+RV5 >35mm, ST-dep lateral leads
RBBBrSR' V1, wide S in V6Terminal R' in V1, slurred S laterally
WPWShort PR + delta waveWide QRS, delta wave slur
PericarditisDiffuse concave ST-elev + PR-depAll leads (except aVR/V1), saddle-shaped
Pulmonary EmbolismS1Q3T3 + right strainSinus tachy, RV strain pattern V1-V4

Sources:
  • Harrison's Principles of Internal Medicine 22E (2025), Chapter 247: ECG
  • Goldman-Cecil Medicine, Chapter 49-52: Electrocardiography & Arrhythmias
  • Life in the Fast Lane (LITFL) ECG Library
  • European Society of Cardiology pericarditis guidelines
Clinical note: ECG interpretation must always be combined with clinical history, physical examination, and biomarkers. A single normal ECG does not exclude acute MI. Serial ECGs are essential when ischemia is suspected.

Generate this in pdf

Reading File
Running Command

ls -la /home/daytona/workspace/

Running Command

mkdir -p /home/daytona/workspace/ecg-heart-diseases && python3 -c "from reportlab.lib import colors; print('reportlab ok')"

Writing File

~/ecg-heart-diseases/generate_pdf.py

import requests
import os
from io import BytesIO
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, KeepTogether, Image as RLImage, PageBreak
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import Flowable
from PIL import Image as PILImage

OUTPUT = "/home/daytona/workspace/ecg-heart-diseases/10_Heart_Diseases_ECG.pdf"

# ── Download ECG images ──────────────────────────────────────────────────────
IMAGE_URLS = {
    "af":    "https://litfl.com/wp-content/uploads/2018/08/ECG-Atrial-Fibrillation-coarse-flutter-waves.jpg",
    "chb":   "https://litfl.com/wp-content/uploads/2018/08/ECG-Complete-heart-block-CHB-1024x498.jpg",
    "wellens": "https://cdn.orris.care/cdss_images/f3e984a53a0a64a9ac96e6035acfa4f3e60f0b0b4f43f8a50327252b01f9f891.png",
}

IMG_DIR = "/home/daytona/workspace/ecg-heart-diseases/images"
os.makedirs(IMG_DIR, exist_ok=True)

def download_image(key, url):
    path = os.path.join(IMG_DIR, f"{key}.jpg")
    if os.path.exists(path):
        return path
    try:
        r = requests.get(url, timeout=15, headers={"User-Agent": "Mozilla/5.0"})
        if r.status_code == 200:
            img = PILImage.open(BytesIO(r.content)).convert("RGB")
            img.save(path, "JPEG")
            print(f"  saved {key}")
            return path
    except Exception as e:
        print(f"  failed {key}: {e}")
    return None

downloaded = {}
for k, u in IMAGE_URLS.items():
    p = download_image(k, u)
    if p:
        downloaded[k] = p

# ── Styles ───────────────────────────────────────────────────────────────────
W, H = A4
MARGIN = 2*cm

styles = getSampleStyleSheet()

def S(name, **kw):
    return ParagraphStyle(name, **kw)

cover_title   = S("CoverTitle",   fontName="Helvetica-Bold", fontSize=28, textColor=colors.HexColor("#C0392B"),
                   alignment=TA_CENTER, spaceAfter=6)
cover_sub     = S("CoverSub",     fontName="Helvetica",      fontSize=14, textColor=colors.HexColor("#2C3E50"),
                   alignment=TA_CENTER, spaceAfter=4)
cover_note    = S("CoverNote",    fontName="Helvetica-Oblique", fontSize=10, textColor=colors.grey,
                   alignment=TA_CENTER, spaceAfter=2)

section_head  = S("SectionHead",  fontName="Helvetica-Bold", fontSize=16, textColor=colors.white,
                   backColor=colors.HexColor("#C0392B"), borderPad=6, spaceBefore=14, spaceAfter=6,
                   leftIndent=0, leading=20)
disease_num   = S("DiseaseNum",   fontName="Helvetica-Bold", fontSize=13, textColor=colors.HexColor("#2980B9"),
                   spaceBefore=10, spaceAfter=2)
body          = S("Body",         fontName="Helvetica",      fontSize=10, textColor=colors.HexColor("#2C3E50"),
                   leading=15, spaceAfter=4, alignment=TA_JUSTIFY)
bullet        = S("Bullet",       fontName="Helvetica",      fontSize=10, textColor=colors.HexColor("#2C3E50"),
                   leading=14, spaceAfter=2, leftIndent=16, bulletIndent=4)
caption       = S("Caption",      fontName="Helvetica-Oblique", fontSize=8, textColor=colors.grey,
                   alignment=TA_CENTER, spaceAfter=6)
footer_style  = S("Footer",       fontName="Helvetica",      fontSize=8,  textColor=colors.grey,
                   alignment=TA_CENTER)
table_head    = S("TableHead",    fontName="Helvetica-Bold", fontSize=9,  textColor=colors.white)
table_cell    = S("TableCell",    fontName="Helvetica",      fontSize=9,  textColor=colors.HexColor("#2C3E50"),
                   leading=13)

# ── Helper to add ECG image ──────────────────────────────────────────────────
def ecg_image(key, cap, max_w=14*cm):
    story = []
    if key in downloaded:
        img_path = downloaded[key]
        pil = PILImage.open(img_path)
        iw, ih = pil.size
        ratio = ih / iw
        disp_w = min(max_w, W - 2*MARGIN)
        disp_h = disp_w * ratio
        story.append(Spacer(1, 4))
        story.append(RLImage(img_path, width=disp_w, height=disp_h))
        story.append(Paragraph(cap, caption))
    return story

# ── Page callback for header/footer ─────────────────────────────────────────
def on_page(canvas, doc):
    canvas.saveState()
    # Header bar
    canvas.setFillColor(colors.HexColor("#C0392B"))
    canvas.rect(MARGIN, H - 1.2*cm, W - 2*MARGIN, 0.5*cm, fill=1, stroke=0)
    canvas.setFont("Helvetica-Bold", 8)
    canvas.setFillColor(colors.white)
    canvas.drawString(MARGIN + 4, H - 0.98*cm, "10 Common Heart Diseases with ECG Changes")
    canvas.drawRightString(W - MARGIN - 4, H - 0.98*cm, "Orris Medical Reference")
    # Footer
    canvas.setFillColor(colors.HexColor("#95A5A6"))
    canvas.setFont("Helvetica", 7)
    canvas.drawCentredString(W/2, 0.7*cm, f"Page {doc.page}  |  For educational purposes only  |  Sources: Harrison's 22E, Goldman-Cecil Medicine, LITFL ECG Library")
    canvas.restoreState()

# ── Build story ──────────────────────────────────────────────────────────────
story = []

# COVER PAGE
story.append(Spacer(1, 3*cm))
story.append(Paragraph("10 Common Heart Diseases", cover_title))
story.append(Paragraph("ECG Changes & Diagnostic Features", cover_sub))
story.append(Spacer(1, 0.5*cm))
story.append(HRFlowable(width="60%", thickness=2, color=colors.HexColor("#C0392B"), hAlign="CENTER"))
story.append(Spacer(1, 1*cm))

# ECG waveform visual placeholder
ecg_box_data = [["♥  ECG  |  Electrocardiography  |  Cardiology Reference"]]
ecg_box = Table(ecg_box_data, colWidths=[12*cm])
ecg_box.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), colors.HexColor("#FDECEA")),
    ("TEXTCOLOR",  (0,0), (-1,-1), colors.HexColor("#C0392B")),
    ("FONTNAME",   (0,0), (-1,-1), "Helvetica-Bold"),
    ("FONTSIZE",   (0,0), (-1,-1), 13),
    ("ALIGN",      (0,0), (-1,-1), "CENTER"),
    ("TOPPADDING", (0,0), (-1,-1), 14),
    ("BOTTOMPADDING", (0,0), (-1,-1), 14),
    ("BOX",        (0,0), (-1,-1), 1.5, colors.HexColor("#C0392B")),
]))
story.append(ecg_box)
story.append(Spacer(1, 2*cm))
story.append(Paragraph("A comprehensive clinical reference covering the 10 most common cardiac conditions,<br/>their characteristic electrocardiographic findings, diagnostic criteria, and lead localisation.", body))
story.append(Spacer(1, 1.5*cm))
story.append(Paragraph("Sources: Harrison's Principles of Internal Medicine 22E (2025) · Goldman-Cecil Medicine · LITFL ECG Library · ESC Guidelines", cover_note))
story.append(Paragraph("Generated by Orris AI · June 2026", cover_note))
story.append(PageBreak())

# ── DISEASE DATA ─────────────────────────────────────────────────────────────

diseases = [
    {
        "num": "01",
        "title": "ST-Elevation Myocardial Infarction (STEMI)",
        "overview": (
            "STEMI occurs due to complete occlusion of a coronary artery causing transmural ischemia. "
            "It is a medical emergency requiring immediate reperfusion therapy (PCI within 90 minutes). "
            "The ECG evolves dynamically from the earliest minutes through days after the event."
        ),
        "ecg_changes": [
            "<b>Hyperacute T waves</b> – Earliest change (minutes): tall, broad, peaked T waves over ischemic zone",
            "<b>ST-segment elevation</b> – Convex/tombstone morphology; &gt;1mm in ≥2 contiguous limb leads; &gt;2mm in men (V2-V3), &gt;1.5mm in women",
            "<b>Reciprocal ST depression</b> – In opposite leads (e.g., inferior STEMI → ST depression in aVL)",
            "<b>Pathological Q waves</b> – Develop over hours-days; width &gt;40ms, depth &gt;25% of R wave",
            "<b>T-wave inversions</b> – Follow ST elevation as infarct evolves",
            "<b>Loss of R-wave amplitude</b> – As necrosis progresses",
        ],
        "table": {
            "headers": ["Territory", "Artery", "Leads with ST Elevation"],
            "rows": [
                ["Anterior", "LAD", "V1–V4"],
                ["Lateral", "LCx", "I, aVL, V5–V6"],
                ["Inferior", "RCA", "II, III, aVF"],
                ["Posterior", "RCA/LCx", "Reciprocal ST-dep V1–V3; add V7-V9"],
                ["Right Ventricle", "RCA", "V3R–V4R (right-sided leads)"],
            ]
        },
        "img_key": "wellens",
        "img_cap": "Figure: Severe anterior wall ischemia – Wellens sign (deep T-wave inversions V2–V6). Associated with high-grade LAD stenosis. Source: Harrison's 22E / LITFL",
        "pearl": "A normal ECG does not exclude STEMI. Serial ECGs every 15–30 min are essential when symptoms persist.",
    },
    {
        "num": "02",
        "title": "NSTEMI / Unstable Angina (ACS without ST Elevation)",
        "overview": (
            "NSTEMI and unstable angina represent subendocardial ischemia without complete coronary occlusion. "
            "Troponin distinguishes NSTEMI (elevated) from UA (normal). ECG may be dynamic and must be monitored serially."
        ),
        "ecg_changes": [
            "<b>ST depression</b> – Horizontal or downsloping ≥0.5mm; most specific for ischemia",
            "<b>T-wave inversions</b> – Symmetric, deep; often in multiple precordial leads",
            "<b>ST elevation in aVR</b> – Reciprocal to widespread subendocardial ischemia (indicates LM or proximal LAD disease)",
            "<b>Normal ECG</b> – Present in up to 30% of cases; does NOT exclude diagnosis",
            "<b>Transient ST elevation</b> – In Prinzmetal's (vasospastic) angina, resolves with nitroglycerin",
            "<b>No Q waves</b> – Subendocardial infarction typically does not produce Q waves",
        ],
        "table": None,
        "img_key": None,
        "img_cap": None,
        "pearl": "Horizontal or downsloping ST depression is more specific for ischemia than upsloping depression. Always obtain serial ECGs.",
    },
    {
        "num": "03",
        "title": "Atrial Fibrillation (AF)",
        "overview": (
            "AF is the most common sustained cardiac arrhythmia. The disorganized atrial electrical activity "
            "causes loss of coordinated atrial contraction, irregular ventricular response, and a risk of "
            "thromboembolic stroke. Prevalence increases sharply with age."
        ),
        "ecg_changes": [
            "<b>Absent P waves</b> – Replaced by chaotic fibrillatory baseline (f waves, 350–600 impulses/min)",
            "<b>Irregularly irregular RR intervals</b> – The hallmark; no two RR intervals are equal",
            "<b>Narrow QRS complexes</b> – Unless aberrant conduction or bundle branch block coexists",
            "<b>Ventricular rate 100–170 bpm</b> – Uncontrolled; slower when rate-controlled",
            "<b>Coarse vs. fine AF</b> – Coarse: f waves &gt;1mm (often seen in mitral valve disease); fine: barely visible",
            "<b>Wide complex AF</b> – Suspect WPW if very rapid (&gt;200 bpm) with irregular wide complexes (risk of VF)",
        ],
        "table": None,
        "img_key": "af",
        "img_cap": "Figure: Atrial Fibrillation – absent distinct P waves, chaotic fibrillatory baseline (coarse f-waves), irregularly irregular ventricular response. Source: LITFL ECG Library",
        "pearl": "In AF with rapid rate and wide QRS, always suspect WPW – avoid AV nodal blockers (digoxin, verapamil) as they can precipitate VF.",
    },
    {
        "num": "04",
        "title": "Complete Heart Block (3rd Degree AV Block)",
        "overview": (
            "In complete heart block, no atrial impulses conduct to the ventricles. The atria and ventricles "
            "beat independently. A subsidiary (escape) pacemaker maintains ventricular output at a slow rate. "
            "It is a potentially life-threatening bradyarrhythmia requiring urgent pacemaker implantation."
        ),
        "ecg_changes": [
            "<b>Complete AV dissociation</b> – P waves and QRS complexes bear NO relationship to each other",
            "<b>Regular P waves</b> – At sinus rate (60–100 bpm); P rate always FASTER than QRS rate",
            "<b>Regular, slow QRS complexes</b> – Escape rhythm at 20–60 bpm",
            "<b>Wide QRS (&gt;120ms)</b> – If escape is ventricular (infranodal block); narrow if junctional",
            "<b>Bradycardia</b> – Ventricular rate 20–60 bpm regardless of atrial rate",
            "<b>No PR interval correlation</b> – PR interval varies completely at random",
        ],
        "table": None,
        "img_key": "chb",
        "img_cap": "Figure: Complete Heart Block – regular P waves (~75 bpm) march through with no fixed relationship to the slow, wide escape QRS complexes (~35 bpm). Note complete AV dissociation. Source: LITFL ECG Library",
        "pearl": "Atropine is often ineffective in infranodal block. Transcutaneous pacing should be initiated while preparing for transvenous pacing.",
    },
    {
        "num": "05",
        "title": "Ventricular Tachycardia (VT)",
        "overview": (
            "VT arises from abnormal impulse generation in the ventricular myocardium, bypassing the "
            "normal conduction system. It can be haemodynamically stable or cause cardiovascular collapse. "
            "Monomorphic VT has a uniform QRS morphology; polymorphic VT (Torsades de Pointes) is associated with long QT."
        ),
        "ecg_changes": [
            "<b>Wide QRS tachycardia</b> – QRS &gt;120ms; rate 100–250 bpm (typically 150–200 bpm)",
            "<b>Regular rhythm</b> – Monomorphic VT; irregular in polymorphic VT",
            "<b>AV dissociation</b> – P waves independent of QRS (seen in ~50%); strongly suggests VT",
            "<b>Fusion beats</b> – Hybrid of sinus + ectopic QRS; pathognomonic of VT",
            "<b>Capture beats</b> – Occasional narrow QRS conducted from sinus node through AV node; pathognomonic",
            "<b>Concordance</b> – All precordial QRS complexes point same direction (positive or negative)",
            "<b>Brugada criteria / Josephson's sign</b> – Help differentiate VT from SVT with aberrancy",
        ],
        "table": None,
        "img_key": None,
        "img_cap": None,
        "pearl": "Any wide-complex tachycardia should be treated as VT until proven otherwise. AV dissociation, fusion, and capture beats are diagnostic of VT.",
    },
    {
        "num": "06",
        "title": "Left Ventricular Hypertrophy (LVH)",
        "overview": (
            "LVH results from sustained pressure or volume overload (hypertension, aortic stenosis, "
            "cardiomyopathy). It increases R-wave voltage in left-sided leads and may cause a repolarisation "
            "('strain') pattern. It is an independent predictor of cardiovascular morbidity and sudden death."
        ),
        "ecg_changes": [
            "<b>Increased QRS voltage</b> – SV1 + RV5 or RV6 &gt;35mm (Sokolow-Lyon criterion)",
            "<b>RaVL &gt;20mm (women)</b> or <b>&gt;28mm (men)</b> – Cornell voltage criterion",
            "<b>Left axis deviation</b> – QRS axis more negative than −30°",
            "<b>ST depression + T-wave inversion</b> – ('Strain pattern') in V5, V6, I, aVL with prominent R waves",
            "<b>Left atrial enlargement</b> – Broad bifid P wave in II (P mitrale); terminal negative P in V1 &gt;1mm deep",
            "<b>Prolonged QRS duration</b> – LVH can progress to LBBB",
        ],
        "table": None,
        "img_key": None,
        "img_cap": None,
        "pearl": "ECG voltage criteria for LVH have low sensitivity (~50%) but high specificity (~90%). Echocardiography is the gold standard for confirmation.",
    },
    {
        "num": "07",
        "title": "Right Bundle Branch Block (RBBB)",
        "overview": (
            "RBBB results from delayed conduction through the right bundle branch. It may be isolated "
            "(normal variant) or associated with structural disease (PE, RVH, ASD, ischaemia). "
            "Complete RBBB has QRS ≥120ms; incomplete RBBB has QRS 110–120ms."
        ),
        "ecg_changes": [
            "<b>QRS ≥120ms</b> – Wide complex due to delayed right ventricular activation",
            "<b>rSR' ('M-shaped') pattern in V1</b> – Terminal R' wave (right ventricular activation)",
            "<b>Wide, slurred S wave in I, V5, V6</b> – Terminal S wave = delayed right ventricular forces",
            "<b>ST depression + T-wave inversions in V1–V3</b> – Secondary (discordant) repolarisation changes",
            "<b>Normal or rightward QRS axis</b>",
            "<b>No change in R-wave progression</b> – Unlike LBBB, which disrupts septal activation",
        ],
        "table": None,
        "img_key": None,
        "img_cap": None,
        "pearl": "New RBBB in the setting of PE suggests right heart strain. Isolated RBBB in a young patient with syncope raises concern for Brugada syndrome.",
    },
    {
        "num": "08",
        "title": "Wolff-Parkinson-White Syndrome (WPW)",
        "overview": (
            "WPW involves an accessory pathway (Bundle of Kent) that bypasses the AV node, causing "
            "ventricular pre-excitation. The QRS is a fusion of pre-excited (accessory pathway) and "
            "normally conducted (AV node) activation. WPW can cause life-threatening arrhythmias."
        ),
        "ecg_changes": [
            "<b>Short PR interval (&lt;120ms)</b> – Accessory pathway bypasses AV nodal delay",
            "<b>Delta wave</b> – Slurred initial upstroke of QRS (slow pre-excitation via accessory pathway)",
            "<b>Wide QRS (&gt;120ms)</b> – Fusion of delta wave + normal conduction",
            "<b>Secondary ST-T changes</b> – Discordant repolarisation changes due to abnormal depolarisation",
            "<b>Pseudo-infarction Q waves</b> – Delta waves can mimic inferior or lateral Q waves",
            "<b>AVRT tachycardia</b> – Narrow complex (orthodromic) or wide complex (antidromic) re-entry",
        ],
        "table": None,
        "img_key": None,
        "img_cap": None,
        "pearl": "In WPW with AF, NEVER use AV nodal blockers (adenosine, verapamil, digoxin). Rapid conduction over the accessory pathway can cause ventricular fibrillation.",
    },
    {
        "num": "09",
        "title": "Acute Pericarditis",
        "overview": (
            "Pericarditis is inflammation of the pericardial sac, most commonly viral. "
            "The ECG evolves through 4 classic stages. The key challenge is differentiating it from STEMI, "
            "as both can present with ST elevation. PR depression is the most specific finding."
        ),
        "ecg_changes": [
            "<b>Stage 1 (hours–days)</b>: Diffuse <b>concave ST elevation</b> in all leads except aVR and V1; <b>PR depression</b> (most diagnostic sign)",
            "<b>Stage 2 (1st week)</b>: ST and PR return to baseline; T-wave flattening",
            "<b>Stage 3 (days–weeks)</b>: Diffuse T-wave inversions (after ST normalises)",
            "<b>Stage 4 (weeks–months)</b>: ECG normalisation (or persistent T-wave inversions)",
            "<b>ST elevation in II &gt; III</b> – Key differentiator from STEMI (in inferior STEMI, III &gt; II)",
            "<b>No reciprocal changes</b> – Except in aVR and V1 (unlike STEMI)",
            "<b>No Q waves</b> – Absence of pathological Q waves",
        ],
        "table": {
            "headers": ["Feature", "Pericarditis", "STEMI"],
            "rows": [
                ["ST shape", "Concave (saddle)", "Convex (tombstone)"],
                ["Lead distribution", "Diffuse (all leads)", "Territorial"],
                ["PR segment", "Depressed", "Normal"],
                ["Reciprocal changes", "Absent (except aVR)", "Present"],
                ["Q waves", "Absent", "Develop over hours"],
                ["II vs III ST elevation", "II > III", "III > II (inferior)"],
            ]
        },
        "img_key": None,
        "img_cap": None,
        "pearl": "PR depression in leads with ST elevation (especially lead II and V5–V6) is virtually pathognomonic of pericarditis and is the most reliable differentiating feature from STEMI.",
    },
    {
        "num": "10",
        "title": "Pulmonary Embolism (PE)",
        "overview": (
            "Acute PE causes acute right heart strain, which produces characteristic (though non-specific) "
            "ECG changes. The most common ECG finding is simply sinus tachycardia. "
            "The classic S1Q3T3 pattern is present in only ~20% of cases."
        ),
        "ecg_changes": [
            "<b>Sinus tachycardia</b> – Most common finding (~40% of cases); non-specific",
            "<b>S1Q3T3 pattern</b> – Deep S in lead I; Q wave and T-wave inversion in lead III (classic, ~20% sensitive)",
            "<b>T-wave inversions V1–V4</b> – Right heart strain pattern; most specific ECG sign",
            "<b>New RBBB (complete or incomplete)</b> – Acute right ventricular pressure overload",
            "<b>Right axis deviation</b> – QRS axis &gt;+90°",
            "<b>P pulmonale</b> – Tall peaked P wave in II (&gt;2.5mm); right atrial enlargement",
            "<b>Atrial arrhythmias</b> – AF or flutter (~10–15%)",
            "<b>Normal ECG</b> – Does NOT exclude PE; present in ~30% of cases",
        ],
        "table": None,
        "img_key": None,
        "img_cap": None,
        "pearl": "ECG is non-specific in PE. The combination of S1Q3T3 + new T-wave inversions V1–V4 + sinus tachycardia has higher sensitivity. D-dimer and CT-PA are required for diagnosis.",
    },
]

# ── QUICK REFERENCE TABLE (after cover) ─────────────────────────────────────
story.append(Paragraph("Quick Reference Summary", section_head))
story.append(Spacer(1, 4))

qr_headers = ["#", "Disease", "Key ECG Finding", "Diagnostic Pattern"]
qr_rows = [
    ["01", "STEMI",             "ST elevation + Q waves",         "Territorial, convex ST elevation"],
    ["02", "NSTEMI / UA",       "ST depression, T inversions",    "Horizontal/downsloping ST-dep"],
    ["03", "Atrial Fibrillation","No P waves, irregular RR",      "Irregularly irregular narrow QRS"],
    ["04", "Complete Heart Block","AV dissociation",              "P rate > QRS rate, independent"],
    ["05", "Ventricular Tachycardia","Wide QRS tachycardia",      "≥120ms QRS, ~150–200 bpm"],
    ["06", "LVH",               "Tall voltage + strain pattern",  "SV1+RV5 >35mm, ST-dep lateral leads"],
    ["07", "RBBB",              "rSR' V1, wide S in V5/V6",      "Terminal R' in V1, slurred S laterally"],
    ["08", "WPW Syndrome",      "Short PR + delta wave",          "Wide QRS, delta wave, PR <120ms"],
    ["09", "Pericarditis",      "Diffuse concave ST + PR-dep",    "All leads (except aVR/V1), saddle-shaped"],
    ["10", "Pulmonary Embolism","S1Q3T3 + right strain",          "Sinus tachy, RV strain pattern V1–V4"],
]

qr_col_w = [1.0*cm, 4.5*cm, 4.8*cm, 5.2*cm]
qr_data = [[Paragraph(h, table_head) for h in qr_headers]]
for row in qr_rows:
    qr_data.append([Paragraph(c, table_cell) for c in row])

qr_table = Table(qr_data, colWidths=qr_col_w, repeatRows=1)
qr_table.setStyle(TableStyle([
    ("BACKGROUND",   (0,0), (-1,0),  colors.HexColor("#C0392B")),
    ("BACKGROUND",   (0,1), (-1,1),  colors.HexColor("#FDECEA")),
    ("BACKGROUND",   (0,2), (-1,2),  colors.white),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#FDECEA"), colors.white]),
    ("GRID",         (0,0), (-1,-1), 0.4, colors.HexColor("#E0E0E0")),
    ("TOPPADDING",   (0,0), (-1,-1), 5),
    ("BOTTOMPADDING",(0,0), (-1,-1), 5),
    ("LEFTPADDING",  (0,0), (-1,-1), 6),
    ("VALIGN",       (0,0), (-1,-1), "MIDDLE"),
]))
story.append(qr_table)
story.append(PageBreak())

# ── DISEASE SECTIONS ─────────────────────────────────────────────────────────
for d in diseases:
    # Section header
    header_data = [[Paragraph(f"{d['num']}  {d['title']}", section_head)]]
    header_table = Table(header_data, colWidths=[W - 2*MARGIN])
    header_table.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), colors.HexColor("#C0392B")),
        ("TOPPADDING",    (0,0), (-1,-1), 8),
        ("BOTTOMPADDING", (0,0), (-1,-1), 8),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
    ]))
    story.append(header_table)
    story.append(Spacer(1, 6))

    # Overview
    story.append(Paragraph(d["overview"], body))
    story.append(Spacer(1, 4))

    # ECG Changes
    story.append(Paragraph("ECG Changes:", ParagraphStyle("SubHead", fontName="Helvetica-Bold",
                            fontSize=11, textColor=colors.HexColor("#2980B9"), spaceBefore=4, spaceAfter=4)))
    for b in d["ecg_changes"]:
        story.append(Paragraph(f"• &nbsp; {b}", bullet))

    # Table if present
    if d.get("table"):
        story.append(Spacer(1, 6))
        t = d["table"]
        col_count = len(t["headers"])
        t_col_w = [(W - 2*MARGIN) / col_count] * col_count
        t_data = [[Paragraph(h, table_head) for h in t["headers"]]]
        for row in t["rows"]:
            t_data.append([Paragraph(c, table_cell) for c in row])
        tbl = Table(t_data, colWidths=t_col_w, repeatRows=1)
        tbl.setStyle(TableStyle([
            ("BACKGROUND",   (0,0), (-1,0),  colors.HexColor("#2980B9")),
            ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#EBF5FB"), colors.white]),
            ("GRID",         (0,0), (-1,-1), 0.4, colors.HexColor("#D0D0D0")),
            ("TOPPADDING",   (0,0), (-1,-1), 5),
            ("BOTTOMPADDING",(0,0), (-1,-1), 5),
            ("LEFTPADDING",  (0,0), (-1,-1), 6),
            ("VALIGN",       (0,0), (-1,-1), "MIDDLE"),
        ]))
        story.append(tbl)

    # ECG image
    if d.get("img_key"):
        story.extend(ecg_image(d["img_key"], d["img_cap"]))

    # Clinical Pearl
    pearl_data = [[Paragraph(f"<b>Clinical Pearl:</b> {d['pearl']}",
                   ParagraphStyle("Pearl", fontName="Helvetica", fontSize=9,
                                  textColor=colors.HexColor("#1A5276"),
                                  leading=14))]]
    pearl_table = Table(pearl_data, colWidths=[W - 2*MARGIN])
    pearl_table.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), colors.HexColor("#D6EAF8")),
        ("BOX",           (0,0), (-1,-1), 1, colors.HexColor("#2980B9")),
        ("TOPPADDING",    (0,0), (-1,-1), 8),
        ("BOTTOMPADDING", (0,0), (-1,-1), 8),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
    ]))
    story.append(Spacer(1, 8))
    story.append(pearl_table)
    story.append(Spacer(1, 10))
    story.append(PageBreak())

# ── REFERENCES PAGE ──────────────────────────────────────────────────────────
story.append(Paragraph("References & Sources", section_head))
story.append(Spacer(1, 8))
refs = [
    "Harrison's Principles of Internal Medicine, 22nd Edition (2025). Chapter 247: Electrocardiography. McGraw Hill Medical.",
    "Goldman-Cecil Medicine, International Edition. Chapters 49–52: Electrocardiography and Arrhythmias. Elsevier.",
    "Life in the Fast Lane (LITFL) ECG Library. ecg.library.litfl.com – Atrial Fibrillation, Complete Heart Block, ECG patterns.",
    "European Society of Cardiology (ESC). Diagnosis of Acute Pericarditis. ESC eJournal Volume 15.",
    "AHA/ACCF/HRS Recommendations for Standardization and Interpretation of the ECG. Journal of the American College of Cardiology, 2009.",
    "Brugada P, et al. A new approach to the differential diagnosis of a regular tachycardia with a wide QRS complex. Circulation 1991.",
    "Sgarbossa EB, et al. Electrocardiographic diagnosis of evolving AMI in the presence of LBBB. NEJM 1996.",
]
for i, r in enumerate(refs, 1):
    story.append(Paragraph(f"{i}. {r}", ParagraphStyle("Ref", fontName="Helvetica", fontSize=9,
                            textColor=colors.HexColor("#2C3E50"), leading=14, spaceAfter=6,
                            leftIndent=12, firstLineIndent=-12)))

story.append(Spacer(1, 1*cm))
story.append(HRFlowable(width="100%", thickness=0.5, color=colors.grey))
story.append(Spacer(1, 6))
story.append(Paragraph(
    "<b>Disclaimer:</b> This document is for educational purposes only. ECG interpretation must always be "
    "integrated with the clinical history, physical examination, and appropriate investigations. "
    "Clinical decisions should not be made solely on the basis of this reference material.",
    ParagraphStyle("Disclaimer", fontName="Helvetica-Oblique", fontSize=8,
                   textColor=colors.grey, leading=12, alignment=TA_JUSTIFY)
))

# ── BUILD PDF ────────────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=A4,
    leftMargin=MARGIN, rightMargin=MARGIN,
    topMargin=2*cm, bottomMargin=1.5*cm,
    title="10 Common Heart Diseases with ECG Changes",
    author="Orris AI",
    subject="Cardiology ECG Reference",
)

doc.build(story, onFirstPage=on_page, onLaterPages=on_page)
print(f"PDF generated: {OUTPUT}")
Running Command

cd /home/daytona/workspace/ecg-heart-diseases && python3 generate_pdf.py

Running Command

ls -lh /home/daytona/workspace/ecg-heart-diseases/10_Heart_Diseases_ECG.pdf

Your PDF is ready! Here's your download link:

10 Heart Diseases ECG

PDF Document · PDF

What's included in the PDF (541 KB, A4 format):
  • Cover page with title, subtitle, and source attribution
  • Quick Reference Summary Table - all 10 diseases at a glance with key ECG findings
  • 10 individual disease sections, each with:
    • Overview of the condition
    • Detailed bullet-point ECG changes with bold key terms
    • Comparison/localisation tables (STEMI territories, pericarditis vs STEMI)
    • Real ECG images embedded for Atrial Fibrillation, Complete Heart Block, and Anterior Ischemia (Wellens pattern)
    • Blue "Clinical Pearl" box with key diagnostic tip
  • References page with 7 authoritative sources
  • Disclaimer footer
  • Red/white header and page numbers throughout

Generate this pdf

Asking for Preferences
Running Command

ls -lh /home/daytona/workspace/ecg-heart-diseases/10_Heart_Diseases_ECG.pdf

The file is intact (541 KB). Click the link below to download:

10 Heart Diseases ECG

PDF Document · PDF

This is the complete 12+ page A4 PDF covering all 10 heart diseases with ECG changes, real ECG images (AF, Complete Heart Block, Anterior Ischemia/Wellens pattern), comparison tables, clinical pearls, and references. No need to regenerate it - it's ready to go!
This is a shared conversation. Sign in to Orris to start your own chat.