/visualise learning Pharmacology of drugs acting on peripheral nervous system : organisation and functions of ANS and neuro humorous transmission co transmission and classification of neurotransmitters generate a hand written notes with diagrams
ls /tmp/workspace/ 2>/dev/null || mkdir -p /tmp/workspace && echo "ready"
mkdir -p /tmp/workspace/ans-pharmacology && python3 -c " import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.patches as mpatches from matplotlib.patches import FancyArrowPatch, FancyBboxPatch, Arc import matplotlib.patheffects as pe import numpy as np from matplotlib.font_manager import FontProperties import warnings warnings.filterwarnings('ignore') # Use a handwriting-style font if available, else fallback import matplotlib.font_manager as fm available = [f.name for f in fm.fontManager.ttflist] hw_fonts = [f for f in available if any(x in f.lower() for x in ['indie', 'permanent', 'handlee', 'comic', 'caveat', 'schoolbell'])] HW = hw_fonts[0] if hw_fonts else 'DejaVu Sans' print('Using font:', HW) print('Done') "
pip install --user matplotlib --quiet 2>/dev/null; python3 << 'PYEOF' import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.patches as mpatches from matplotlib.patches import FancyArrowPatch, FancyBboxPatch import matplotlib.patheffects as pe import numpy as np from matplotlib.backends.backend_pdf import PdfPages import warnings warnings.filterwarnings('ignore') PDF_PATH = '/tmp/workspace/ans-pharmacology/ANS_Pharmacology_Notes.pdf' # Paper-like background color PAPER = '#fffef0' LINES = '#d4c99a' INK = '#1a1a2e' BLUE = '#1b4fc4' RED = '#c0392b' GREEN = '#1a7a3c' PURPLE= '#6c3483' ORANGE= '#d35400' TEAL = '#148f77' def add_ruled_lines(ax, n=28): """Draw faint ruled lines like a notebook.""" for i in np.linspace(0.04, 0.96, n): ax.axhline(i, color=LINES, lw=0.5, alpha=0.7, zorder=0) def page_setup(fig, ax): fig.patch.set_facecolor(PAPER) ax.set_facecolor(PAPER) ax.set_xlim(0, 1) ax.set_ylim(0, 1) ax.axis('off') add_ruled_lines(ax) # Left margin line ax.axvline(0.07, color='#f8a0a0', lw=1.2, alpha=0.8, zorder=1) def hw_text(ax, x, y, text, size=11, color=INK, bold=False, italic=False, ha='left', va='center', wrap=False, alpha=1.0): weight = 'bold' if bold else 'normal' style = 'italic' if italic else 'normal' ax.text(x, y, text, fontsize=size, color=color, fontweight=weight, fontstyle=style, ha=ha, va=va, alpha=alpha, zorder=10, wrap=wrap, fontfamily='DejaVu Sans') def arrow(ax, x1, y1, x2, y2, color=INK, lw=1.5, style='->', head=0.015): ax.annotate('', xy=(x2, y2), xytext=(x1, y1), arrowprops=dict(arrowstyle='->', color=color, lw=lw, mutation_scale=12), zorder=9) def box(ax, x, y, w, h, fc='white', ec=INK, lw=1.2, radius=0.02, alpha=1.0): rect = FancyBboxPatch((x, y), w, h, boxstyle=f'round,pad={radius}', linewidth=lw, edgecolor=ec, facecolor=fc, alpha=alpha, zorder=5) ax.add_patch(rect) def underline_title(ax, x, y, text, size=15, color=BLUE): hw_text(ax, x, y, text, size=size, color=color, bold=True, ha='center') tw = len(text)*0.006 ax.plot([x-tw, x+tw], [y-0.022, y-0.022], color=color, lw=2, zorder=10) # ============================================================ # PAGE 1 – Title + ANS Overview + Organisation # ============================================================ fig1, ax1 = plt.subplots(figsize=(8.5, 11)) page_setup(fig1, ax1) # Title banner box(ax1, 0.05, 0.91, 0.90, 0.075, fc='#1b4fc4', ec=BLUE, radius=0.015) hw_text(ax1, 0.5, 0.952, 'PHARMACOLOGY – PERIPHERAL NERVOUS SYSTEM', size=13, color='white', bold=True, ha='center') hw_text(ax1, 0.5, 0.928, 'ANS: Organisation, Functions & Neurotransmission', size=10.5, color='#d6eaf8', ha='center') # Section 1 header hw_text(ax1, 0.09, 0.875, '1. ORGANISATION OF THE ANS', size=12.5, color=BLUE, bold=True) ax1.plot([0.09, 0.91], [0.864, 0.864], color=BLUE, lw=1.5) # ANS = SNS + PNS bullet block hw_text(ax1, 0.10, 0.845, '• ANS = Autonomic Nervous System', size=10.5, color=INK) hw_text(ax1, 0.10, 0.826, ' = Sympathetic (SNS) + Parasympathetic (PNS)', size=10.5, color=INK) hw_text(ax1, 0.10, 0.808, ' Also called: Visceral / Vegetative / Involuntary NS', size=9.5, color=TEAL, italic=True) # Key difference box box(ax1, 0.08, 0.740, 0.85, 0.058, fc='#eaf4fb', ec=TEAL, lw=1.2) hw_text(ax1, 0.12, 0.778, 'KEY: ANS is a TWO-NEURON (bipolar) chain:', size=10, color=TEAL, bold=True) hw_text(ax1, 0.12, 0.758, 'Preganglionic neuron → ANS Ganglion → Postganglionic neuron → Effector organ', size=9.5, color=INK) # Diagram: Two-neuron chain y_chain = 0.695 # Boxes box(ax1, 0.08, 0.672, 0.13, 0.040, fc='#d5e8f8', ec=BLUE, lw=1.2) hw_text(ax1, 0.145, 0.692, 'CNS', size=9, color=BLUE, bold=True, ha='center') arrow(ax1, 0.21, 0.692, 0.28, 0.692, color=BLUE) box(ax1, 0.28, 0.672, 0.18, 0.040, fc='#d5f8e3', ec=GREEN, lw=1.2) hw_text(ax1, 0.37, 0.692, 'Preganglionic\nneuron', size=8.5, color=GREEN, bold=True, ha='center') arrow(ax1, 0.46, 0.692, 0.53, 0.692, color=GREEN) box(ax1, 0.53, 0.672, 0.14, 0.040, fc='#fff3cd', ec=ORANGE, lw=1.2) hw_text(ax1, 0.60, 0.692, 'Ganglion', size=8.5, color=ORANGE, bold=True, ha='center') arrow(ax1, 0.67, 0.692, 0.74, 0.692, color=ORANGE) box(ax1, 0.74, 0.672, 0.18, 0.040, fc='#fde8f0', ec=RED, lw=1.2) hw_text(ax1, 0.83, 0.692, 'Postganglionic\nneuron', size=8.5, color=RED, bold=True, ha='center') # Neurotransmitters below arrows hw_text(ax1, 0.245, 0.662, 'ACh', size=8, color=BLUE, italic=True, ha='center') hw_text(ax1, 0.595, 0.662, 'ACh', size=8, color=ORANGE, italic=True, ha='center') # Section 2: SNS vs PNS comparison table hw_text(ax1, 0.09, 0.635, '2. SNS vs PNS – AT A GLANCE', size=12.5, color=RED, bold=True) ax1.plot([0.09, 0.91], [0.624, 0.624], color=RED, lw=1.5) # Table header box(ax1, 0.08, 0.596, 0.84, 0.026, fc=RED, ec=RED, lw=0) for txt, xp in [('Feature', 0.18), ('Sympathetic (SNS)', 0.44), ('Parasympathetic (PNS)', 0.73)]: hw_text(ax1, xp, 0.609, txt, size=9.5, color='white', bold=True, ha='center') rows = [ ('Origin', 'Thoracolumbar (T1–L2)', 'Craniosacral (CN III,VII,IX,X; S2–4)'), ('Preganglionic', 'Short', 'Long'), ('Postganglionic', 'Long', 'Short'), ('Ganglion location', 'Paravertebral / prevertebral', 'Near / within effector organ'), ('NT at postganglionic', 'Norepinephrine (NE)', 'Acetylcholine (ACh)'), ('NT preganglionic', 'Acetylcholine (ACh)', 'Acetylcholine (ACh)'), ('Effect', 'Fight-or-Flight (diffuse)', 'Rest-and-Digest (discrete)'), ('Sweat glands', 'ACh (exception!)', 'Not innervated'), ] row_fc = ['#fff9f9', '#f9fff9'] for i, (feat, sns, pns) in enumerate(rows): yy = 0.574 - i*0.028 box(ax1, 0.08, yy-0.013, 0.84, 0.026, fc=row_fc[i%2], ec='#cccccc', lw=0.5, radius=0.004) hw_text(ax1, 0.18, yy, feat, size=9, color=INK, bold=True, ha='center') hw_text(ax1, 0.44, yy, sns, size=8.8, color=RED, ha='center') hw_text(ax1, 0.73, yy, pns, size=8.8, color=BLUE, ha='center') # Footer hw_text(ax1, 0.5, 0.014, 'Page 1 of 4 | ANS Pharmacology – Handwritten Notes', size=8, color='#888888', ha='center', italic=True) fig1.tight_layout(pad=0.3) fig1.savefig('/tmp/workspace/ans-pharmacology/page1.png', dpi=150, bbox_inches='tight', facecolor=PAPER) plt.close(fig1) print('Page 1 done') PYEOF
python3 << 'PYEOF' import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.patches as mpatches from matplotlib.patches import FancyBboxPatch import numpy as np import warnings warnings.filterwarnings('ignore') PAPER='#fffef0'; LINES='#d4c99a'; INK='#1a1a2e' BLUE='#1b4fc4'; RED='#c0392b'; GREEN='#1a7a3c' PURPLE='#6c3483'; ORANGE='#d35400'; TEAL='#148f77' def add_ruled_lines(ax, n=28): for i in np.linspace(0.04, 0.96, n): ax.axhline(i, color=LINES, lw=0.5, alpha=0.7, zorder=0) def page_setup(fig, ax): fig.patch.set_facecolor(PAPER) ax.set_facecolor(PAPER) ax.set_xlim(0, 1); ax.set_ylim(0, 1); ax.axis('off') add_ruled_lines(ax) ax.axvline(0.07, color='#f8a0a0', lw=1.2, alpha=0.8, zorder=1) def hw_text(ax, x, y, text, size=11, color=INK, bold=False, italic=False, ha='left', va='center'): ax.text(x, y, text, fontsize=size, color=color, fontweight='bold' if bold else 'normal', fontstyle='italic' if italic else 'normal', ha=ha, va=va, zorder=10, fontfamily='DejaVu Sans') def arrow(ax, x1, y1, x2, y2, color=INK, lw=1.5): ax.annotate('', xy=(x2,y2), xytext=(x1,y1), arrowprops=dict(arrowstyle='->', color=color, lw=lw, mutation_scale=12), zorder=9) def box(ax, x, y, w, h, fc='white', ec=INK, lw=1.2, radius=0.02, alpha=1.0): rect = FancyBboxPatch((x,y), w, h, boxstyle=f'round,pad={radius}', linewidth=lw, edgecolor=ec, facecolor=fc, alpha=alpha, zorder=5) ax.add_patch(rect) # ============================================================ # PAGE 2 – Neurohumoral Transmission (Cholinergic + Adrenergic) # ============================================================ fig2, ax2 = plt.subplots(figsize=(8.5, 11)) page_setup(fig2, ax2) # Header box(ax2, 0.05, 0.930, 0.90, 0.055, fc=GREEN, ec=GREEN, radius=0.012) hw_text(ax2, 0.5, 0.959, 'NEUROHUMORAL TRANSMISSION', size=14, color='white', bold=True, ha='center') hw_text(ax2, 0.5, 0.938, 'Steps of Synaptic Transmission at ANS Junctions', size=10, color='#d0f0e0', ha='center') # ------- CHOLINERGIC TRANSMISSION ------- hw_text(ax2, 0.09, 0.907, 'A. CHOLINERGIC TRANSMISSION (PNS & preganglionic neurons)', size=11.5, color=BLUE, bold=True) ax2.plot([0.09, 0.91], [0.896, 0.896], color=BLUE, lw=1.5) steps_cho = [ ('1', 'SYNTHESIS', 'Choline + Acetyl-CoA →[ChAT]→ ACh (in cytosol)\n (Rate-limiting step = choline uptake by Na⁺-cotransporter)', BLUE), ('2', 'STORAGE', 'ACh packaged into vesicles by active transport\n Vesicle also contains ATP (cotransmitter) + proteoglycan', TEAL), ('3', 'RELEASE', 'AP → voltage-gated Ca²⁺ channels open → Ca²⁺ influx\n → vesicle fuses with membrane → exocytosis (quanta)', GREEN), ('4', 'RECEPTOR BINDING', 'ACh → Muscarinic (M) or Nicotinic (N) receptors\n Post-synaptic OR pre-synaptic (autoreceptors)', PURPLE), ('5', 'TERMINATION', 'AChE hydrolyses ACh → Choline + Acetate\n Choline recycled back by high-affinity uptake system', RED), ] y_cho = 0.878 for num, title, desc, col in steps_cho: box(ax2, 0.08, y_cho-0.036, 0.025, 0.030, fc=col, ec=col, radius=0.005) hw_text(ax2, 0.0925, y_cho-0.020, num, size=9, color='white', bold=True, ha='center') hw_text(ax2, 0.115, y_cho-0.012, title, size=9.5, color=col, bold=True) hw_text(ax2, 0.115, y_cho-0.028, desc, size=9, color=INK) y_cho -= 0.058 # Mini diagram – cholinergic synapse bx = 0.56; by = 0.766; bw = 0.36; bh = 0.115 box(ax2, bx, by, bw, bh, fc='#eaf7fb', ec=BLUE, lw=1.2) hw_text(ax2, bx+bw/2, by+bh-0.01, 'Cholinergic Synapse', size=8.5, color=BLUE, bold=True, ha='center') # Presynaptic ax2.add_patch(FancyBboxPatch((bx+0.01, by+0.025), 0.10, 0.06, boxstyle='round,pad=0.005', fc='#d5e8f8', ec=BLUE, lw=0.8)) hw_text(ax2, bx+0.06, by+0.058, 'Pre-\nsynaptic', size=7.5, color=BLUE, ha='center') # Vesicles for vx in [0.03, 0.055, 0.08]: circ = plt.Circle((bx+vx, by+0.048), 0.009, color=TEAL, alpha=0.7) ax2.add_patch(circ) hw_text(ax2, bx+vx, by+0.048, 'ACh', size=5.5, color='white', ha='center') # Arrow down arrow(ax2, bx+0.06, by+0.025, bx+0.06, by+0.005, color=GREEN) hw_text(ax2, bx+0.067, by+0.015, 'AChE', size=7, color=RED, italic=True) # Post-synaptic ax2.add_patch(FancyBboxPatch((bx+0.01, by+0.002), 0.10, 0.022, boxstyle='round,pad=0.003', fc='#fde8e0', ec=RED, lw=0.8)) hw_text(ax2, bx+0.06, by+0.013, 'Post-synaptic (M/N)', size=7, color=RED, ha='center') # Receptor legend hw_text(ax2, bx+0.14, by+0.095, 'M = Muscarinic', size=8, color=PURPLE) hw_text(ax2, bx+0.14, by+0.078, 'N = Nicotinic', size=8, color=ORANGE) hw_text(ax2, bx+0.14, by+0.061, 'Block: Atropine (M)', size=8, color=RED) hw_text(ax2, bx+0.14, by+0.044, 'Block: Botulinum toxin', size=8, color=RED) hw_text(ax2, bx+0.14, by+0.027, '(blocks release)', size=7.5, color=RED, italic=True) # ------- ADRENERGIC TRANSMISSION ------- hw_text(ax2, 0.09, 0.695, 'B. ADRENERGIC TRANSMISSION (SNS postganglionic)', size=11.5, color=RED, bold=True) ax2.plot([0.09, 0.91], [0.684, 0.684], color=RED, lw=1.5) steps_adr = [ ('1', 'SYNTHESIS', 'Tyrosine →[TH]→ DOPA →[AAAD]→ Dopamine →[DBH]→ NE\n (TH = Tyrosine hydroxylase = rate-limiting enzyme!)', RED), ('2', 'STORAGE', 'NE stored in vesicles (dense-core) with ATP + chromogranins\n Uptake-1 = neuronal reuptake (main route of inactivation)', ORANGE), ('3', 'RELEASE', 'AP → Ca²⁺ influx → exocytosis of NE (+ ATP + NPY)\n Adrenal medulla: EPI (80%) + NE (20%) released directly', GREEN), ('4', 'RECEPTOR BINDING', 'α₁, α₂, β₁, β₂, β₃ adrenoceptors (G-protein coupled)\n Pre-synaptic α₂ = autoreceptor (inhibits NE release)', PURPLE), ('5', 'TERMINATION', 'Reuptake-1 (neuron, main) → MAO degradation\n Reuptake-2 (extraneuronal) → COMT → VMA', RED), ] y_adr = 0.660 for num, title, desc, col in steps_adr: box(ax2, 0.08, y_adr-0.036, 0.025, 0.030, fc=col, ec=col, radius=0.005) hw_text(ax2, 0.0925, y_adr-0.020, num, size=9, color='white', bold=True, ha='center') hw_text(ax2, 0.115, y_adr-0.012, title, size=9.5, color=col, bold=True) hw_text(ax2, 0.115, y_adr-0.028, desc, size=9, color=INK) y_adr -= 0.058 # Synthesis pathway diagram bx2 = 0.56; by2 = 0.430; bw2 = 0.38; bh2 = 0.20 box(ax2, bx2, by2, bw2, bh2, fc='#fef9ec', ec=ORANGE, lw=1.3) hw_text(ax2, bx2+bw2/2, by2+bh2-0.015, 'NE Synthesis Pathway', size=9, color=ORANGE, bold=True, ha='center') syn_steps = [ ('Tyrosine', 0.045, RED), ('L-DOPA', 0.078, ORANGE), ('Dopamine', 0.111, GREEN), ('NE (Norepinephrine)', 0.144, BLUE), ('EPI (Epinephrine)', 0.172, PURPLE), ] enzymes = ['Tyrosine\nHydroxylase (TH)★', 'AAAD', 'DBH', 'PNMT\n(adrenal medulla)'] yy0 = by2+0.170 for i,(name, _, col) in enumerate(syn_steps): yy = yy0 - i*0.033 box(ax2, bx2+0.02, yy-0.012, 0.20, 0.024, fc='white', ec=col, lw=1.0, radius=0.004) hw_text(ax2, bx2+0.12, yy, name, size=8.5, color=col, bold=True, ha='center') if i < 4: arrow(ax2, bx2+0.12, yy-0.012, bx2+0.12, yy-0.024, color='#666666') hw_text(ax2, bx2+0.24, yy-0.018, enzymes[i], size=7.5, color='#555555', italic=True) hw_text(ax2, bx2+0.24, by2+0.014, '★ = rate-limiting step', size=8, color=RED, italic=True) # Footer hw_text(ax2, 0.5, 0.014, 'Page 2 of 4 | ANS Pharmacology – Handwritten Notes', size=8, color='#888888', ha='center', italic=True) fig2.tight_layout(pad=0.3) fig2.savefig('/tmp/workspace/ans-pharmacology/page2.png', dpi=150, bbox_inches='tight', facecolor=PAPER) plt.close(fig2) print('Page 2 done') PYEOF
python3 << 'PYEOF' import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.patches import FancyBboxPatch import numpy as np import warnings warnings.filterwarnings('ignore') PAPER='#fffef0'; LINES='#d4c99a'; INK='#1a1a2e' BLUE='#1b4fc4'; RED='#c0392b'; GREEN='#1a7a3c' PURPLE='#6c3483'; ORANGE='#d35400'; TEAL='#148f77' def add_ruled_lines(ax, n=28): for i in np.linspace(0.04, 0.96, n): ax.axhline(i, color=LINES, lw=0.5, alpha=0.7, zorder=0) def page_setup(fig, ax): fig.patch.set_facecolor(PAPER) ax.set_facecolor(PAPER) ax.set_xlim(0, 1); ax.set_ylim(0, 1); ax.axis('off') add_ruled_lines(ax) ax.axvline(0.07, color='#f8a0a0', lw=1.2, alpha=0.8, zorder=1) def hw_text(ax, x, y, text, size=11, color=INK, bold=False, italic=False, ha='left', va='center'): ax.text(x, y, text, fontsize=size, color=color, fontweight='bold' if bold else 'normal', fontstyle='italic' if italic else 'normal', ha=ha, va=va, zorder=10, fontfamily='DejaVu Sans') def arrow(ax, x1, y1, x2, y2, color=INK, lw=1.5): ax.annotate('', xy=(x2,y2), xytext=(x1,y1), arrowprops=dict(arrowstyle='->', color=color, lw=lw, mutation_scale=12), zorder=9) def box(ax, x, y, w, h, fc='white', ec=INK, lw=1.2, radius=0.02, alpha=1.0): rect = FancyBboxPatch((x,y), w, h, boxstyle=f'round,pad={radius}', linewidth=lw, edgecolor=ec, facecolor=fc, alpha=alpha, zorder=5) ax.add_patch(rect) # ============================================================ # PAGE 3 – Cotransmission + ANS Functions Table # ============================================================ fig3, ax3 = plt.subplots(figsize=(8.5, 11)) page_setup(fig3, ax3) # Header box(ax3, 0.05, 0.930, 0.90, 0.055, fc=PURPLE, ec=PURPLE, radius=0.012) hw_text(ax3, 0.5, 0.959, 'COTRANSMISSION & ANS FUNCTIONS', size=14, color='white', bold=True, ha='center') hw_text(ax3, 0.5, 0.938, 'Co-transmission, Organ Effects & Receptors', size=10, color='#e8d5f8', ha='center') # ------- COTRANSMISSION ------- hw_text(ax3, 0.09, 0.907, '3. COTRANSMISSION IN THE ANS', size=12, color=PURPLE, bold=True) ax3.plot([0.09, 0.91], [0.896, 0.896], color=PURPLE, lw=1.5) hw_text(ax3, 0.10, 0.876, '• Cotransmission = release of MULTIPLE transmitters from a single neuron', size=10, color=INK) hw_text(ax3, 0.10, 0.858, '• "Cotransmission is the RULE, not the exception" (Lippincott)', size=10, color=PURPLE, italic=True) hw_text(ax3, 0.10, 0.840, '• Primary NT stored with cotransmitter in same vesicle (e.g., ACh + ATP)', size=10, color=INK) # Cotransmitter table headers = ['Neuron Type', 'Primary NT', 'Cotransmitters'] col_xs = [0.18, 0.40, 0.70] box(ax3, 0.08, 0.808, 0.84, 0.024, fc=PURPLE, ec=PURPLE, lw=0) for txt, xp in zip(headers, col_xs): hw_text(ax3, xp, 0.820, txt, size=9.5, color='white', bold=True, ha='center') cotrans_rows = [ ('Cholinergic (PNS post-g)', 'ACh', 'ATP, VIP (vasoactive intestinal peptide)'), ('Adrenergic (SNS post-g)', 'NE', 'ATP, NPY (neuropeptide Y)'), ('Sympathetic (sweat gl.)', 'ACh', 'CGRP, Substance P'), ('Adrenal medulla', 'EPI / NE', 'Enkephalins, NPY, Chromogranins'), ] row_fc = ['#f9f0ff', '#f0e8ff'] for i, (nt, pri, cot) in enumerate(cotrans_rows): yy = 0.792 - i*0.028 box(ax3, 0.08, yy-0.013, 0.84, 0.026, fc=row_fc[i%2], ec='#cccccc', lw=0.5, radius=0.004) hw_text(ax3, 0.18, yy, nt, size=9, color=INK, ha='center') hw_text(ax3, 0.40, yy, pri, size=9, color=PURPLE, bold=True, ha='center') hw_text(ax3, 0.70, yy, cot, size=8.8, color=TEAL, ha='center') # Role of Cotransmitters hw_text(ax3, 0.10, 0.665, ' Roles of Cotransmitters:', size=10, color=ORANGE, bold=True) roles = [ 'Modulate/enhance primary NT action (e.g., NPY potentiates vasoconstriction by NE)', 'Pre-synaptic inhibition – NPY-Y2 receptors act as autoreceptors', 'VIP + ACh: synergism in salivary gland vasodilation & secretion', 'ATP – acts via purinergic receptors (P2X/P2Y) independently of ACh/NE', ] for i, r in enumerate(roles): hw_text(ax3, 0.12, 0.645-i*0.022, f'• {r}', size=9.2, color=INK) # ------- ANS ORGAN EFFECTS ------- hw_text(ax3, 0.09, 0.550, '4. EFFECTS ON ORGANS (Mnemonics)', size=12, color=RED, bold=True) ax3.plot([0.09, 0.91], [0.540, 0.540], color=RED, lw=1.5) # Mnemonic boxes box(ax3, 0.08, 0.508, 0.40, 0.026, fc='#ffe8e8', ec=RED, lw=1.2, radius=0.008) hw_text(ax3, 0.28, 0.521, 'SNS → "Fight or Flight"', size=10, color=RED, bold=True, ha='center') box(ax3, 0.52, 0.508, 0.40, 0.026, fc='#e8f0ff', ec=BLUE, lw=1.2, radius=0.008) hw_text(ax3, 0.72, 0.521, 'PNS → "Rest & Digest"', size=10, color=BLUE, bold=True, ha='center') organ_rows = [ ('Heart Rate', '↑ (β₁)', '↓ (M₂)'), ('BP / Vessels', '↑ Vasoconstriction (α₁)', 'Dilates genitalia only'), ('Bronchi', 'Dilates (β₂)', 'Constricts (M₃)'), ('GI motility', '↓ (α₂, β₂)', '↑ (M₃)'), ('GI sphincters', 'Contracts (α₁)', 'Relaxes (M₃)'), ('Bladder detrusor','Relaxes (β₂)', 'Contracts (M₃)'), ('Bladder sphincter','Contracts (α₁)','Relaxes (M₃)'), ('Pupils', 'Dilates – Mydriasis (α₁)', 'Constricts – Miosis (M₃)'), ('Salivary glands', 'Scant thick saliva (α₁)', 'Copious watery saliva (M₃)'), ('Sweat glands', 'Sweating (ACh, M)', '—'), ] # Table header box(ax3, 0.08, 0.472, 0.84, 0.024, fc='#cc0000', ec=RED, lw=0) for txt, xp in [('Organ', 0.22), ('Sympathetic', 0.50), ('Parasympathetic', 0.78)]: hw_text(ax3, xp, 0.484, txt, size=9.5, color='white', bold=True, ha='center') row_fc2 = ['#fff9f9', '#fff0f0'] for i, (org, sns, pns) in enumerate(organ_rows): yy = 0.458 - i*0.026 box(ax3, 0.08, yy-0.012, 0.84, 0.024, fc=row_fc2[i%2], ec='#cccccc', lw=0.4, radius=0.003) hw_text(ax3, 0.22, yy, org, size=9, color=INK, bold=True, ha='center') hw_text(ax3, 0.50, yy, sns, size=8.5, color=RED, ha='center') hw_text(ax3, 0.78, yy, pns, size=8.5, color=BLUE, ha='center') # Footer hw_text(ax3, 0.5, 0.014, 'Page 3 of 4 | ANS Pharmacology – Handwritten Notes', size=8, color='#888888', ha='center', italic=True) fig3.tight_layout(pad=0.3) fig3.savefig('/tmp/workspace/ans-pharmacology/page3.png', dpi=150, bbox_inches='tight', facecolor=PAPER) plt.close(fig3) print('Page 3 done') PYEOF
python3 << 'PYEOF' import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.patches import FancyBboxPatch import numpy as np import warnings warnings.filterwarnings('ignore') PAPER='#fffef0'; LINES='#d4c99a'; INK='#1a1a2e' BLUE='#1b4fc4'; RED='#c0392b'; GREEN='#1a7a3c' PURPLE='#6c3483'; ORANGE='#d35400'; TEAL='#148f77' MAROON='#7b241c' def add_ruled_lines(ax, n=28): for i in np.linspace(0.04, 0.96, n): ax.axhline(i, color=LINES, lw=0.5, alpha=0.7, zorder=0) def page_setup(fig, ax): fig.patch.set_facecolor(PAPER) ax.set_facecolor(PAPER) ax.set_xlim(0, 1); ax.set_ylim(0, 1); ax.axis('off') add_ruled_lines(ax) ax.axvline(0.07, color='#f8a0a0', lw=1.2, alpha=0.8, zorder=1) def hw_text(ax, x, y, text, size=11, color=INK, bold=False, italic=False, ha='left', va='center'): ax.text(x, y, text, fontsize=size, color=color, fontweight='bold' if bold else 'normal', fontstyle='italic' if italic else 'normal', ha=ha, va=va, zorder=10, fontfamily='DejaVu Sans') def arrow(ax, x1, y1, x2, y2, color=INK, lw=1.5): ax.annotate('', xy=(x2,y2), xytext=(x1,y1), arrowprops=dict(arrowstyle='->', color=color, lw=lw, mutation_scale=12), zorder=9) def box(ax, x, y, w, h, fc='white', ec=INK, lw=1.2, radius=0.02, alpha=1.0): rect = FancyBboxPatch((x,y), w, h, boxstyle=f'round,pad={radius}', linewidth=lw, edgecolor=ec, facecolor=fc, alpha=alpha, zorder=5) ax.add_patch(rect) # ============================================================ # PAGE 4 – Classification of Neurotransmitters + Quick Review # ============================================================ fig4, ax4 = plt.subplots(figsize=(8.5, 11)) page_setup(fig4, ax4) # Header box(ax4, 0.05, 0.930, 0.90, 0.055, fc=TEAL, ec=TEAL, radius=0.012) hw_text(ax4, 0.5, 0.959, 'CLASSIFICATION OF NEUROTRANSMITTERS', size=13.5, color='white', bold=True, ha='center') hw_text(ax4, 0.5, 0.938, 'Types, Examples & Key Points', size=10, color='#d0f0ee', ha='center') # Classification Mind-Map style hw_text(ax4, 0.09, 0.907, '5. CLASSIFICATION OF NEUROTRANSMITTERS', size=12, color=TEAL, bold=True) ax4.plot([0.09, 0.91], [0.896, 0.896], color=TEAL, lw=1.5) # Central box box(ax4, 0.34, 0.830, 0.32, 0.038, fc=TEAL, ec=TEAL, radius=0.01) hw_text(ax4, 0.50, 0.849, 'NEUROTRANSMITTERS', size=10, color='white', bold=True, ha='center') classes = [ # (x_box, y_box, w, h, label, examples, color, arrow_from_x, arrow_from_y) (0.04, 0.760, 0.26, 0.050, 'I. Cholinergic', 'ACh', BLUE, 0.40, 0.830), (0.04, 0.690, 0.26, 0.050, 'II. Adrenergic /\nCatecholamines', 'NE, EPI, Dopamine', RED, 0.40, 0.830), (0.04, 0.620, 0.26, 0.050, 'III. Amino Acids\n(inhibitory)', 'GABA, Glycine', GREEN, 0.40, 0.830), (0.04, 0.550, 0.26, 0.050, 'IV. Amino Acids\n(excitatory)', 'Glutamate, Aspartate', ORANGE, 0.40, 0.830), (0.70, 0.760, 0.26, 0.050, 'V. Purines', 'ATP, Adenosine', PURPLE, 0.60, 0.830), (0.70, 0.690, 0.26, 0.050, 'VI. Neuropeptides', 'NPY, VIP, Substance P,\nEnkephalins, CGRP', MAROON, 0.60, 0.830), (0.70, 0.620, 0.26, 0.050, 'VII. Gaseous NTs', 'NO (nitric oxide),\nCO, H₂S', TEAL, 0.60, 0.830), (0.70, 0.550, 0.26, 0.050, 'VIII. Others', '5-HT (Serotonin),\nHistamine, Melatonin', GREEN, 0.60, 0.830), ] for bx, by, bw, bh, label, ex, col, ax_from, ay_from in classes: box(ax4, bx, by, bw, bh, fc='white', ec=col, lw=1.3, radius=0.008) hw_text(ax4, bx+bw/2, by+bh*0.70, label, size=9, color=col, bold=True, ha='center') hw_text(ax4, bx+bw/2, by+bh*0.25, ex, size=8.2, color=INK, ha='center', italic=True) # line from center box to this class box bx_end = bx+bw if bx < 0.4 else bx by_mid = by+bh/2 ax4.plot([ax_from, bx_end], [ay_from, by_mid], color=col, lw=1.0, alpha=0.6, zorder=3) # ---- Detailed notes on key NTs ---- hw_text(ax4, 0.09, 0.510, '6. KEY NEUROTRANSMITTER DETAILS', size=12, color=ORANGE, bold=True) ax4.plot([0.09, 0.91], [0.500, 0.500], color=ORANGE, lw=1.5) details = [ (BLUE, 'ACh', 'Preganglionic (both SNS & PNS) + PNS postganglionic + NMJ + sweat glands'), (RED, 'NE', 'SNS postganglionic (main). Terminated by Reuptake-1 → MAO/COMT'), (RED, 'EPI', 'Adrenal medulla (80%). Binds α & β receptors more than NE on β₂'), (PURPLE, 'DA', 'Precursor to NE; own receptors (D1–D5) in CNS & renal vasculature'), (PURPLE, 'NPY', 'Cotransmitter with NE at vascular sympathetic terminals; vasoconstrictive'), (TEAL, 'VIP', 'Cotransmitter with ACh (parasympathetic); vasodilatation & secretion'), (GREEN, 'ATP', 'Cotransmitter in BOTH sympathetic & parasympathetic neurons; purinergic'), (TEAL, 'NO', 'Gaseous; synthesized from L-arginine by NOS; key in erectile function & vasodilation'), ] y_det = 0.480 for col, nt, desc in details: box(ax4, 0.09, y_det-0.017, 0.065, 0.026, fc=col, ec=col, radius=0.005) hw_text(ax4, 0.123, y_det, nt, size=9, color='white', bold=True, ha='center') hw_text(ax4, 0.165, y_det, desc, size=9, color=INK) y_det -= 0.033 # ---- Quick Memory Aid ---- box(ax4, 0.08, 0.137, 0.84, 0.100, fc='#fffbe0', ec=ORANGE, lw=1.5, radius=0.01) hw_text(ax4, 0.50, 0.230, '★ QUICK MEMORY AID ★', size=11, color=ORANGE, bold=True, ha='center') hw_text(ax4, 0.50, 0.213, '"All preganglionic neurons → ACh (cholinergic)"', size=9.5, color=BLUE, ha='center', italic=True) hw_text(ax4, 0.50, 0.196, '"SNS postganglionic → NE | PNS postganglionic → ACh"', size=9.5, color=RED, ha='center', italic=True) hw_text(ax4, 0.50, 0.179, '"Exception: SNS to sweat glands → ACh (cholinergic sympathetic!)"', size=9.5, color=GREEN, ha='center', italic=True) hw_text(ax4, 0.50, 0.162, '"Cotransmission = rule! Primary NT always accompanied by ATP ± peptide"', size=9.5, color=PURPLE, ha='center', italic=True) hw_text(ax4, 0.50, 0.145, 'TH★ (NE synthesis) | ChAT (ACh synthesis) | AChE (ACh termination)', size=9.5, color=MAROON, ha='center', italic=True) # Footer hw_text(ax4, 0.5, 0.014, 'Page 4 of 4 | ANS Pharmacology – Handwritten Notes | Source: Goodman & Gilman, Lippincott, Barash', size=7.5, color='#888888', ha='center', italic=True) fig4.tight_layout(pad=0.3) fig4.savefig('/tmp/workspace/ans-pharmacology/page4.png', dpi=150, bbox_inches='tight', facecolor=PAPER) plt.close(fig4) print('Page 4 done') PYEOF
python3 << 'PYEOF' from PIL import Image from reportlab.lib.pagesizes import letter from reportlab.pdfgen import canvas import os out_pdf = '/tmp/workspace/ans-pharmacology/ANS_Pharmacology_Notes.pdf' pages = [ '/tmp/workspace/ans-pharmacology/page1.png', '/tmp/workspace/ans-pharmacology/page2.png', '/tmp/workspace/ans-pharmacology/page3.png', '/tmp/workspace/ans-pharmacology/page4.png', ] c = canvas.Canvas(out_pdf, pagesize=letter) W, H = letter # 612 x 792 for pg in pages: img = Image.open(pg) img_w, img_h = img.size # Scale to fit page scale = min(W/img_w, H/img_h) new_w = img_w * scale new_h = img_h * scale x = (W - new_w) / 2 y = (H - new_h) / 2 c.drawImage(pg, x, y, width=new_w, height=new_h) c.showPage() c.save() size = os.path.getsize(out_pdf) print(f'PDF created: {out_pdf} ({size/1024:.0f} KB)') PYEOF
ANS Pharmacology Notes
PDF Document · PDF
/generate handwritten symphathomimetics and sympatolytics and parasympatolytics and parasympatomimetics and with digrams
mkdir -p /tmp/workspace/ans-drugs && python3 << 'PYEOF' import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.patches import FancyBboxPatch import numpy as np import warnings warnings.filterwarnings('ignore') PAPER='#fffef0'; LINES='#d4c99a'; INK='#1a1a2e' BLUE='#1b4fc4'; RED='#c0392b'; GREEN='#1a7a3c' PURPLE='#6c3483'; ORANGE='#d35400'; TEAL='#148f77' MAROON='#7b241c'; PINK='#c0185a'; DKBLUE='#0d2b6e' def ruled(ax, n=30): for i in np.linspace(0.03, 0.97, n): ax.axhline(i, color=LINES, lw=0.45, alpha=0.65, zorder=0) def setup(fig, ax): fig.patch.set_facecolor(PAPER); ax.set_facecolor(PAPER) ax.set_xlim(0,1); ax.set_ylim(0,1); ax.axis('off') ruled(ax) ax.axvline(0.07, color='#f8a0a0', lw=1.1, alpha=0.75, zorder=1) def T(ax, x, y, txt, sz=10, col=INK, bold=False, ital=False, ha='left', va='center'): ax.text(x, y, txt, fontsize=sz, color=col, fontweight='bold' if bold else 'normal', fontstyle='italic' if ital else 'normal', ha=ha, va=va, zorder=10, fontfamily='DejaVu Sans') def ARR(ax, x1, y1, x2, y2, col=INK, lw=1.4): ax.annotate('', xy=(x2,y2), xytext=(x1,y1), arrowprops=dict(arrowstyle='->', color=col, lw=lw, mutation_scale=11), zorder=9) def BOX(ax, x, y, w, h, fc='white', ec=INK, lw=1.2, r=0.015, al=1.0): ax.add_patch(FancyBboxPatch((x,y), w, h, boxstyle=f'round,pad={r}', linewidth=lw, edgecolor=ec, facecolor=fc, alpha=al, zorder=5)) def hdr(ax, title, sub, col): BOX(ax, 0.04, 0.930, 0.92, 0.058, fc=col, ec=col, r=0.012) T(ax, 0.50, 0.962, title, sz=13.5, col='white', bold=True, ha='center') T(ax, 0.50, 0.940, sub, sz=9.5, col='#e8f8ff', ha='center') def footer(ax, pg, total=6): T(ax, 0.50, 0.013, f'Page {pg} of {total} | ANS Drug Pharmacology – Handwritten Notes | Source: Goodman & Gilman, Lippincott, Barash', sz=7.2, col='#888888', ha='center', ital=True) # ============================================================ # PAGE 1 – Overview + Sympathomimetics Classification # ============================================================ fig,ax = plt.subplots(figsize=(8.5,11)) setup(fig,ax) hdr(ax, 'ANS DRUG PHARMACOLOGY – OVERVIEW', 'Sympathomimetics • Sympatholytics • Parasympathomimetics • Parasympatholytics', DKBLUE) # Big overview diagram T(ax, 0.09, 0.905, '1. OVERVIEW – ANS DRUG CLASSIFICATION', sz=12, col=DKBLUE, bold=True) ax.plot([0.09,0.91],[0.894,0.894], color=DKBLUE, lw=1.4) # Central node BOX(ax, 0.38, 0.848, 0.24, 0.030, fc=DKBLUE, ec=DKBLUE, r=0.008) T(ax, 0.50, 0.863, 'ANS DRUGS', sz=10, col='white', bold=True, ha='center') branches = [ (0.10, 0.800, 0.22, 0.028, 'SYMPATHOMIMETICS', '(Adrenergic Agonists)', RED, 0.38, 0.863), (0.10, 0.758, 0.22, 0.028, 'SYMPATHOLYTICS', '(Adrenergic Antagonists)', MAROON, 0.38, 0.863), (0.68, 0.800, 0.22, 0.028, 'PARASYMPATHOMIMETICS', '(Cholinergic Agonists)', BLUE, 0.62, 0.863), (0.68, 0.758, 0.22, 0.028, 'PARASYMPATHOLYTICS', '(Cholinergic Antagonists)', PURPLE, 0.62, 0.863), ] for bx,by,bw,bh,lab,sub,col,ax2,ay2 in branches: BOX(ax, bx, by, bw, bh, fc='white', ec=col, lw=1.3, r=0.007) T(ax, bx+bw/2, by+bh*0.7, lab, sz=8.5, col=col, bold=True, ha='center') T(ax, bx+bw/2, by+bh*0.2, sub, sz=7.5, col=INK, ha='center', ital=True) bx_end = bx+bw if bx < 0.40 else bx by_mid = by+bh/2 ax.plot([ax2, bx_end],[ay2, by_mid], color=col, lw=1.0, alpha=0.7, zorder=3) # Section: Sympathomimetics T(ax, 0.09, 0.726, '2. SYMPATHOMIMETICS (Adrenergic Agonists / SNS Mimics)', sz=12, col=RED, bold=True) ax.plot([0.09,0.91],[0.715,0.715], color=RED, lw=1.4) T(ax, 0.10, 0.697, 'Definition: Drugs that mimic SNS activity by stimulating adrenergic receptors (directly / indirectly / mixed)', sz=9.5, col=INK) # Classification box BOX(ax, 0.08, 0.656, 0.84, 0.034, fc='#ffe8e8', ec=RED, lw=1.2) T(ax, 0.50, 0.673, 'CLASSIFICATION BY MECHANISM OF ACTION', sz=10, col=RED, bold=True, ha='center') mech_cols = [0.16, 0.50, 0.84] BOX(ax, 0.08, 0.608, 0.84, 0.043, fc='white', ec='#cccccc', lw=0.5, r=0.004) for txt,xp in [('DIRECT', 0.16), ('INDIRECT', 0.50), ('MIXED', 0.84)]: BOX(ax, xp-0.10, 0.615, 0.185, 0.028, fc=RED if txt=='DIRECT' else ORANGE if txt=='INDIRECT' else GREEN, ec='white', lw=0, r=0.006) T(ax, xp, 0.629, txt, sz=9.5, col='white', bold=True, ha='center') T(ax, 0.16, 0.600, 'Acts on α/β receptors', sz=8.5, col=RED, ha='center') T(ax, 0.16, 0.588, 'EPI, NE, DA,', sz=8.5, col=INK, ha='center') T(ax, 0.16, 0.577, 'Phenylephrine,', sz=8.5, col=INK, ha='center') T(ax, 0.16, 0.566, 'Salbutamol', sz=8.5, col=INK, ha='center') T(ax, 0.50, 0.600, 'Releases NE from stores', sz=8.5, col=ORANGE, ha='center') T(ax, 0.50, 0.588, 'Amphetamine,', sz=8.5, col=INK, ha='center') T(ax, 0.50, 0.577, 'Tyramine', sz=8.5, col=INK, ha='center') T(ax, 0.84, 0.600, 'Direct + Indirect', sz=8.5, col=GREEN, ha='center') T(ax, 0.84, 0.588, 'Ephedrine,', sz=8.5, col=INK, ha='center') T(ax, 0.84, 0.577, 'Pseudoephedrine', sz=8.5, col=INK, ha='center') # Classification by receptor selectivity T(ax, 0.09, 0.548, 'CLASSIFICATION BY RECEPTOR SELECTIVITY:', sz=10.5, col=MAROON, bold=True) rcols = [ ('α₁ selective', 'Phenylephrine\nMethoxamine\nMidodrine', RED, 0.09), ('α₂ selective', 'Clonidine\nDexmedetomidine\nMethyldopa', MAROON, 0.275), ('β₁ selective', 'Dobutamine\nAtenolol (blocker)\nMetoprolol (blocker)', ORANGE, 0.46), ('β₂ selective', 'Salbutamol\nTerbutaline\nSalmeterol\nFormoterol', TEAL, 0.645), ('Non-selective\nα+β', 'EPI (α₁,α₂,β₁,β₂)\nNE (α₁,α₂,β₁)\nIsoproterenol (β₁,β₂)', PURPLE, 0.830), ] for lab,drugs,col,xp in rcols: xp = min(xp, 0.83) BOX(ax, xp, 0.455, 0.165, 0.080, fc='white', ec=col, lw=1.2, r=0.007) T(ax, xp+0.0825, 0.524, lab, sz=8.2, col=col, bold=True, ha='center') T(ax, xp+0.0825, 0.488, drugs, sz=7.8, col=INK, ha='center') # Catecholamine vs Non-catecholamine T(ax, 0.09, 0.435, 'CATECHOLAMINES vs NON-CATECHOLAMINES:', sz=10.5, col=ORANGE, bold=True) BOX(ax, 0.08, 0.368, 0.40, 0.058, fc='#fff0e0', ec=ORANGE, lw=1.2) T(ax, 0.28, 0.416, 'Catecholamines', sz=9.5, col=ORANGE, bold=True, ha='center') T(ax, 0.28, 0.400, 'EPI, NE, DA, Dobutamine,', sz=8.5, col=INK, ha='center') T(ax, 0.28, 0.387, 'Isoproterenol', sz=8.5, col=INK, ha='center') T(ax, 0.28, 0.374, 'Not orally active; short t½; NOT CNS', sz=8, col=RED, ha='center', ital=True) BOX(ax, 0.52, 0.368, 0.40, 0.058, fc='#f0ffe0', ec=GREEN, lw=1.2) T(ax, 0.72, 0.416, 'Non-Catecholamines', sz=9.5, col=GREEN, bold=True, ha='center') T(ax, 0.72, 0.400, 'Ephedrine, Amphetamine,', sz=8.5, col=INK, ha='center') T(ax, 0.72, 0.387, 'Phenylephrine, Salbutamol', sz=8.5, col=INK, ha='center') T(ax, 0.72, 0.374, 'Orally active; longer t½; CNS effects', sz=8, col=GREEN, ha='center', ital=True) # Important drugs table T(ax, 0.09, 0.347, 'KEY SYMPATHOMIMETICS – RECEPTOR PROFILE & USES:', sz=10.5, col=RED, bold=True) BOX(ax, 0.08, 0.315, 0.84, 0.024, fc=RED, ec=RED, lw=0) for hh,xp in [('Drug', 0.18),('Receptors', 0.38),('Main Use(s)', 0.70)]: T(ax, xp, 0.327, hh, sz=9, col='white', bold=True, ha='center') drug_rows = [ ('EPI (Adrenaline)', 'α₁,α₂,β₁,β₂', 'Anaphylaxis, Cardiac arrest, Bronchospasm', 0), ('NE (Noradrenaline)', 'α₁,α₂,β₁ (>>β₂)', 'Septic shock (vasopressor)', 1), ('Dopamine', 'D₁,D₂, β₁, α₁ (dose-dep)', 'Shock, Renal perfusion, Heart failure', 0), ('Dobutamine', 'β₁ > β₂ (direct)', 'Acute heart failure, Stress echo', 1), ('Isoproterenol', 'β₁ = β₂ (non-sel)', 'AV block, Severe bradycardia', 0), ('Phenylephrine', 'α₁ selective', 'Hypotension, Nasal decongestant, Mydriasis', 1), ('Salbutamol', 'β₂ selective', 'Bronchial asthma (acute relief)', 0), ('Clonidine', 'α₂ central agonist', 'Hypertension, Opioid withdrawal, Sedation', 1), ('Ephedrine', 'α,β (direct+indirect)', 'Spinal hypotension, Nasal congestion', 0), ] rfc = ['#fff5f5','#ffebeb'] for i,(drg,rec,use,_) in enumerate(drug_rows): yy = 0.299 - i*0.024 BOX(ax, 0.08, yy-0.011, 0.84, 0.022, fc=rfc[i%2], ec='#dddddd', lw=0.4, r=0.003) T(ax, 0.18, yy, drg, sz=8.5, col=RED, bold=True, ha='center') T(ax, 0.38, yy, rec, sz=8.2, col=PURPLE, ha='center') T(ax, 0.70, yy, use, sz=8.2, col=INK, ha='center') footer(ax, 1) fig.tight_layout(pad=0.3) fig.savefig('/tmp/workspace/ans-drugs/p1.png', dpi=150, bbox_inches='tight', facecolor=PAPER) plt.close(fig) print('P1 done') PYEOF
python3 << 'PYEOF' import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.patches import FancyBboxPatch import numpy as np import warnings warnings.filterwarnings('ignore') PAPER='#fffef0'; LINES='#d4c99a'; INK='#1a1a2e' BLUE='#1b4fc4'; RED='#c0392b'; GREEN='#1a7a3c' PURPLE='#6c3483'; ORANGE='#d35400'; TEAL='#148f77' MAROON='#7b241c'; PINK='#c0185a'; DKBLUE='#0d2b6e' def ruled(ax, n=30): for i in np.linspace(0.03, 0.97, n): ax.axhline(i, color=LINES, lw=0.45, alpha=0.65, zorder=0) def setup(fig, ax): fig.patch.set_facecolor(PAPER); ax.set_facecolor(PAPER) ax.set_xlim(0,1); ax.set_ylim(0,1); ax.axis('off') ruled(ax) ax.axvline(0.07, color='#f8a0a0', lw=1.1, alpha=0.75, zorder=1) def T(ax, x, y, txt, sz=10, col=INK, bold=False, ital=False, ha='left', va='center'): ax.text(x, y, txt, fontsize=sz, color=col, fontweight='bold' if bold else 'normal', fontstyle='italic' if ital else 'normal', ha=ha, va=va, zorder=10, fontfamily='DejaVu Sans') def ARR(ax, x1, y1, x2, y2, col=INK, lw=1.4): ax.annotate('', xy=(x2,y2), xytext=(x1,y1), arrowprops=dict(arrowstyle='->', color=col, lw=lw, mutation_scale=11), zorder=9) def BOX(ax, x, y, w, h, fc='white', ec=INK, lw=1.2, r=0.015, al=1.0): ax.add_patch(FancyBboxPatch((x,y), w, h, boxstyle=f'round,pad={r}', linewidth=lw, edgecolor=ec, facecolor=fc, alpha=al, zorder=5)) def footer(ax, pg, total=6): T(ax, 0.50, 0.013, f'Page {pg} of {total} | ANS Drug Pharmacology – Handwritten Notes | Source: Goodman & Gilman, Lippincott, Barash', sz=7.2, col='#888888', ha='center', ital=True) # ============================================================ # PAGE 2 – Adrenergic Receptor Diagram + EPI/NE/DA dose-effects # ============================================================ fig,ax = plt.subplots(figsize=(8.5,11)) setup(fig,ax) BOX(ax, 0.04, 0.930, 0.92, 0.058, fc=RED, ec=RED, r=0.012) T(ax, 0.50, 0.962, 'SYMPATHOMIMETICS – RECEPTOR DIAGRAMS & DOSE EFFECTS', sz=12.5, col='white', bold=True, ha='center') T(ax, 0.50, 0.940, 'Adrenergic Receptor Subtypes, Signalling & Drug Profiles', sz=9.5, col='#ffe0e0', ha='center') # Adrenergic receptor tree T(ax, 0.09, 0.906, 'A. ADRENERGIC RECEPTOR SUBTYPES', sz=11.5, col=RED, bold=True) ax.plot([0.09,0.91],[0.895,0.895], color=RED, lw=1.3) # Root BOX(ax, 0.38, 0.858, 0.24, 0.028, fc=RED, ec=RED, r=0.007) T(ax, 0.50, 0.872, 'Adrenoceptors', sz=10, col='white', bold=True, ha='center') # α and β for xb,lab,col in [(0.13,0.863,'α-receptors',MAROON),(0.65,0.863,'β-receptors',ORANGE)]: BOX(ax, xb, 0.828, 0.20, 0.026, fc='white', ec=col, lw=1.3, r=0.007) T(ax, xb+0.10, 0.841, lab, sz=9.5, col=col, bold=True, ha='center') xe = 0.38 if xb<0.40 else 0.62 ax.plot([xe,xb+0.10],[0.858,0.854], color=col, lw=1.0, alpha=0.7) # α sub-types sub_alpha = [ (0.07, 0.772, 'α₁', 'Postsynaptic\nGq → ↑IP₃, DAG\nVasoconstriction\nMydriasis\nBladder contracts', MAROON), (0.23, 0.772, 'α₂', 'Pre & postsynaptic\nGi → ↓cAMP\nInhibits NE release\nPlatelet aggregation\nLowers IOP', RED), ] for bx,by,lab,desc,col in sub_alpha: BOX(ax, bx, by-0.068, 0.145, 0.095, fc='#fff0f0', ec=col, lw=1.1, r=0.007) T(ax, bx+0.0725, by, lab, sz=11, col=col, bold=True, ha='center') T(ax, bx+0.0725, by-0.040, desc, sz=7.8, col=INK, ha='center') ax.plot([0.23, bx+0.0725],[0.828, by+0.027], color=col, lw=0.9, alpha=0.7) # β sub-types sub_beta = [ (0.54, 0.772, 'β₁', 'Heart\nGs → ↑cAMP → PKA\n↑HR (chronotropy)\n↑Force (inotropy)\n↑AV conduction', ORANGE), (0.69, 0.772, 'β₂', 'Bronchi, vessels,\nuterus, skeletal m.\nGs → ↑cAMP\nBronchodilation\nVasodilation', TEAL), (0.84, 0.772, 'β₃', 'Adipose tissue\nGs → ↑cAMP\nLipolysis\nThermogenesis', GREEN), ] for bx,by,lab,desc,col in sub_beta: BOX(ax, bx, by-0.068, 0.135, 0.095, fc='#fff8e0', ec=col, lw=1.1, r=0.007) T(ax, bx+0.0675, by, lab, sz=11, col=col, bold=True, ha='center') T(ax, bx+0.0675, by-0.040, desc, sz=7.5, col=INK, ha='center') ax.plot([0.75, bx+0.0675],[0.828, by+0.027], color=col, lw=0.9, alpha=0.7) # Drug Dose-Effect profiles T(ax, 0.09, 0.665, 'B. DOSE-DEPENDENT RECEPTOR ACTIVATION', sz=11.5, col=ORANGE, bold=True) ax.plot([0.09,0.91],[0.654,0.654], color=ORANGE, lw=1.3) dose_drugs = [ ('EPINEPHRINE (EPI)', [ ('Low dose', 'Mainly β₁, β₂', 'HR↑, CO↑, Bronchodilation, Vasodilation (β₂)', TEAL), ('High dose', 'α₁ + β₁,β₂', 'Vasoconstriction (α₁) + cardiac stimulation', RED), ], RED), ('DOPAMINE (DA)', [ ('Low (1-3 mcg/kg/min)', 'D₁, D₂', 'Renal vasodilation, ↑urine output', BLUE), ('Medium (3-10 mcg/kg/min)', 'β₁', 'Inotropy ↑, CO↑', ORANGE), ('High (>10 mcg/kg/min)', 'α₁', 'Vasoconstriction, BP↑', RED), ], PURPLE), ] yy = 0.635 for drug_name, doses, col in dose_drugs: BOX(ax, 0.08, yy-0.022, 0.25, 0.020, fc=col, ec=col, r=0.006) T(ax, 0.205, yy-0.011, drug_name, sz=9.5, col='white', bold=True, ha='center') for dose_label, recep, effect, dcol in doses: yy -= 0.028 BOX(ax, 0.09, yy-0.012, 0.84, 0.022, fc='#fafafa', ec='#cccccc', lw=0.4, r=0.003) T(ax, 0.20, yy, dose_label, sz=8.5, col=dcol, bold=True, ha='center') T(ax, 0.38, yy, recep, sz=8.5, col=PURPLE, ha='center') T(ax, 0.70, yy, effect, sz=8.5, col=INK, ha='center') yy -= 0.015 # NE profile BOX(ax, 0.08, yy-0.022, 0.25, 0.020, fc=MAROON, ec=MAROON, r=0.006) T(ax, 0.205, yy-0.011, 'NOREPINEPHRINE (NE)', sz=9.5, col='white', bold=True, ha='center') yy -= 0.028 BOX(ax, 0.09, yy-0.012, 0.84, 0.022, fc='#fafafa', ec='#cccccc', lw=0.4, r=0.003) T(ax, 0.20, yy, 'All doses', sz=8.5, col=MAROON, bold=True, ha='center') T(ax, 0.38, yy, 'α₁,α₂,β₁ (no β₂)', sz=8.5, col=PURPLE, ha='center') T(ax, 0.70, yy, 'Vasoconstriction + HR↑ (reflex bradycardia at high doses)', sz=8.5, col=INK, ha='center') # Memory box yy -= 0.045 BOX(ax, 0.08, yy-0.030, 0.84, 0.052, fc='#fff8f0', ec=ORANGE, lw=1.5, r=0.01) T(ax, 0.50, yy+0.014, '★ MEMORY TRICK ★', sz=10.5, col=ORANGE, bold=True, ha='center') T(ax, 0.50, yy-0.002, 'EPI = Emergency drug (anaphylaxis → ALL receptors) | NE = No β₂ = \'NE-ver dilates bronchi\'', sz=9, col=RED, ha='center', ital=True) T(ax, 0.50, yy-0.018, 'DA doses: 1-3 = Diuresis | 3-10 = Beats heart | >10 = Baaaad vasoconstriction', sz=9, col=PURPLE, ha='center', ital=True) footer(ax, 2) fig.tight_layout(pad=0.3) fig.savefig('/tmp/workspace/ans-drugs/p2.png', dpi=150, bbox_inches='tight', facecolor=PAPER) plt.close(fig) print('P2 done') PYEOF
python3 << 'PYEOF' import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.patches import FancyBboxPatch import numpy as np import warnings warnings.filterwarnings('ignore') PAPER='#fffef0'; LINES='#d4c99a'; INK='#1a1a2e' BLUE='#1b4fc4'; RED='#c0392b'; GREEN='#1a7a3c' PURPLE='#6c3483'; ORANGE='#d35400'; TEAL='#148f77' MAROON='#7b241c'; DKBLUE='#0d2b6e' def ruled(ax, n=30): for i in np.linspace(0.03, 0.97, n): ax.axhline(i, color=LINES, lw=0.45, alpha=0.65, zorder=0) def setup(fig, ax): fig.patch.set_facecolor(PAPER); ax.set_facecolor(PAPER) ax.set_xlim(0,1); ax.set_ylim(0,1); ax.axis('off') ruled(ax) ax.axvline(0.07, color='#f8a0a0', lw=1.1, alpha=0.75, zorder=1) def T(ax, x, y, txt, sz=10, col=INK, bold=False, ital=False, ha='left', va='center'): ax.text(x, y, txt, fontsize=sz, color=col, fontweight='bold' if bold else 'normal', fontstyle='italic' if ital else 'normal', ha=ha, va=va, zorder=10, fontfamily='DejaVu Sans') def BOX(ax, x, y, w, h, fc='white', ec=INK, lw=1.2, r=0.015, al=1.0): ax.add_patch(FancyBboxPatch((x,y), w, h, boxstyle=f'round,pad={r}', linewidth=lw, edgecolor=ec, facecolor=fc, alpha=al, zorder=5)) def footer(ax, pg, total=6): T(ax, 0.50, 0.013, f'Page {pg} of {total} | ANS Drug Pharmacology – Handwritten Notes', sz=7.5, col='#888888', ha='center', ital=True) fig,ax = plt.subplots(figsize=(8.5,11)) setup(fig,ax) BOX(ax, 0.04, 0.930, 0.92, 0.058, fc=RED, ec=RED, r=0.012) T(ax, 0.50, 0.962, 'SYMPATHOMIMETICS – RECEPTOR DIAGRAMS & DOSE EFFECTS', sz=12.5, col='white', bold=True, ha='center') T(ax, 0.50, 0.940, 'Adrenergic Receptor Subtypes, Signalling & Drug Profiles', sz=9.5, col='#ffe0e0', ha='center') # Adrenergic receptor tree T(ax, 0.09, 0.906, 'A. ADRENERGIC RECEPTOR SUBTYPES', sz=11.5, col=RED, bold=True) ax.plot([0.09,0.91],[0.895,0.895], color=RED, lw=1.3) BOX(ax, 0.38, 0.858, 0.24, 0.028, fc=RED, ec=RED, r=0.007) T(ax, 0.50, 0.872, 'Adrenoceptors', sz=10, col='white', bold=True, ha='center') # α and β branches for xb, lab, col, cx in [(0.13, 'α-receptors', MAROON, 0.38),(0.65, 'β-receptors', ORANGE, 0.62)]: BOX(ax, xb, 0.828, 0.20, 0.026, fc='white', ec=col, lw=1.3, r=0.007) T(ax, xb+0.10, 0.841, lab, sz=9.5, col=col, bold=True, ha='center') ax.plot([cx, xb+0.10],[0.858, 0.854], color=col, lw=1.0, alpha=0.7) # α sub-types alpha_data = [ (0.07, 'α₁', 'Postsynaptic\nGq → ↑IP₃,DAG\nVasoconstriction\nMydriasis\nBladder contracts', MAROON), (0.23, 'α₂', 'Pre+postsynaptic\nGi → ↓cAMP\nInhibits NE release\nPlatelet aggreg.\nLowers IOP', RED), ] for bx, lab, desc, col in alpha_data: BOX(ax, bx, 0.704, 0.145, 0.092, fc='#fff0f0', ec=col, lw=1.1, r=0.007) T(ax, bx+0.0725, 0.784, lab, sz=11, col=col, bold=True, ha='center') T(ax, bx+0.0725, 0.748, desc, sz=7.6, col=INK, ha='center') ax.plot([0.23, bx+0.0725],[0.828, 0.796], color=col, lw=0.9, alpha=0.7) # β sub-types beta_data = [ (0.535, 'β₁', 'Heart\nGs→↑cAMP→PKA\n↑HR (chronotropy)\n↑Force (inotropy)\n↑AV conduction', ORANGE), (0.690, 'β₂', 'Bronchi,vessels,\nuterus,skel.m.\nGs→↑cAMP\nBronchodilation\nVasodilation', TEAL), (0.845, 'β₃', 'Adipose tissue\nGs→↑cAMP\nLipolysis\nThermogenesis', GREEN), ] for bx, lab, desc, col in beta_data: BOX(ax, bx, 0.704, 0.135, 0.092, fc='#fff8e0', ec=col, lw=1.1, r=0.007) T(ax, bx+0.0675, 0.784, lab, sz=11, col=col, bold=True, ha='center') T(ax, bx+0.0675, 0.748, desc, sz=7.4, col=INK, ha='center') ax.plot([0.75, bx+0.0675],[0.828, 0.796], color=col, lw=0.9, alpha=0.7) # Dose-Dependent effects T(ax, 0.09, 0.678, 'B. DOSE-DEPENDENT RECEPTOR ACTIVATION', sz=11.5, col=ORANGE, bold=True) ax.plot([0.09,0.91],[0.667,0.667], color=ORANGE, lw=1.3) # Table header BOX(ax, 0.08, 0.640, 0.84, 0.022, fc=ORANGE, ec=ORANGE, lw=0) for hh,xp in [('Drug/Dose', 0.20),('Receptors', 0.42),('Effects', 0.70)]: T(ax, xp, 0.651, hh, sz=9, col='white', bold=True, ha='center') dose_rows = [ ('EPI – low dose', 'β₁,β₂ dominant', 'HR↑, CO↑, Bronchodilation, Vasodilation', RED, '#fff0f0'), ('EPI – high dose', 'α₁+β₁,β₂', 'Vasoconstriction+cardiac stimulation', RED, '#ffe8e8'), ('NE – all doses', 'α₁,α₂,β₁ (no β₂)', 'Vasoconstriction, HR↑, reflex bradycardia', MAROON, '#fff5f5'), ('DA – low (1-3)', 'D₁,D₂', 'Renal vasodilation, ↑urine output', BLUE, '#f0f5ff'), ('DA – medium (3-10)', 'β₁', 'Inotropy↑, CO↑, HR↑', ORANGE, '#fff8f0'), ('DA – high (>10)', 'α₁', 'Vasoconstriction, BP↑ (like NE)', RED, '#fff0f0'), ('Isoproterenol', 'β₁=β₂ (pure β)', 'HR↑↑, Bronchodilation, Vasodilation', TEAL, '#f0fff8'), ('Phenylephrine', 'α₁ only', 'Vasoconstriction, reflex bradycardia, Mydriasis', PURPLE, '#f8f0ff'), ] for i, row in enumerate(dose_rows): drg, rec, eff, col, rfc = row yy = 0.626 - i*0.026 BOX(ax, 0.08, yy-0.012, 0.84, 0.022, fc=rfc, ec='#dddddd', lw=0.4, r=0.003) T(ax, 0.20, yy, drg, sz=8.5, col=col, bold=True, ha='center') T(ax, 0.42, yy, rec, sz=8.2, col=PURPLE, ha='center') T(ax, 0.70, yy, eff, sz=8.2, col=INK, ha='center') # Memory trick ym = 0.396 BOX(ax, 0.08, ym-0.032, 0.84, 0.056, fc='#fffbe0', ec=ORANGE, lw=1.5, r=0.01) T(ax, 0.50, ym+0.016, '★ MEMORY TRICKS ★', sz=11, col=ORANGE, bold=True, ha='center') T(ax, 0.50, ym-0.000, 'EPI: "ALPHA at HIGH, BETA at LOW dose"', sz=9, col=RED, ha='center', ital=True) T(ax, 0.50, ym-0.016, 'DA: "1-3 Diuresis | 3-10 Beats | >10 Bad squeeze"', sz=9, col=PURPLE, ha='center', ital=True) T(ax, 0.50, ym-0.028, 'NE: "No Epsilon (no β₂) = No bronchodilation"', sz=9, col=MAROON, ha='center', ital=True) # Sympathomimetic uses summary T(ax, 0.09, 0.342, 'C. CLINICAL USES SUMMARY', sz=11.5, col=DKBLUE, bold=True) ax.plot([0.09,0.91],[0.332,0.332], color=DKBLUE, lw=1.3) use_rows = [ ('Anaphylaxis/Arrest', 'EPI (IM 0.5mg/SC)', RED), ('Septic shock', 'NE first-line vasopressor', MAROON), ('Acute HF/cardiogenic shock', 'Dobutamine (β₁ agonist)', ORANGE), ('Bronchial asthma (acute)', 'Salbutamol (β₂, inhaled)', TEAL), ('Bradycardia/AV block', 'Isoproterenol (non-sel β)', GREEN), ('Spinal/neuraxial hypotension', 'Ephedrine (mixed α+β)', PURPLE), ('Nasal decongestion', 'Oxymetazoline (α₁ topical)', BLUE), ('HTN / Opioid withdrawal', 'Clonidine (α₂ central)', MAROON), ] for i, (ind, drug, col) in enumerate(use_rows): yy = 0.318 - i*0.026 BOX(ax, 0.08, yy-0.012, 0.84, 0.022, fc='white', ec='#dddddd', lw=0.4, r=0.003) T(ax, 0.28, yy, ind, sz=8.8, col=INK, ha='center') T(ax, 0.72, yy, drug, sz=8.8, col=col, bold=True, ha='center') footer(ax, 2) fig.tight_layout(pad=0.3) fig.savefig('/tmp/workspace/ans-drugs/p2.png', dpi=150, bbox_inches='tight', facecolor=PAPER) plt.close(fig) print('P2 done') PYEOF
python3 << 'PYEOF' import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.patches import FancyBboxPatch import numpy as np import warnings warnings.filterwarnings('ignore') PAPER='#fffef0'; LINES='#d4c99a'; INK='#1a1a2e' BLUE='#1b4fc4'; RED='#c0392b'; GREEN='#1a7a3c' PURPLE='#6c3483'; ORANGE='#d35400'; TEAL='#148f77' MAROON='#7b241c'; DKBLUE='#0d2b6e' def ruled(ax, n=30): for i in np.linspace(0.03, 0.97, n): ax.axhline(i, color=LINES, lw=0.45, alpha=0.65, zorder=0) def setup(fig, ax): fig.patch.set_facecolor(PAPER); ax.set_facecolor(PAPER) ax.set_xlim(0,1); ax.set_ylim(0,1); ax.axis('off') ruled(ax) ax.axvline(0.07, color='#f8a0a0', lw=1.1, alpha=0.75, zorder=1) def T(ax, x, y, txt, sz=10, col=INK, bold=False, ital=False, ha='left', va='center'): ax.text(x, y, txt, fontsize=sz, color=col, fontweight='bold' if bold else 'normal', fontstyle='italic' if ital else 'normal', ha=ha, va=va, zorder=10, fontfamily='DejaVu Sans') def BOX(ax, x, y, w, h, fc='white', ec=INK, lw=1.2, r=0.015, al=1.0): ax.add_patch(FancyBboxPatch((x,y), w, h, boxstyle=f'round,pad={r}', linewidth=lw, edgecolor=ec, facecolor=fc, alpha=al, zorder=5)) def footer(ax, pg, total=6): T(ax, 0.50, 0.013, f'Page {pg} of {total} | ANS Drug Pharmacology – Handwritten Notes', sz=7.5, col='#888888', ha='center', ital=True) # PAGE 3 – SYMPATHOLYTICS fig,ax = plt.subplots(figsize=(8.5,11)) setup(fig,ax) BOX(ax, 0.04, 0.930, 0.92, 0.058, fc=MAROON, ec=MAROON, r=0.012) T(ax, 0.50, 0.962, 'SYMPATHOLYTICS (Adrenergic Antagonists)', sz=13.5, col='white', bold=True, ha='center') T(ax, 0.50, 0.940, 'α-Blockers • β-Blockers • Centrally Acting • NE-Depleting', sz=9.5, col='#ffddd0', ha='center') T(ax, 0.09, 0.906, '3. SYMPATHOLYTICS – Definition & Classification', sz=12, col=MAROON, bold=True) ax.plot([0.09,0.91],[0.895,0.895], color=MAROON, lw=1.3) T(ax, 0.10, 0.878, '• Drugs that BLOCK or REDUCE SNS (adrenergic) activity', sz=10, col=INK) T(ax, 0.10, 0.860, '• Mechanisms: Receptor blockade | Inhibit NE synthesis | Block NE release | Deplete NE stores', sz=9.5, col=INK) # α-BLOCKERS T(ax, 0.09, 0.840, 'A. α-ADRENERGIC BLOCKERS (α-blockers)', sz=11, col=RED, bold=True) ax.plot([0.09,0.91],[0.829,0.829], color=RED, lw=1.2) BOX(ax, 0.08, 0.794, 0.84, 0.030, fc='#ffe8e8', ec=RED, lw=1.2) T(ax, 0.12, 0.809, 'Effect: Vasodilation → BP↓; Reflex tachycardia; Nasal stuffiness; Postural hypotension', sz=9, col=MAROON) # α-blocker table BOX(ax, 0.08, 0.764, 0.84, 0.022, fc=RED, ec=RED, lw=0) for hh,xp in [('Drug', 0.20),('Selectivity', 0.40),('Uses', 0.70)]: T(ax, xp, 0.775, hh, sz=9, col='white', bold=True, ha='center') ab_rows = [ ('Prazosin', 'α₁ selective (post-synaptic)', 'HTN, BPH, Raynaud\'s', '#fff5f5'), ('Doxazosin', 'α₁ selective (long-acting)', 'HTN, BPH', '#ffe8e8'), ('Tamsulosin', 'α₁A selective (urinary)', 'BPH (prostate)', '#fff0f0'), ('Phentolamine', 'α₁+α₂ (non-selective)', 'Phaeochromocytoma, Hypertensive emergency', '#fff5f5'), ('Phenoxybenzamine', 'α₁+α₂ (irreversible)', 'Pre-op phaeochromocytoma', '#ffe8e8'), ('Yohimbine', 'α₂ selective', 'Research; Orthostatic hypotension', '#fff5f5'), ] for i, (drg, sel, use, rfc) in enumerate(ab_rows): yy = 0.750 - i*0.024 BOX(ax, 0.08, yy-0.011, 0.84, 0.021, fc=rfc, ec='#dddddd', lw=0.4, r=0.003) T(ax, 0.20, yy, drg, sz=8.5, col=RED, bold=True, ha='center') T(ax, 0.40, yy, sel, sz=8.2, col=PURPLE, ha='center') T(ax, 0.70, yy, use, sz=8.2, col=INK, ha='center') # β-BLOCKERS T(ax, 0.09, 0.598, 'B. β-ADRENERGIC BLOCKERS (β-blockers)', sz=11, col=ORANGE, bold=True) ax.plot([0.09,0.91],[0.588,0.588], color=ORANGE, lw=1.2) BOX(ax, 0.08, 0.558, 0.84, 0.024, fc='#fff8e0', ec=ORANGE, lw=1.2) T(ax, 0.12, 0.570, 'Effect: HR↓ (neg. chronotropy), BP↓, CO↓, Renin↓, AV conduction↓; Bronchoconstriction (non-sel.)', sz=9, col=MAROON) # Classification β-blockers gen1 = [('Propranolol','β₁=β₂ non-sel, no ISA','HTN,Angina,Arrhythmia,Tremor,Migraine',ORANGE), ('Sotalol','β₁=β₂ + K-ch block (Class III)','Arrhythmia (AF,VT)',ORANGE), ('Timolol','β₁=β₂ non-sel','HTN, Glaucoma (topical)',ORANGE)] gen2 = [('Atenolol','β₁ selective','HTN,Angina,MI,Arrhythmia',BLUE), ('Metoprolol','β₁ selective','HTN,HF,MI,Arrhythmia',BLUE), ('Bisoprolol','β₁ selective (most)','Heart failure (HFrEF)',BLUE), ('Esmolol','β₁ selective (IV, ultra-short)','SVT, Perioperative HTN',BLUE)] gen3 = [('Carvedilol','α₁+β₁+β₂ (no ISA)','HF,HTN (vasodilating β-blocker)',TEAL), ('Labetalol','α₁+β₁+β₂ (1:3 ratio)','Hypertensive emergency, HTN in pregnancy',TEAL), ('Nebivolol','β₁ sel + NO release','HTN,HF (vasodilating)',TEAL)] gen_labels = [ ('Generation 1 – Non-selective (β₁+β₂)', gen1, ORANGE, 0.540), ('Generation 2 – Cardioselective (β₁)', gen2, BLUE, 0.455), ('Generation 3 – Vasodilating (α+β)', gen3, TEAL, 0.360), ] BOX(ax, 0.08, 0.548, 0.84, 0.022, fc=MAROON, ec=MAROON, lw=0) for hh,xp in [('Drug', 0.18),('Selectivity/Notes', 0.42),('Main Uses', 0.72)]: T(ax, xp, 0.559, hh, sz=9, col='white', bold=True, ha='center') yy = 0.534 for glabel, glist, gcol, _ in gen_labels: # Sub-header BOX(ax, 0.08, yy-0.012, 0.84, 0.021, fc=gcol, ec=gcol, lw=0, r=0.003, al=0.15) T(ax, 0.50, yy, glabel, sz=8.5, col=gcol, bold=True, ha='center') yy -= 0.024 for drg, sel, use, col in glist: BOX(ax, 0.08, yy-0.012, 0.84, 0.021, fc='white', ec='#dddddd', lw=0.4, r=0.003) T(ax, 0.18, yy, drg, sz=8.5, col=col, bold=True, ha='center') T(ax, 0.42, yy, sel, sz=8, col=PURPLE, ha='center') T(ax, 0.72, yy, use, sz=8, col=INK, ha='center') yy -= 0.023 # Contraindications BOX(ax, 0.08, yy-0.050, 0.84, 0.055, fc='#fff0f0', ec=RED, lw=1.4, r=0.010) T(ax, 0.50, yy+0.000, '⚠ β-BLOCKER CONTRAINDICATIONS:', sz=10, col=RED, bold=True, ha='center') T(ax, 0.50, yy-0.015, 'Bronchial asthma (non-sel) | Acute decompensated HF | Bradycardia | AV block (2nd/3rd)', sz=9, col=MAROON, ha='center') T(ax, 0.50, yy-0.030, 'Peripheral vascular disease | Phaeochromocytoma (without α-blocker)', sz=9, col=MAROON, ha='center') T(ax, 0.50, yy-0.044, 'ABCD: Asthma | Bradycardia | COPD | Decompensated HF', sz=9, col=RED, ha='center', ital=True) footer(ax, 3) fig.tight_layout(pad=0.3) fig.savefig('/tmp/workspace/ans-drugs/p3.png', dpi=150, bbox_inches='tight', facecolor=PAPER) plt.close(fig) print('P3 done') PYEOF
python3 << 'PYEOF' import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.patches import FancyBboxPatch import numpy as np import warnings warnings.filterwarnings('ignore') PAPER='#fffef0'; LINES='#d4c99a'; INK='#1a1a2e' BLUE='#1b4fc4'; RED='#c0392b'; GREEN='#1a7a3c' PURPLE='#6c3483'; ORANGE='#d35400'; TEAL='#148f77' MAROON='#7b241c'; DKBLUE='#0d2b6e' def ruled(ax, n=30): for i in np.linspace(0.03, 0.97, n): ax.axhline(i, color=LINES, lw=0.45, alpha=0.65, zorder=0) def setup(fig, ax): fig.patch.set_facecolor(PAPER); ax.set_facecolor(PAPER) ax.set_xlim(0,1); ax.set_ylim(0,1); ax.axis('off') ruled(ax) ax.axvline(0.07, color='#f8a0a0', lw=1.1, alpha=0.75, zorder=1) def T(ax, x, y, txt, sz=10, col=INK, bold=False, ital=False, ha='left', va='center'): ax.text(x, y, txt, fontsize=sz, color=col, fontweight='bold' if bold else 'normal', fontstyle='italic' if ital else 'normal', ha=ha, va=va, zorder=10, fontfamily='DejaVu Sans') def BOX(ax, x, y, w, h, fc='white', ec=INK, lw=1.2, r=0.015, al=1.0): ax.add_patch(FancyBboxPatch((x,y), w, h, boxstyle=f'round,pad={r}', linewidth=lw, edgecolor=ec, facecolor=fc, alpha=al, zorder=5)) def footer(ax, pg, total=6): T(ax, 0.50, 0.013, f'Page {pg} of {total} | ANS Drug Pharmacology – Handwritten Notes', sz=7.5, col='#888888', ha='center', ital=True) # PAGE 4 – PARASYMPATHOMIMETICS fig,ax = plt.subplots(figsize=(8.5,11)) setup(fig,ax) BOX(ax, 0.04, 0.930, 0.92, 0.058, fc=BLUE, ec=BLUE, r=0.012) T(ax, 0.50, 0.962, 'PARASYMPATHOMIMETICS (Cholinergic Agonists)', sz=13.5, col='white', bold=True, ha='center') T(ax, 0.50, 0.940, 'Direct-Acting • Indirect-Acting (Anticholinesterases)', sz=9.5, col='#d0e8ff', ha='center') T(ax, 0.09, 0.906, '4. PARASYMPATHOMIMETICS – Classification', sz=12, col=BLUE, bold=True) ax.plot([0.09,0.91],[0.895,0.895], color=BLUE, lw=1.3) T(ax, 0.10, 0.878, 'Def: Drugs that mimic PNS (ACh) effects → "SLUDD" + Bradycardia + Miosis + ↑Secretions', sz=10, col=INK) # SLUDD box BOX(ax, 0.08, 0.845, 0.84, 0.025, fc='#e8f4ff', ec=BLUE, lw=1.3) T(ax, 0.50, 0.858, 'SLUDD = Salivation | Lacrimation | Urination | Defaecation | Digestion (GI↑)', sz=9.5, col=BLUE, bold=True, ha='center') # Classification BOX(ax, 0.08, 0.805, 0.84, 0.030, fc='#c8e6fb', ec=BLUE, lw=1.2) T(ax, 0.50, 0.820, 'CLASSIFICATION', sz=10.5, col=BLUE, bold=True, ha='center') # Two columns BOX(ax, 0.08, 0.730, 0.40, 0.068, fc='white', ec=BLUE, lw=1.3, r=0.008) T(ax, 0.28, 0.790, 'A. DIRECT-ACTING', sz=10, col=BLUE, bold=True, ha='center') T(ax, 0.28, 0.774, 'Act directly on muscarinic (M)', sz=8.5, col=INK, ha='center') T(ax, 0.28, 0.760, 'and/or nicotinic (N) receptors', sz=8.5, col=INK, ha='center') T(ax, 0.28, 0.746, 'Examples: Pilocarpine, Bethanechol,', sz=8.5, col=TEAL, ha='center') T(ax, 0.28, 0.732, 'Carbachol, Muscarine', sz=8.5, col=TEAL, ha='center') ax.plot([0.50, 0.28],[0.820, 0.798], color=BLUE, lw=1.0, alpha=0.7) BOX(ax, 0.52, 0.730, 0.40, 0.068, fc='white', ec=TEAL, lw=1.3, r=0.008) T(ax, 0.72, 0.790, 'B. INDIRECT-ACTING', sz=10, col=TEAL, bold=True, ha='center') T(ax, 0.72, 0.774, 'Inhibit AChE → ↑ACh at synapse', sz=8.5, col=INK, ha='center') T(ax, 0.72, 0.760, '(Anticholinesterases)', sz=8.5, col=INK, ha='center') T(ax, 0.72, 0.746, 'Reversible: Neostigmine, Physostigmine', sz=8.5, col=TEAL, ha='center') T(ax, 0.72, 0.732, 'Irreversible: Organophosphates', sz=8.5, col=RED, ha='center') ax.plot([0.50, 0.72],[0.820, 0.798], color=TEAL, lw=1.0, alpha=0.7) # A. Direct-acting table T(ax, 0.09, 0.712, 'A. DIRECT-ACTING PARASYMPATHOMIMETICS', sz=11, col=BLUE, bold=True) ax.plot([0.09,0.91],[0.701,0.701], color=BLUE, lw=1.2) BOX(ax, 0.08, 0.672, 0.84, 0.022, fc=BLUE, ec=BLUE, lw=0) for hh,xp in [('Drug', 0.18),('Receptor', 0.34),('Main Uses', 0.62),('Notes', 0.84)]: T(ax, xp, 0.683, hh, sz=9, col='white', bold=True, ha='center') da_rows = [ ('Acetylcholine (ACh)', 'M+N', 'Rarely used clinically', 'Endogenous NT', '#f0f5ff'), ('Pilocarpine', 'M (tertiary)', 'Glaucoma (topical), Xerostomia', 'Crosses BBB', '#e8f4ff'), ('Bethanechol', 'M selective', 'Urinary retention, Gastroparesis', 'Not hydrolysed by AChE', '#f0f5ff'), ('Carbachol', 'M+N', 'Glaucoma (topical)', 'Resistant to AChE', '#e8f4ff'), ('Cevimeline', 'M (M₁,M₃)', 'Sjogren\'s syndrome (dry mouth)', 'Selective muscarinic', '#f0f5ff'), ('Methacholine', 'M selective', 'Asthma diagnosis (provocation test)', 'Slowly hydrolysed', '#e8f4ff'), ] for i, (drg, rec, use, note, rfc) in enumerate(da_rows): yy = 0.658 - i*0.024 BOX(ax, 0.08, yy-0.011, 0.84, 0.021, fc=rfc, ec='#cccccc', lw=0.4, r=0.003) T(ax, 0.18, yy, drg, sz=8.5, col=BLUE, bold=True, ha='center') T(ax, 0.34, yy, rec, sz=8.2, col=PURPLE, ha='center') T(ax, 0.62, yy, use, sz=8.2, col=INK, ha='center') T(ax, 0.84, yy, note, sz=7.8, col=TEAL, ha='center', ital=True) # B. Anticholinesterases T(ax, 0.09, 0.506, 'B. INDIRECT-ACTING (ANTICHOLINESTERASES)', sz=11, col=TEAL, bold=True) ax.plot([0.09,0.91],[0.496,0.496], color=TEAL, lw=1.2) BOX(ax, 0.08, 0.464, 0.84, 0.026, fc=TEAL, ec=TEAL, lw=0) for hh,xp in [('Drug', 0.18),('Reversibility', 0.36),('Uses', 0.62),('Special', 0.84)]: T(ax, xp, 0.477, hh, sz=9, col='white', bold=True, ha='center') ac_rows = [ ('Neostigmine', 'Reversible (Q-amm.)', 'Reversal NMB, Myasthenia gravis,\nUrinary/GI atony', 'Doesn\'t cross BBB', '#f0fff8'), ('Pyridostigmine', 'Reversible (Q-amm.)', 'Myasthenia gravis (oral, long-acting)', 'DNAR for nerve gas', '#e8fff0'), ('Physostigmine', 'Reversible (tertiary)', 'Anticholinergic toxicity (central)', 'Crosses BBB!', '#f0fff8'), ('Edrophonium', 'Reversible (electro.)', 'Diagnosis Myasthenia (Tensilon test)', 'Very short-acting', '#e8fff0'), ('Rivastigmine', 'Pseudo-irreversible', 'Alzheimer\'s dementia, Parkinson\'s dementia', 'CNS selective', '#f0fff8'), ('Donepezil', 'Reversible', 'Alzheimer\'s dementia (all stages)', 'Long-acting, once daily', '#e8fff0'), ('Organophosphates', 'IRREVERSIBLE', 'Insecticides; nerve gases (TOXIC!)', 'Pralidoxime = antidote', '#fff0f0'), ('Echothiophate', 'Irreversible (OP)', 'Glaucoma (topical)', '↑Suxamethonium effect', '#fff0f0'), ] for i, (drg, rev, use, note, rfc) in enumerate(ac_rows): yy = 0.450 - i*0.026 col = RED if 'IRREVERSI' in rev else TEAL BOX(ax, 0.08, yy-0.012, 0.84, 0.023, fc=rfc, ec='#cccccc', lw=0.4, r=0.003) T(ax, 0.18, yy, drg, sz=8.5, col=col, bold=True, ha='center') T(ax, 0.36, yy, rev, sz=8, col=col, ha='center') T(ax, 0.62, yy, use, sz=7.8, col=INK, ha='center') T(ax, 0.84, yy, note, sz=7.5, col=PURPLE, ha='center', ital=True) # Memory BOX(ax, 0.08, 0.193, 0.84, 0.052, fc='#f0f8ff', ec=BLUE, lw=1.5, r=0.010) T(ax, 0.50, 0.237, '★ MEMORY TRICKS ★', sz=11, col=BLUE, bold=True, ha='center') T(ax, 0.50, 0.222, 'DUMBELS = Defaecation, Urination, Miosis, Bradycardia, Emesis, Lacrimation, Salivation', sz=9, col=TEAL, ha='center', ital=True) T(ax, 0.50, 0.208, '(Signs of cholinergic toxicity = same as overdose of parasympathomimetics)', sz=9, col=RED, ha='center', ital=True) T(ax, 0.50, 0.196, 'Neostigmine = "Needs assistance to cross BBB (it can\'t!)" | Physostigmine = "Physi-crosses"', sz=8.8, col=PURPLE, ha='center', ital=True) footer(ax, 4) fig.tight_layout(pad=0.3) fig.savefig('/tmp/workspace/ans-drugs/p4.png', dpi=150, bbox_inches='tight', facecolor=PAPER) plt.close(fig) print('P4 done') PYEOF
python3 << 'PYEOF' import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.patches import FancyBboxPatch import numpy as np import warnings warnings.filterwarnings('ignore') PAPER='#fffef0'; LINES='#d4c99a'; INK='#1a1a2e' BLUE='#1b4fc4'; RED='#c0392b'; GREEN='#1a7a3c' PURPLE='#6c3483'; ORANGE='#d35400'; TEAL='#148f77' MAROON='#7b241c'; DKBLUE='#0d2b6e' def ruled(ax, n=30): for i in np.linspace(0.03, 0.97, n): ax.axhline(i, color=LINES, lw=0.45, alpha=0.65, zorder=0) def setup(fig, ax): fig.patch.set_facecolor(PAPER); ax.set_facecolor(PAPER) ax.set_xlim(0,1); ax.set_ylim(0,1); ax.axis('off') ruled(ax) ax.axvline(0.07, color='#f8a0a0', lw=1.1, alpha=0.75, zorder=1) def T(ax, x, y, txt, sz=10, col=INK, bold=False, ital=False, ha='left', va='center'): ax.text(x, y, txt, fontsize=sz, color=col, fontweight='bold' if bold else 'normal', fontstyle='italic' if ital else 'normal', ha=ha, va=va, zorder=10, fontfamily='DejaVu Sans') def BOX(ax, x, y, w, h, fc='white', ec=INK, lw=1.2, r=0.015, al=1.0): ax.add_patch(FancyBboxPatch((x,y), w, h, boxstyle=f'round,pad={r}', linewidth=lw, edgecolor=ec, facecolor=fc, alpha=al, zorder=5)) def footer(ax, pg, total=6): T(ax, 0.50, 0.013, f'Page {pg} of {total} | ANS Drug Pharmacology – Handwritten Notes', sz=7.5, col='#888888', ha='center', ital=True) # PAGE 5 – PARASYMPATHOLYTICS fig,ax = plt.subplots(figsize=(8.5,11)) setup(fig,ax) BOX(ax, 0.04, 0.930, 0.92, 0.058, fc=PURPLE, ec=PURPLE, r=0.012) T(ax, 0.50, 0.962, 'PARASYMPATHOLYTICS (Cholinergic Antagonists)', sz=13.5, col='white', bold=True, ha='center') T(ax, 0.50, 0.940, 'Muscarinic Blockers (Antimuscarinics) • Nicotinic Blockers • Ganglionic Blockers', sz=9.5, col='#e8d5ff', ha='center') T(ax, 0.09, 0.906, '5. PARASYMPATHOLYTICS – Overview', sz=12, col=PURPLE, bold=True) ax.plot([0.09,0.91],[0.895,0.895], color=PURPLE, lw=1.3) T(ax, 0.10, 0.878, 'Def: Block muscarinic (M) or nicotinic (N) receptors → block PNS / cholinergic effects', sz=10, col=INK) # 3 subgroups for xb, lab, sub, col in [ (0.08, 'Muscarinic Antagonists', '(Antimuscarinics)', PURPLE), (0.38, 'NMJ Blockers', '(Neuromuscular junction)', ORANGE), (0.68, 'Ganglionic Blockers', '(Nicotinic gang. blockade)', TEAL), ]: BOX(ax, xb, 0.840, 0.27, 0.030, fc='white', ec=col, lw=1.3, r=0.008) T(ax, xb+0.135, 0.860, lab, sz=9, col=col, bold=True, ha='center') T(ax, xb+0.135, 0.847, sub, sz=8, col=INK, ha='center', ital=True) # A. MUSCARINIC ANTAGONISTS T(ax, 0.09, 0.822, 'A. MUSCARINIC ANTAGONISTS (Antimuscarinics / Anticholinergics)', sz=11, col=PURPLE, bold=True) ax.plot([0.09,0.91],[0.812,0.812], color=PURPLE, lw=1.2) BOX(ax, 0.08, 0.782, 0.84, 0.022, fc='#f8f0ff', ec=PURPLE, lw=1.2) T(ax, 0.12, 0.793, 'Effect: ANTI-SLUDD = ↓Secretions, Tachycardia, Bronchodilation, Mydriasis, Urinary retention, Constipation', sz=9, col=PURPLE) BOX(ax, 0.08, 0.754, 0.84, 0.022, fc=PURPLE, ec=PURPLE, lw=0) for hh,xp in [('Drug', 0.18),('Type', 0.34),('Main Uses', 0.62),('Special Notes', 0.84)]: T(ax, xp, 0.765, hh, sz=9, col='white', bold=True, ha='center') mant_rows = [ ('Atropine', 'Tertiary amine', 'Bradycardia, Pre-op drying,\nOrganophosphate poisoning', 'Crosses BBB+placenta', '#f8f0ff'), ('Scopolamine', 'Tertiary amine', 'Motion sickness, Pre-op sedation', 'CNS depression+amnesic', '#f0e8ff'), ('Glycopyrrolate', 'Quaternary amm.', 'Pre-op antisecretory, Reversal\n(with neostigmine)', 'No BBB, No placenta', '#f8f0ff'), ('Hyoscine butylbromide', 'Quaternary amm.', 'IBS, Smooth muscle spasm,\nRenal/biliary colic', 'No CNS effects', '#f0e8ff'), ('Ipratropium', 'Quaternary (inh.)', 'COPD (bronchodilation),\nAcute severe asthma', 'Inhaled only, No systemic', '#f8f0ff'), ('Tiotropium', 'Quaternary (inh.)', 'COPD maintenance therapy', 'Long-acting (LAMA)', '#f0e8ff'), ('Oxybutynin', 'Tertiary (M₁,M₃)', 'Overactive bladder,\nUrge incontinence', 'M₃ selective (bladder)', '#f8f0ff'), ('Solifenacin', 'Tertiary (M₃ sel.)', 'Overactive bladder (OAB)', 'Better tolerated', '#f0e8ff'), ('Tropicamide', 'Tertiary', 'Mydriasis (ophthalmology)', 'Short-acting', '#f8f0ff'), ('Benztropine', 'Tertiary', 'Parkinsonism, EPS (antipsychotics)', 'Crosses BBB', '#f0e8ff'), ] for i, (drg, typ, use, note, rfc) in enumerate(mant_rows): yy = 0.740 - i*0.024 BOX(ax, 0.08, yy-0.011, 0.84, 0.022, fc=rfc, ec='#cccccc', lw=0.4, r=0.003) T(ax, 0.18, yy, drg, sz=8.5, col=PURPLE, bold=True, ha='center') T(ax, 0.34, yy, typ, sz=8, col=MAROON, ha='center') T(ax, 0.62, yy, use, sz=7.8, col=INK, ha='center') T(ax, 0.84, yy, note, sz=7.5, col=TEAL, ha='center', ital=True) # Side effects T(ax, 0.09, 0.487, 'ADVERSE EFFECTS of Antimuscarinics:', sz=10.5, col=RED, bold=True) ae_cols = [ ('Dry mouth', 0.13, 0.468), ('Blurred vision', 0.13, 0.452), ('Urinary retention', 0.13, 0.436), ('Constipation', 0.13, 0.420), ('Tachycardia', 0.13, 0.404), ('Confusion/Delirium (BBB-crossing drugs)', 0.50, 0.468), ('Hyperthermia (↓sweating)', 0.50, 0.452), ('Photophobia (mydriasis)', 0.50, 0.436), ('Glaucoma precipitation', 0.50, 0.420), ('Hot dry skin', 0.50, 0.404), ] for txt, xp, yp in ae_cols: T(ax, xp, yp, f'• {txt}', sz=9, col=RED) BOX(ax, 0.08, 0.380, 0.84, 0.018, fc='#ffe0e0', ec=RED, lw=1.2, r=0.005) T(ax, 0.50, 0.389, '"Can\'t see, Can\'t pee, Can\'t poo, Can\'t drool, Feel hot, Feel fast, Feel mad" (Classic anticholinergic mnemonic)', sz=9, col=RED, bold=True, ha='center', ital=True) # B. Ganglionic blockers T(ax, 0.09, 0.358, 'B. GANGLIONIC BLOCKERS', sz=10.5, col=TEAL, bold=True) ax.plot([0.09,0.55],[0.348,0.348], color=TEAL, lw=1.2) gang_rows = [ ('Hexamethonium', 'Non-depolarising', 'Historical antihypertensive', '#e0fff8'), ('Trimethaphan', 'Non-depolarising', 'Hypertensive emergency (historical)', '#f0fff8'), ('Mecamylamine', 'Non-dep (oral)', 'Tourette\'s, Smoking cessation', '#e0fff8'), ] BOX(ax, 0.08, 0.320, 0.52, 0.022, fc=TEAL, ec=TEAL, lw=0) for hh,xp in [('Drug', 0.18),('Type', 0.30),('Use', 0.45)]: T(ax, xp, 0.331, hh, sz=9, col='white', bold=True, ha='center') for i, (drg, typ, use, rfc) in enumerate(gang_rows): yy = 0.308 - i*0.022 BOX(ax, 0.08, yy-0.010, 0.52, 0.020, fc=rfc, ec='#cccccc', lw=0.4, r=0.003) T(ax, 0.18, yy, drg, sz=8.5, col=TEAL, bold=True, ha='center') T(ax, 0.30, yy, typ, sz=8, col=PURPLE, ha='center') T(ax, 0.45, yy, use, sz=8, col=INK, ha='center') # Comparison: BBB crossing BOX(ax, 0.62, 0.270, 0.30, 0.100, fc='#fffbe0', ec=ORANGE, lw=1.4, r=0.010) T(ax, 0.77, 0.362, 'BBB Crossing:', sz=9.5, col=ORANGE, bold=True, ha='center') T(ax, 0.77, 0.347, 'TERTIARY = YES', sz=9, col=GREEN, ha='center', bold=True) T(ax, 0.77, 0.333, 'Atropine, Scopolamine', sz=8.5, col=INK, ha='center') T(ax, 0.77, 0.320, 'Physostigmine, Pilocarpine', sz=8.5, col=INK, ha='center') T(ax, 0.77, 0.305, 'QUATERNARY = NO', sz=9, col=RED, ha='center', bold=True) T(ax, 0.77, 0.291, 'Neostigmine, Glycopyrrolate', sz=8.5, col=INK, ha='center') T(ax, 0.77, 0.277, 'Ipratropium, Carbachol', sz=8.5, col=INK, ha='center') footer(ax, 5) fig.tight_layout(pad=0.3) fig.savefig('/tmp/workspace/ans-drugs/p5.png', dpi=150, bbox_inches='tight', facecolor=PAPER) plt.close(fig) print('P5 done') PYEOF
python3 << 'PYEOF' import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.patches import FancyBboxPatch import numpy as np import warnings warnings.filterwarnings('ignore') PAPER='#fffef0'; LINES='#d4c99a'; INK='#1a1a2e' BLUE='#1b4fc4'; RED='#c0392b'; GREEN='#1a7a3c' PURPLE='#6c3483'; ORANGE='#d35400'; TEAL='#148f77' MAROON='#7b241c'; DKBLUE='#0d2b6e' def ruled(ax, n=30): for i in np.linspace(0.03, 0.97, n): ax.axhline(i, color=LINES, lw=0.45, alpha=0.65, zorder=0) def setup(fig, ax): fig.patch.set_facecolor(PAPER); ax.set_facecolor(PAPER) ax.set_xlim(0,1); ax.set_ylim(0,1); ax.axis('off') ruled(ax) ax.axvline(0.07, color='#f8a0a0', lw=1.1, alpha=0.75, zorder=1) def T(ax, x, y, txt, sz=10, col=INK, bold=False, ital=False, ha='left', va='center'): ax.text(x, y, txt, fontsize=sz, color=col, fontweight='bold' if bold else 'normal', fontstyle='italic' if ital else 'normal', ha=ha, va=va, zorder=10, fontfamily='DejaVu Sans') def BOX(ax, x, y, w, h, fc='white', ec=INK, lw=1.2, r=0.015, al=1.0): ax.add_patch(FancyBboxPatch((x,y), w, h, boxstyle=f'round,pad={r}', linewidth=lw, edgecolor=ec, facecolor=fc, alpha=al, zorder=5)) def footer(ax, pg, total=6): T(ax, 0.50, 0.013, f'Page {pg} of {total} | ANS Drug Pharmacology – Handwritten Notes | Source: Goodman & Gilman, Lippincott, Barash', sz=7.2, col='#888888', ha='center', ital=True) # PAGE 6 – Master Comparison Table + Mnemonics + Exam Tips fig,ax = plt.subplots(figsize=(8.5,11)) setup(fig,ax) BOX(ax, 0.04, 0.930, 0.92, 0.058, fc=DKBLUE, ec=DKBLUE, r=0.012) T(ax, 0.50, 0.962, 'MASTER COMPARISON & QUICK REVISION', sz=13.5, col='white', bold=True, ha='center') T(ax, 0.50, 0.940, 'Side-by-side comparison + Drug Mechanisms + Antidotes + Mnemonics', sz=9.5, col='#d0d8ff', ha='center') T(ax, 0.09, 0.906, '6. MASTER COMPARISON TABLE', sz=12, col=DKBLUE, bold=True) ax.plot([0.09,0.91],[0.895,0.895], color=DKBLUE, lw=1.3) BOX(ax, 0.08, 0.862, 0.84, 0.026, fc=DKBLUE, ec=DKBLUE, lw=0) for hh,xp in [('Feature', 0.15),('Sympathomimetics', 0.33),('Sympatholytics', 0.51),('Parasympathomimetics', 0.70),('Parasympatholytics', 0.88)]: T(ax, xp, 0.875, hh, sz=8.5, col='white', bold=True, ha='center') master_rows = [ ('Also called', 'Adrenergic agonists', 'Adrenergic antagonists', 'Cholinergic agonists', 'Cholinergic antagonists'), ('Mimics/Blocks', 'Mimics SNS (NE/EPI)', 'Blocks SNS', 'Mimics PNS (ACh)', 'Blocks PNS'), ('Heart rate', 'HR ↑ (β₁)', 'HR ↓ (β-blockers)', 'HR ↓ (M₂)', 'HR ↑ (atropine)'), ('BP', 'BP ↑ (α₁)', 'BP ↓', 'BP ↓ (vasodilation)', 'BP ↑ (slight)'), ('Bronchi', 'Dilates (β₂)', 'Constricts (non-sel β)', 'Constricts (M₃)', 'Dilates (ipratropium)'), ('Pupils', 'Dilates (α₁)', '—', 'Constricts (M₃)', 'Dilates (mydriasis)'), ('Secretions', 'Decreases (α₁)', '—', 'Increases (M₃)', 'Decreases'), ('GI motility', 'Decreases (α₂)', '—', 'Increases (M₃)', 'Decreases'), ('Key examples', 'EPI, NE, DA,\nSalbutamol, Clonidine', 'Propranolol, Atenolol,\nPrazosin, Phentolamine', 'Pilocarpine, Bethanechol,\nNeostigmine', 'Atropine, Glycopyrrolate,\nIpratropium, Tiotropium'), ('Toxicity antidote', 'Physostigmine (CNS)', 'Glucagon (β-blocker OD)', 'Atropine', 'Physostigmine (CNS)'), ] rfc_pairs = ['#fafafa','#f5f5f5'] col_text = [RED, MAROON, BLUE, PURPLE] for i, row in enumerate(master_rows): feat = row[0]; vals = row[1:] yy = 0.848 - i*0.032 BOX(ax, 0.08, yy-0.015, 0.84, 0.030, fc=rfc_pairs[i%2], ec='#dddddd', lw=0.4, r=0.003) T(ax, 0.15, yy, feat, sz=8.5, col=INK, bold=True, ha='center') for j, val in enumerate(vals): T(ax, [0.33,0.51,0.70,0.88][j], yy, val, sz=7.8, col=col_text[j], ha='center') # Key drug mechanisms T(ax, 0.09, 0.512, '7. UNIQUE MECHANISMS TO REMEMBER', sz=11.5, col=ORANGE, bold=True) ax.plot([0.09,0.91],[0.502,0.502], color=ORANGE, lw=1.3) mech_rows = [ ('Clonidine', 'α₂ agonist (central) → ↓SNS outflow → BP↓', RED), ('Methyldopa', 'False transmitter → α-Methylnorepinephrine → α₂ agonist', MAROON), ('Reserpine', 'Depletes NE from vesicles (VMAT block) → sympatholytic', PURPLE), ('Guanethidine', 'Prevents NE release + depletes stores → sympatholytic', PURPLE), ('Cocaine/TCA', 'Reuptake-1 inhibition → ↑NE at synapse (sympathomimetic)', ORANGE), ('Amphetamine', 'Reverses Uptake-1 transporter → NE release (indirect)', ORANGE), ('MAOIs', 'Block MAO → ↑NE,5HT,DA (indirect sympathomimetic)', RED), ('Organophosphates', 'Irreversible AChE inhibition → ↑ACh → cholinergic crisis', RED), ('Pralidoxime', 'Reactivates AChE (before aging) → antidote for OP poisoning', GREEN), ('Botulinum toxin', 'Blocks ACh vesicle fusion (SNARE) → blocks release', BLUE), ] for i, (drg, mech, col) in enumerate(mech_rows): yy = 0.488 - i*0.028 BOX(ax, 0.08, yy-0.013, 0.84, 0.024, fc='white', ec='#dddddd', lw=0.4, r=0.003) T(ax, 0.185, yy, drg, sz=9, col=col, bold=True, ha='center') T(ax, 0.60, yy, mech, sz=8.5, col=INK, ha='center') # Final mnemonics BOX(ax, 0.08, 0.162, 0.84, 0.100, fc='#f9f9e0', ec=DKBLUE, lw=1.8, r=0.012) T(ax, 0.50, 0.254, '★ EXAM MNEMONICS & QUICK RECALL ★', sz=11.5, col=DKBLUE, bold=True, ha='center') mnems = [ ('SYMPATHOMIMETICS:', 'EPI for emergency • NE for shock (no β₂) • DA in doses • Salbutamol for bronchospasm', RED), ('SYMPATHOLYTICS:', 'Prazosin = α₁ blocker → BPH • Propranolol = β₁+β₂ → asthma CI • ABCD = β-blocker CI', MAROON), ('PARASYMPATHOMIMETICS:', 'Pilocarpine = Pupil (miosis) • Neostigmine = NMJ reversal • Physostigmine = crosses BBB', BLUE), ('PARASYMPATHOLYTICS:', 'Atropine = blocks ALL M • Ipratropium = COPD only (inhaled) • Tiotropium = LAMA (COPD)', PURPLE), ] for i, (title, body, col) in enumerate(mnems): yy = 0.238 - i*0.021 T(ax, 0.12, yy, title, sz=9, col=col, bold=True) T(ax, 0.38, yy, body, sz=8.5, col=INK) footer(ax, 6) fig.tight_layout(pad=0.3) fig.savefig('/tmp/workspace/ans-drugs/p6.png', dpi=150, bbox_inches='tight', facecolor=PAPER) plt.close(fig) print('P6 done') PYEOF
python3 << 'PYEOF' from PIL import Image from reportlab.lib.pagesizes import letter from reportlab.pdfgen import canvas import os out_pdf = '/tmp/workspace/ans-drugs/ANS_Drugs_Pharmacology_Notes.pdf' pages = [f'/tmp/workspace/ans-drugs/p{i}.png' for i in range(1,7)] c = canvas.Canvas(out_pdf, pagesize=letter) W, H = letter for pg in pages: img = Image.open(pg) img_w, img_h = img.size scale = min(W/img_w, H/img_h) new_w = img_w * scale new_h = img_h * scale x = (W - new_w) / 2 y = (H - new_h) / 2 c.drawImage(pg, x, y, width=new_w, height=new_h) c.showPage() c.save() size = os.path.getsize(out_pdf) print(f'PDF created: {out_pdf} ({size/1024:.0f} KB)') PYEOF
ANS Drugs Pharmacology Notes
PDF Document · PDF