Teach me this (MPT level)

Reading File
Running Command

cd /home/daytona/workspace/attachments/8f2f4c83-256c-4438-be7a-e5b8d147b6c8/ && python3 -c " import pdfplumber with pdfplumber.open('Pain_and_Its_Modulation_PG_20_Marks_Detailed_Answer.pdf') as pdf: print(f'Total pages: {len(pdf.pages)}') for i, page in enumerate(pdf.pages): text = page.extract_text() print(f'--- PAGE {i+1} ---') print(text) print() "

Reading File
Searching PubMed

"pain modulation" AND "gate control" AND "descending inhibition"

Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Loading Image
Reading File
I now have everything I need to deliver a thorough MPT-level teaching session. Let me compose the full response.

Pain and Its Modulation - MPT Level Master Guide

This is a complete teaching breakdown of your 20-mark answer, structured for deep understanding rather than just memorization. I'll explain the why behind every concept so you can answer any examiner's angle.

1. What IS Pain? (Start Here - Don't Skip)

Pain is defined by the IASP as "an unpleasant sensory and emotional experience associated with actual or potential tissue damage."
Three words matter here:
  • Sensory - it has a physical component (where, how intense, what quality)
  • Emotional - it has a feeling/affect component (fear, distress, urge to escape)
  • Experience - it is processed and interpreted, not just received passively
This is why the same injury hurts differently depending on your mood, attention, past experience, and cultural context. Pain is NOT simply "nerve impulse reaches brain = pain." That reductionist view is wrong and examiners want you to know that.

2. The Three Dimensions of Pain (Must Know for Theory Marks)

DimensionWhat It MeansBrain Region Involved
Sensory-discriminativeWhere is it? How intense? How long? What quality?Somatosensory cortex (S1, S2)
Motivational-affectiveHow unpleasant? Fear, distress, urge to withdrawLimbic system - ACC (anterior cingulate cortex), amygdala
Cognitive-evaluativeWhat does this pain MEAN to me? (culture, past experience, attention)Prefrontal cortex
Exam tip: When an examiner asks "why does the same injury hurt differently in different people?" - you answer using the motivational-affective and cognitive-evaluative dimensions.

3. Pain Fibers - The Hardware

This is a table you must know cold:
FiberMyelinationSpeedPain QualityOpens/Closes Gate?
A-deltaSmall myelinatedFast (5-30 m/s)Sharp, pricking, well-localized - "first pain"Opens gate
C fibersUnmyelinatedSlow (0.5-2 m/s)Dull, burning, aching, throbbing - "second pain"Opens gate
A-betaLarge myelinatedVery fast (30-70 m/s)Touch and pressure - NOT painCloses gate
Why does this matter clinically?
  • When you rub an injured knee, you activate A-beta fibers - this closes the gate and reduces pain. That is the entire physiological basis of rubbing, massage, and TENS.
  • A-delta gives you fast withdrawal reflex. C fibers give you the lingering ache afterward.

4. The Pain Transmission Pathway (Draw This as a Flow)

Noxious stimulus (mechanical/thermal/chemical)
         ↓
    Nociceptor (skin, muscle, viscera, periosteum, joint)
         ↓
   Action potential generated
         ↓
Primary afferent fiber (A-delta or C)
         ↓
  Dorsal Root Ganglion (cell body of 1st-order neuron)
         ↓
     Dorsal Horn of Spinal Cord
   (synapse with 2nd-order neuron in lamina I, II, V)
         ↓
  Decussation (crosses to opposite side)
         ↓
Spinothalamic Tract (anterolateral system)
         ↓
        Thalamus
         ↓
   Somatosensory Cortex (localization + perception)
   + Limbic system (emotional coloring)
Two types of 2nd-order neurons in the dorsal horn:
  1. Nociceptive-Specific (NS) neurons - respond ONLY to painful input. Found in lamina I.
  2. Wide Dynamic Range (WDR) neurons - respond to BOTH painful AND non-painful input. Found in lamina V. These are KEY to sensitization and gate control.

5. Peripheral Sensitization and Hyperalgesia

When tissue is injured, the inflammatory soup is released:
Bradykinin, prostaglandins, histamine, serotonin, K⁺, H⁺, Substance P
These chemicals do two things:
  1. Directly activate nociceptors - depolarize them even with mild stimuli
  2. Lower the activation threshold of nociceptors (sensitization)
Result: The area becomes hyperalgesic (more painful than normal to a noxious stimulus) and allodynic (painful even to normally non-painful touch).
This explains why a sunburned shoulder hurts when clothing merely touches it - the nociceptors are primed and firing at a much lower threshold.
Peripheral sensitization = change at the RECEPTOR level. Central sensitization = change at the SPINAL CORD/BRAIN level. (distinguish these in your exam)

6. Clinical Types of Pain (Quick Contrast Table)

FeatureAcute PainChronic Pain
PurposeProtective warning signalOften loses protective role
DurationShort, resolves with healing> 3-6 months, persists
BehaviorRestless, anxious, guardingWithdrawn, depressed
AutonomicTachycardia, hypertension, dilated pupilsOften absent
Neural basisActive nociceptionNeural dysfunction, sensitization
Other types to know:
  • Neuropathic pain - damage to nervous tissue itself (e.g., diabetic neuropathy, phantom limb)
  • Referred pain - felt distant from the source (visceral and somatic afferents converge on same dorsal horn neuron; brain misinterprets origin)
  • Phantom pain - pain in an absent limb; reflects reorganization of cortical maps and altered peripheral/central processing
Classic referred pain example: Myocardial ischemia → pain in left arm, jaw, upper chest. Cardiac afferents converge with somatic afferents at dorsal horn levels C8-T4.

7. Gate Control Theory (Melzack & Wall, 1965) - The Central Theory

This is the MOST IMPORTANT theoretical concept in the paper. Get this airtight.
The Gate:
  • Located in the substantia gelatinosa (lamina II) of the spinal dorsal horn
  • The "gate" controls how much nociceptive signal passes up to the brain
The Mechanism:
Small fibers (A-delta + C)
→ Inhibit inhibitory interneuron in substantia gelatinosa
→ Gate OPENS → Pain impulses ascend freely

Large fibers (A-beta - touch/pressure)
→ Activate inhibitory interneuron in substantia gelatinosa
→ Gate CLOSES → Nociceptive transmission suppressed
Also: Descending signals from the brain (via cortex and brainstem) can also close the gate - this is the top-down control.
Clinical applications of gate control:
InterventionMechanism
Rubbing/massageActivates A-beta → closes gate
VibrationActivates A-beta → closes gate
High-frequency low-intensity TENSActivates A-beta → segmental gate closure
Heat/cold therapyMix of peripheral + segmental effects
Brief intense TENSPeripheral nerve block + segmental
Morgan & Mikhail (Clinical Anesthesiology): "Activation of large afferent fibers subserving sensation inhibits WDR neuron and spinothalamic tract activity... these two phenomena support a 'gate' theory for pain processing in the spinal cord."

8. Descending Inhibitory Pathways - Top-Down Pain Control

This is the mechanism behind acupuncture, placebo, low-frequency TENS, and why attitude affects pain.
The Descending Inhibitory System:
Descending endorphin-mediated inhibitory pain system
(Sleisenger & Fordtran's Gastrointestinal and Liver Disease)
Key relay stations (learn this sequence):
Cortex + Limbic System (ACC, prefrontal cortex, amygdala)
         ↓
Periaqueductal Gray (PAG) - midbrain
         ↓
Nucleus Raphe Magnus (NRM) / Rostral Ventromedial Medulla
+ Locus Coeruleus (dorsolateral pons)
         ↓
Dorsal Horn of Spinal Cord (inhibits 2nd-order neurons + interneurons)
Three neurotransmitter pathways in descending inhibition:
PathwayNeurotransmitterReceptorOrigin
SerotonergicSerotonin (5-HT)5-HT receptorsNRM → dorsal horn via dorsolateral funiculus
NoradrenergicNorepinephrineα2-adrenergicLocus coeruleus → dorsal horn
Opioidergicβ-endorphin, enkephalins, dynorphinsμ, δ, κ opioid receptorsPAG, NRM, dorsal horn
Mechanism at dorsal horn: Endogenous opioids act:
  1. Presynaptically - hyperpolarize the primary afferent, reducing Substance P and glutamate release
  2. Postsynaptically - inhibit 2nd-order neuron firing
Morgan & Mikhail: "The endogenous opiate system acts via methionine enkephalin, leucine enkephalin, and β-endorphin, all antagonized by naloxone. These opioids act presynaptically to hyperpolarize primary afferent neurons and inhibit the release of substance P."
This explains:
  • Why exercise reduces pain (beta-endorphin release)
  • Why naloxone can partially reverse placebo analgesia
  • Why tricyclic antidepressants reduce chronic pain (block reuptake of serotonin and norepinephrine - enhancing descending inhibition)
  • Why low-frequency high-intensity TENS (acupuncture-like) works via opioid release

9. Cortical Modulation (The Psychological Level)

The brain is not just a passive receiver - it actively amplifies or suppresses pain.
Amplifiers of pain:
  • Fear, anxiety, catastrophizing
  • Attention and hypervigilance
  • Depression
  • Negative past experience
Suppressors of pain:
  • Reassurance and education
  • Relaxation and mindfulness
  • Positive coping strategies
  • Distraction
  • Placebo (real, measurable opioid-mediated effect)
PET imaging evidence: Subjects hypnotized to feel the same hot stimulus as "not painful" showed no difference in somatosensory cortex activation but significantly less activation in the anterior cingulate cortex (ACC) - the limbic area processing the emotional quality of pain. (Sleisenger & Fordtran)
This is why cognitive-behavioral therapy, graded exposure, and patient education are first-line in chronic pain - they have a measurable physiological effect on descending inhibitory pathways.

10. Pain Modulation at All Levels - The MPT Framework

LevelTargetMechanismsClinical Examples
PeripheralReduce nociceptor activation and chemical mediatorsBlock inflammatory mediators, reduce tissue irritationNSAIDs, ice, compression, ultrasound, PEME, massage
Spinal segmentalClose the gate via A-beta activation or physiological blockGate control (large fiber activation), high-frequency nerve blockHigh-freq low-intensity TENS, vibration, interferential current, brief intense TENS, manual therapy
SupraspinalActivate descending inhibitory pathwaysPAG → NRM → dorsal horn opioid/serotonin/NE releaseAcupuncture, low-freq high-intensity TENS, UV radiation, counter-irritation, placebo
CorticalModify pain perception, meaning, copingCognitive restructuring, attention modulation, fear reductionCBT, graded exposure, education, relaxation, psychotherapy

11. High-Yield Exam Points - Quick Fire

  • First pain = A-delta (sharp, localized, fast) / Second pain = C fibers (dull, slow, burning)
  • Gate is in substantia gelatinosa (lamina II) of dorsal horn
  • PAG + NRM = the descending pain suppressive system
  • Three descending transmitters: serotonin, norepinephrine, opioids
  • Endogenous opioids: beta-endorphin (pituitary/hypothalamus), enkephalins (dorsal horn), dynorphins
  • Referred pain mechanism: Viscero-somatic convergence at dorsal horn → brain misinterprets
  • Phantom pain = neuropathic (altered central mapping, not simple peripheral mechanism)
  • Central sensitization: WDR neuron wind-up, NMDA receptor activation → chronic pain
  • Allodynia = pain to normally non-painful stimulus / Hyperalgesia = exaggerated pain to painful stimulus
  • GABA and glycine are the inhibitory interneuron transmitters mediating gate closure in spinal cord
  • Exercise-induced analgesia = beta-endorphin release from hypothalamus

12. How to Structure Your 20-Mark Answer

A 20-mark answer needs 4+ pages with this structure:
  1. Introduction - IASP definition + multidimensional concept (5-7 lines)
  2. Dimensions - sensory-discriminative, motivational-affective, cognitive-evaluative (table)
  3. Pain fibers - table of A-delta, C, A-beta with clinical relevance
  4. Transmission pathway - draw the flow diagram (marks for diagrams!)
  5. Peripheral sensitization - mediators + mechanism
  6. Clinical types - acute vs chronic table + referred + phantom
  7. Gate control theory - diagram + mechanism (this section alone = 4-5 marks)
  8. Descending inhibitory pathways - PAG → NRM diagram + 3 neurotransmitters
  9. Cortical modulation - psychological influence with evidence
  10. Physiotherapy applications - table by level
  11. Conclusion - 3-4 lines tying it together
Diagrams of the gate control mechanism and the descending inhibitory pathway will earn you extra marks and make your answer look authoritative. Practice drawing them.

Sources used:
  • Your uploaded lecture notes (Pain and its Modulation, MPT-level 20-mark answer)
  • Morgan & Mikhail's Clinical Anesthesiology, 7e - Inhibition of pain, p. 1992
  • Sleisenger & Fordtran's Gastrointestinal and Liver Disease - Descending Modulation of Pain, p. 3162
  • Eric Kandel, Principles of Neural Science, 6e - Endorphin-mediated pain control

Create 20 marks answer summery highlighting all points including diagrams & flow chart

Reading File
Running Command

ls /home/daytona/workspace/

Running Command

mkdir -p /home/daytona/workspace/pain-modulation && ls /home/daytona/skills/docx/

Writing File

~/pain-modulation/create_pain_doc.js

const {
  Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
  HeadingLevel, AlignmentType, BorderStyle, WidthType, ShadingType,
  VerticalAlign, PageBreak, TableLayoutType
} = require('docx');
const fs = require('fs');

// ── Color palette ────────────────────────────────────────────────────────────
const C = {
  navy:    '1B3A6B',
  blue:    '2563EB',
  teal:    '0D9488',
  green:   '16A34A',
  red:     'DC2626',
  amber:   'D97706',
  purple:  '7C3AED',
  orange:  'EA580C',
  gray:    '374151',
  lgray:   'F3F4F6',
  mgray:   'E5E7EB',
  dgray:   '6B7280',
  white:   'FFFFFF',
  yellow:  'FEF3C7',
  lblue:   'EFF6FF',
  lgreen:  'F0FDF4',
  lred:    'FEF2F2',
  lpurple: 'F5F3FF',
  lteal:   'F0FDFA',
};

// ── Helpers ───────────────────────────────────────────────────────────────────
function sp(n=200) { return { before: n, after: n }; }
function heading1(text) {
  return new Paragraph({
    children: [new TextRun({ text, bold: true, size: 28, color: C.navy, font: 'Calibri' })],
    heading: HeadingLevel.HEADING_1,
    spacing: { before: 320, after: 120 },
    border: { bottom: { style: BorderStyle.THICK, size: 6, color: C.blue, space: 4 } }
  });
}
function heading2(text, color=C.teal) {
  return new Paragraph({
    children: [new TextRun({ text, bold: true, size: 24, color, font: 'Calibri' })],
    heading: HeadingLevel.HEADING_2,
    spacing: { before: 260, after: 80 }
  });
}
function heading3(text, color=C.gray) {
  return new Paragraph({
    children: [new TextRun({ text, bold: true, size: 22, color, font: 'Calibri' })],
    spacing: { before: 200, after: 60 }
  });
}
function para(text, opts={}) {
  return new Paragraph({
    children: [new TextRun({ text, size: 20, font: 'Calibri', color: C.gray, ...opts })],
    spacing: { before: 80, after: 80 }
  });
}
function bullet(text, opts={}) {
  return new Paragraph({
    children: [new TextRun({ text: '• ' + text, size: 20, font: 'Calibri', color: C.gray, ...opts })],
    spacing: { before: 60, after: 60 },
    indent: { left: 360 }
  });
}
function subbullet(text, color=C.gray) {
  return new Paragraph({
    children: [new TextRun({ text: '  ◦ ' + text, size: 19, font: 'Calibri', color })],
    spacing: { before: 40, after: 40 },
    indent: { left: 720 }
  });
}
function note(text) {
  return new Paragraph({
    children: [new TextRun({ text: '📌 ' + text, size: 19, italics: true, font: 'Calibri', color: C.amber })],
    spacing: { before: 80, after: 80 },
    indent: { left: 360 }
  });
}
function pageBreak() {
  return new Paragraph({ children: [new TextRun({ break: 1 })] });
}
function divider() {
  return new Paragraph({
    border: { bottom: { style: BorderStyle.SINGLE, size: 2, color: C.mgray, space: 4 } },
    spacing: { before: 100, after: 100 }
  });
}

// ── Cell builder ──────────────────────────────────────────────────────────────
function cell(text, { bg=C.white, bold=false, color=C.gray, size=19, align=AlignmentType.LEFT, width=null }={}) {
  const opts = { bold, size, font: 'Calibri', color };
  const cellOpts = {
    children: [new Paragraph({
      children: [new TextRun({ text, ...opts })],
      alignment: align,
      spacing: { before: 60, after: 60 }
    })],
    shading: { type: ShadingType.CLEAR, color: 'auto', fill: bg },
    margins: { top: 80, bottom: 80, left: 120, right: 120 },
    verticalAlign: VerticalAlign.CENTER
  };
  if (width) cellOpts.width = { size: width, type: WidthType.PERCENTAGE };
  return new TableCell(cellOpts);
}
function headerRow(cols, bg=C.navy) {
  return new TableRow({
    children: cols.map(c => cell(c, { bg, bold: true, color: C.white, size: 20, align: AlignmentType.CENTER })),
    tableHeader: true
  });
}
function dataRow(cols, bgs=[]) {
  return new TableRow({
    children: cols.map((c, i) => cell(c, { bg: bgs[i] || C.white }))
  });
}
function altRow(cols, idx) {
  const bg = idx % 2 === 0 ? C.white : C.lgray;
  return new TableRow({ children: cols.map(c => cell(c, { bg })) });
}

// ── Flowchart box (simulated with table) ─────────────────────────────────────
function flowBox(text, bg=C.lblue, color=C.navy, bold=true) {
  return new Table({
    width: { size: 60, type: WidthType.PERCENTAGE },
    alignment: AlignmentType.CENTER,
    rows: [new TableRow({
      children: [new TableCell({
        children: [new Paragraph({
          children: [new TextRun({ text, bold, size: 20, font: 'Calibri', color })],
          alignment: AlignmentType.CENTER,
          spacing: { before: 80, after: 80 }
        })],
        shading: { type: ShadingType.CLEAR, color: 'auto', fill: bg },
        margins: { top: 100, bottom: 100, left: 160, right: 160 },
        borders: {
          top:    { style: BorderStyle.SINGLE, size: 8, color: color },
          bottom: { style: BorderStyle.SINGLE, size: 8, color: color },
          left:   { style: BorderStyle.SINGLE, size: 8, color: color },
          right:  { style: BorderStyle.SINGLE, size: 8, color: color },
        }
      })]
    })]
  });
}
function arrow() {
  return new Paragraph({
    children: [new TextRun({ text: '▼', size: 22, color: C.blue, font: 'Calibri' })],
    alignment: AlignmentType.CENTER,
    spacing: { before: 40, after: 40 }
  });
}

// ── COVER PAGE ────────────────────────────────────────────────────────────────
const cover = [
  new Paragraph({ spacing: { before: 800 } }),
  new Paragraph({
    children: [new TextRun({ text: 'PAIN AND ITS MODULATION', bold: true, size: 52, color: C.navy, font: 'Calibri' })],
    alignment: AlignmentType.CENTER,
    spacing: { before: 200, after: 80 }
  }),
  new Paragraph({
    children: [new TextRun({ text: 'MPT Level • 20-Mark University Exam Answer Summary', size: 26, color: C.teal, font: 'Calibri', italics: true })],
    alignment: AlignmentType.CENTER,
    spacing: { before: 40, after: 40 }
  }),
  new Paragraph({
    children: [new TextRun({ text: '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━', size: 24, color: C.blue, font: 'Calibri' })],
    alignment: AlignmentType.CENTER,
    spacing: { before: 40, after: 40 }
  }),
  new Paragraph({
    children: [new TextRun({ text: 'Complete with Diagrams • Flowcharts • Tables • Key Points', size: 22, color: C.dgray, font: 'Calibri' })],
    alignment: AlignmentType.CENTER,
    spacing: { before: 40, after: 400 }
  }),
  // Summary box
  new Table({
    width: { size: 80, type: WidthType.PERCENTAGE },
    alignment: AlignmentType.CENTER,
    rows: [
      new TableRow({ children: [new TableCell({
        children: [
          new Paragraph({ children: [new TextRun({ text: 'TOPICS COVERED', bold: true, size: 22, color: C.navy, font: 'Calibri' })], alignment: AlignmentType.CENTER, spacing: { before: 80, after: 80 } }),
          new Paragraph({ children: [new TextRun({ text: '1. Definition & Dimensions   2. Pain Fibers   3. Transmission Pathway', size: 19, font: 'Calibri', color: C.gray })], alignment: AlignmentType.CENTER }),
          new Paragraph({ children: [new TextRun({ text: '4. Peripheral Sensitization   5. Clinical Types   6. Referred & Phantom Pain', size: 19, font: 'Calibri', color: C.gray })], alignment: AlignmentType.CENTER }),
          new Paragraph({ children: [new TextRun({ text: '7. Gate Control Theory   8. Descending Inhibition   9. Cortical Modulation', size: 19, font: 'Calibri', color: C.gray })], alignment: AlignmentType.CENTER }),
          new Paragraph({ children: [new TextRun({ text: '10. Physiotherapy Applications   11. Key Points & Exam Tips', size: 19, font: 'Calibri', color: C.gray })], alignment: AlignmentType.CENTER, spacing: { after: 80 } }),
        ],
        shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.lblue },
        margins: { top: 120, bottom: 120, left: 200, right: 200 },
        borders: {
          top:    { style: BorderStyle.THICK, size: 12, color: C.blue },
          bottom: { style: BorderStyle.THICK, size: 12, color: C.blue },
          left:   { style: BorderStyle.THICK, size: 12, color: C.blue },
          right:  { style: BorderStyle.THICK, size: 12, color: C.blue },
        }
      })] })
    ]
  }),
  pageBreak()
];

// ── SECTION 1: Definition ─────────────────────────────────────────────────────
const sec1 = [
  heading1('1. Introduction – Definition of Pain'),
  para('Pain is defined by the IASP as:'),
  new Table({
    width: { size: 90, type: WidthType.PERCENTAGE },
    alignment: AlignmentType.CENTER,
    rows: [new TableRow({ children: [new TableCell({
      children: [new Paragraph({
        children: [new TextRun({ text: '"An unpleasant sensory and emotional experience associated with actual or potential tissue damage."', italics: true, bold: true, size: 22, color: C.navy, font: 'Calibri' })],
        alignment: AlignmentType.CENTER,
        spacing: { before: 100, after: 100 }
      })],
      shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.lblue },
      margins: { top: 120, bottom: 120, left: 200, right: 200 },
      borders: { top: { style: BorderStyle.THICK, size: 10, color: C.blue }, bottom: { style: BorderStyle.THICK, size: 10, color: C.blue }, left: { style: BorderStyle.THICK, size: 10, color: C.blue }, right: { style: BorderStyle.THICK, size: 10, color: C.blue } }
    })] })]
  }),
  new Paragraph({ spacing: { before: 80 } }),
  bullet('Pain is NOT simply a nerve impulse – it is a multidimensional experience'),
  bullet('Shaped by: sensory input, emotional state, attention, past experience, cultural context'),
  bullet('Functions as a warning signal – promotes withdrawal, guarding, and rest'),
  divider(),
];

// ── SECTION 2: Dimensions ─────────────────────────────────────────────────────
const sec2 = [
  heading1('2. Three Dimensions of Pain'),
  new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [
      headerRow(['Dimension', 'What It Describes', 'Brain Region']),
      altRow(['Sensory-Discriminative', 'Location, intensity, duration, quality ("Where? How much?)', 'Somatosensory cortex (S1, S2)'], 0),
      altRow(['Motivational-Affective', 'Unpleasantness, fear, distress, urge to escape', 'Limbic system – ACC, Amygdala'], 1),
      altRow(['Cognitive-Evaluative', 'Meaning based on past experience, culture, attention', 'Prefrontal cortex'], 0),
    ]
  }),
  new Paragraph({ spacing: { before: 120 } }),
  note('Exam tip: "Why does the same injury hurt differently?" → Motivational-affective + Cognitive-evaluative dimensions'),
  divider(),
];

// ── SECTION 3: Pain Fibers ────────────────────────────────────────────────────
const sec3 = [
  heading1('3. Pain Fibers – The Peripheral Hardware'),
  new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [
      headerRow(['Fiber', 'Myelination', 'Speed', 'Pain Quality', 'Gate Effect']),
      new TableRow({ children: [
        cell('A-delta', { bg: C.lred, bold: true, color: C.red }),
        cell('Small myelinated', { bg: C.lred }),
        cell('5–30 m/s (fast)', { bg: C.lred }),
        cell('Sharp, pricking, well-localized\n"First Pain"', { bg: C.lred }),
        cell('OPENS gate', { bg: C.lred, bold: true, color: C.red }),
      ]}),
      new TableRow({ children: [
        cell('C fibers', { bg: C.lpurple, bold: true, color: C.purple }),
        cell('Unmyelinated', { bg: C.lpurple }),
        cell('0.5–2 m/s (slow)', { bg: C.lpurple }),
        cell('Dull, burning, aching, throbbing\n"Second Pain"', { bg: C.lpurple }),
        cell('OPENS gate', { bg: C.lpurple, bold: true, color: C.purple }),
      ]}),
      new TableRow({ children: [
        cell('A-beta', { bg: C.lgreen, bold: true, color: C.green }),
        cell('Large myelinated', { bg: C.lgreen }),
        cell('30–70 m/s (very fast)', { bg: C.lgreen }),
        cell('Touch, pressure – NOT pain', { bg: C.lgreen }),
        cell('CLOSES gate ✓', { bg: C.lgreen, bold: true, color: C.green }),
      ]}),
    ]
  }),
  new Paragraph({ spacing: { before: 100 } }),
  note('Clinical: Rubbing injured area activates A-beta → closes gate → reduces pain. Basis of TENS & massage!'),
  divider(),
];

// ── SECTION 4: Transmission Pathway Flowchart ─────────────────────────────────
const sec4 = [
  heading1('4. Pain Transmission Pathway'),
  heading2('FLOWCHART: Nociception to Perception', C.blue),
  new Paragraph({ spacing: { before: 80 } }),

  flowBox('NOXIOUS STIMULUS\n(Mechanical / Thermal / Chemical)', C.lred, C.red),
  arrow(),
  flowBox('NOCICEPTOR ACTIVATION\n(Skin, muscle, tendon, periosteum, viscera, joint)', C.lred, C.red),
  arrow(),
  flowBox('ACTION POTENTIAL GENERATED\n↓\nPrimary Afferent Fiber: A-delta (fast, sharp) or C fiber (slow, dull)', C.lpurple, C.purple),
  arrow(),
  flowBox('DORSAL ROOT GANGLION\n(Cell body of 1st-order neuron)', C.lteal, C.teal),
  arrow(),
  flowBox('DORSAL HORN – SPINAL CORD\nSynapse with 2nd-order neuron (Lamina I, II, V)\nGate Control operates here', C.lblue, C.blue),
  arrow(),
  flowBox('DECUSSATION\n(Crosses to opposite side of spinal cord)', C.yellow, C.amber),
  arrow(),
  flowBox('SPINOTHALAMIC TRACT (Anterolateral System)\nAscends to brain', C.yellow, C.amber),
  arrow(),
  flowBox('THALAMUS\n(Relay station)', C.lpurple, C.purple),
  arrow(),
  flowBox('SOMATOSENSORY CORTEX → Localization & Perception\n+ LIMBIC SYSTEM → Emotional coloring\n+ PREFRONTAL CORTEX → Interpretation', C.lgreen, C.green),

  new Paragraph({ spacing: { before: 140 } }),
  heading2('2nd-Order Neuron Types in Dorsal Horn', C.teal),
  new Table({
    width: { size: 90, type: WidthType.PERCENTAGE },
    alignment: AlignmentType.CENTER,
    rows: [
      headerRow(['Type', 'Responds To', 'Location', 'Role']),
      altRow(['Nociceptive-Specific (NS)', 'ONLY painful input', 'Lamina I', 'Specific pain signaling'], 0),
      altRow(['Wide Dynamic Range (WDR)', 'Both painful + non-painful', 'Lamina V', 'Pain integration, sensitization, gate'], 1),
    ]
  }),
  new Paragraph({ spacing: { before: 100 } }),
  divider(),
];

// ── SECTION 5: Peripheral Sensitization ──────────────────────────────────────
const sec5 = [
  heading1('5. Peripheral Sensitization & Hyperalgesia'),
  heading2('Inflammatory Mediators Released on Tissue Injury'),
  new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [
      headerRow(['Mediator', 'Source', 'Effect on Nociceptor']),
      altRow(['Bradykinin', 'Plasma proteins', 'Direct activation + sensitization'], 0),
      altRow(['Prostaglandins (PGE2)', 'Arachidonic acid (COX pathway)', 'Lowers activation threshold'], 1),
      altRow(['Histamine', 'Mast cells', 'Direct activation'], 0),
      altRow(['Serotonin (5-HT)', 'Platelets', 'Sensitization'], 1),
      altRow(['K⁺ / H⁺ ions', 'Damaged cells', 'Depolarize nociceptors'], 0),
      altRow(['Substance P', 'Primary afferents (antidromic)', 'Neurogenic inflammation, sensitization'], 1),
    ]
  }),
  new Paragraph({ spacing: { before: 100 } }),
  heading2('Result of Sensitization'),
  bullet('Hyperalgesia – exaggerated pain response to a normally painful stimulus'),
  bullet('Allodynia – pain in response to a normally NON-painful stimulus'),
  bullet('Expanded receptive field – wider area of tenderness'),
  note('Peripheral sensitization = change at the RECEPTOR level\nCentral sensitization = change at the SPINAL CORD/BRAIN level (distinguish these!)'),
  divider(),
];

// ── SECTION 6: Clinical Types ─────────────────────────────────────────────────
const sec6 = [
  heading1('6. Clinical Types of Pain'),
  heading2('Acute vs. Chronic Pain'),
  new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [
      headerRow(['Feature', 'Acute Pain', 'Chronic Pain']),
      altRow(['Purpose', 'Protective warning signal', 'Often loses protective role'], 0),
      altRow(['Duration', 'Short, resolves with healing', '> 3–6 months, persists after healing'], 1),
      altRow(['Behavior', 'Restless, anxious, guarding', 'Withdrawn, depressed, pain behavior absent'], 0),
      altRow(['Autonomic signs', 'Tachycardia, hypertension,\ndilated pupils, sweating', 'Often minimal or absent'], 1),
      altRow(['Neural basis', 'Active nociception', 'Neural dysfunction, central sensitization'], 0),
      altRow(['Emotional state', 'Fear, anxiety', 'Depression, helplessness, catastrophizing'], 1),
    ]
  }),
  new Paragraph({ spacing: { before: 120 } }),
  heading2('Other Pain Types'),
  new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [
      headerRow(['Type', 'Definition', 'Mechanism/Example']),
      altRow(['Somatogenic', 'Origin in body tissue (musculoskeletal, visceral)', 'Fracture, arthritis, muscle tear'], 0),
      altRow(['Neurogenic/Neuropathic', 'Damage to nervous tissue itself', 'Diabetic neuropathy, sciatica, post-herpetic neuralgia'], 1),
      altRow(['Psychogenic', 'Psychological origin, no clear tissue damage', 'Somatoform disorder, amplified pain'], 0),
      altRow(['Referred Pain', 'Felt distant from actual source', 'Cardiac ischemia → left arm/jaw; viscero-somatic convergence'], 1),
      altRow(['Phantom Pain', 'Pain in absent/amputated limb', 'Cortical map reorganization + central sensitization'], 0),
    ]
  }),
  new Paragraph({ spacing: { before: 100 } }),
  heading2('Referred Pain – Mechanism', C.orange),
  new Table({
    width: { size: 90, type: WidthType.PERCENTAGE },
    alignment: AlignmentType.CENTER,
    rows: [new TableRow({ children: [new TableCell({
      children: [
        para('Visceral afferents + somatic afferents CONVERGE on the same dorsal horn neuron'),
        para('→ Brain MISINTERPRETS the origin of the signal as coming from the somatic area'),
        para('Classic example: Myocardial ischemia (cardiac pain) → left arm, jaw, upper chest (levels C8-T4)'),
      ],
      shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.yellow },
      margins: { top: 80, bottom: 80, left: 160, right: 160 },
      borders: { top: { style: BorderStyle.THICK, size: 8, color: C.amber }, bottom: { style: BorderStyle.THICK, size: 8, color: C.amber }, left: { style: BorderStyle.THICK, size: 8, color: C.amber }, right: { style: BorderStyle.THICK, size: 8, color: C.amber } }
    })] })]
  }),
  new Paragraph({ spacing: { before: 80 } }),
  divider(),
];

// ── SECTION 7: Gate Control Theory ───────────────────────────────────────────
const sec7 = [
  heading1('7. Gate Control Theory (Melzack & Wall, 1965)'),
  heading2('THE MOST IMPORTANT THEORY – Learn This Cold'),
  para('The "gate" is located in the substantia gelatinosa (Lamina II) of the spinal dorsal horn.'),
  para('It controls how much nociceptive signal passes up to the brain.'),
  new Paragraph({ spacing: { before: 80 } }),

  heading2('GATE CONTROL DIAGRAM', C.blue),
  new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [
      new TableRow({ children: [
        new TableCell({
          children: [
            new Paragraph({ children: [new TextRun({ text: 'SMALL FIBERS\n(A-delta + C)', bold: true, size: 22, color: C.white, font: 'Calibri' })], alignment: AlignmentType.CENTER, spacing: { before: 60, after: 60 } }),
            new Paragraph({ children: [new TextRun({ text: 'Noxious input', size: 19, color: C.white, font: 'Calibri' })], alignment: AlignmentType.CENTER }),
          ],
          shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.red },
          margins: { top: 100, bottom: 100, left: 120, right: 120 },
          borders: { top: { style: BorderStyle.SINGLE, size: 6, color: C.red }, bottom: { style: BorderStyle.SINGLE, size: 6, color: C.red }, left: { style: BorderStyle.SINGLE, size: 6, color: C.red }, right: { style: BorderStyle.SINGLE, size: 6, color: C.red } }
        }),
        new TableCell({
          children: [new Paragraph({ children: [new TextRun({ text: '→', size: 36, color: C.red, font: 'Calibri', bold: true })], alignment: AlignmentType.CENTER })],
          shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.white },
          margins: { top: 100, bottom: 100 },
        }),
        new TableCell({
          children: [
            new Paragraph({ children: [new TextRun({ text: 'INHIBITORY\nINTERNEURON\n(Substantia Gelatinosa)', bold: true, size: 20, color: C.white, font: 'Calibri' })], alignment: AlignmentType.CENTER, spacing: { before: 60, after: 60 } }),
            new Paragraph({ children: [new TextRun({ text: 'Small fibers INHIBIT this neuron', size: 18, color: C.white, font: 'Calibri', italics: true })], alignment: AlignmentType.CENTER }),
          ],
          shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.blue },
          margins: { top: 100, bottom: 100, left: 120, right: 120 },
          borders: { top: { style: BorderStyle.SINGLE, size: 6, color: C.blue }, bottom: { style: BorderStyle.SINGLE, size: 6, color: C.blue }, left: { style: BorderStyle.SINGLE, size: 6, color: C.blue }, right: { style: BorderStyle.SINGLE, size: 6, color: C.blue } }
        }),
        new TableCell({
          children: [new Paragraph({ children: [new TextRun({ text: '→', size: 36, color: C.red, font: 'Calibri', bold: true })], alignment: AlignmentType.CENTER })],
          shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.white },
          margins: { top: 100, bottom: 100 },
        }),
        new TableCell({
          children: [
            new Paragraph({ children: [new TextRun({ text: 'GATE OPEN', bold: true, size: 22, color: C.white, font: 'Calibri' })], alignment: AlignmentType.CENTER, spacing: { before: 60, after: 20 } }),
            new Paragraph({ children: [new TextRun({ text: 'Pain impulses ASCEND to brain', size: 19, color: C.white, font: 'Calibri' })], alignment: AlignmentType.CENTER }),
          ],
          shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.orange },
          margins: { top: 100, bottom: 100, left: 120, right: 120 },
          borders: { top: { style: BorderStyle.SINGLE, size: 6, color: C.orange }, bottom: { style: BorderStyle.SINGLE, size: 6, color: C.orange }, left: { style: BorderStyle.SINGLE, size: 6, color: C.orange }, right: { style: BorderStyle.SINGLE, size: 6, color: C.orange } }
        }),
      ]}),
      new TableRow({ children: [new TableCell({
        children: [new Paragraph({ children: [new TextRun({ text: ' ', size: 14 })], alignment: AlignmentType.CENTER })],
        columnSpan: 5,
        shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.white },
        borders: { top: { style: BorderStyle.NONE }, bottom: { style: BorderStyle.NONE }, left: { style: BorderStyle.NONE }, right: { style: BorderStyle.NONE } }
      })] }),
      new TableRow({ children: [
        new TableCell({
          children: [
            new Paragraph({ children: [new TextRun({ text: 'LARGE FIBERS\n(A-beta)', bold: true, size: 22, color: C.white, font: 'Calibri' })], alignment: AlignmentType.CENTER, spacing: { before: 60, after: 60 } }),
            new Paragraph({ children: [new TextRun({ text: 'Touch / pressure', size: 19, color: C.white, font: 'Calibri' })], alignment: AlignmentType.CENTER }),
          ],
          shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.green },
          margins: { top: 100, bottom: 100, left: 120, right: 120 },
          borders: { top: { style: BorderStyle.SINGLE, size: 6, color: C.green }, bottom: { style: BorderStyle.SINGLE, size: 6, color: C.green }, left: { style: BorderStyle.SINGLE, size: 6, color: C.green }, right: { style: BorderStyle.SINGLE, size: 6, color: C.green } }
        }),
        new TableCell({
          children: [new Paragraph({ children: [new TextRun({ text: '→', size: 36, color: C.green, font: 'Calibri', bold: true })], alignment: AlignmentType.CENTER })],
          shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.white },
          margins: { top: 100, bottom: 100 },
        }),
        new TableCell({
          children: [
            new Paragraph({ children: [new TextRun({ text: 'INHIBITORY\nINTERNEURON\n(Substantia Gelatinosa)', bold: true, size: 20, color: C.white, font: 'Calibri' })], alignment: AlignmentType.CENTER, spacing: { before: 60, after: 60 } }),
            new Paragraph({ children: [new TextRun({ text: 'Large fibers ACTIVATE this neuron', size: 18, color: C.white, font: 'Calibri', italics: true })], alignment: AlignmentType.CENTER }),
          ],
          shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.blue },
          margins: { top: 100, bottom: 100, left: 120, right: 120 },
          borders: { top: { style: BorderStyle.SINGLE, size: 6, color: C.blue }, bottom: { style: BorderStyle.SINGLE, size: 6, color: C.blue }, left: { style: BorderStyle.SINGLE, size: 6, color: C.blue }, right: { style: BorderStyle.SINGLE, size: 6, color: C.blue } }
        }),
        new TableCell({
          children: [new Paragraph({ children: [new TextRun({ text: '→', size: 36, color: C.green, font: 'Calibri', bold: true })], alignment: AlignmentType.CENTER })],
          shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.white },
          margins: { top: 100, bottom: 100 },
        }),
        new TableCell({
          children: [
            new Paragraph({ children: [new TextRun({ text: 'GATE CLOSED', bold: true, size: 22, color: C.white, font: 'Calibri' })], alignment: AlignmentType.CENTER, spacing: { before: 60, after: 20 } }),
            new Paragraph({ children: [new TextRun({ text: 'Pain transmission SUPPRESSED', size: 19, color: C.white, font: 'Calibri' })], alignment: AlignmentType.CENTER }),
          ],
          shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.teal },
          margins: { top: 100, bottom: 100, left: 120, right: 120 },
          borders: { top: { style: BorderStyle.SINGLE, size: 6, color: C.teal }, bottom: { style: BorderStyle.SINGLE, size: 6, color: C.teal }, left: { style: BorderStyle.SINGLE, size: 6, color: C.teal }, right: { style: BorderStyle.SINGLE, size: 6, color: C.teal } }
        }),
      ]}),
    ]
  }),
  new Paragraph({ spacing: { before: 120 } }),
  heading2('Inhibitory Neurotransmitters at the Gate'),
  bullet('GABA (GABA-B receptor – baclofen) – segmental inhibition'),
  bullet('Glycine – increases Cl⁻ conductance → hyperpolarization'),
  bullet('Adenosine – A1 receptor mediates antinociception'),
  new Paragraph({ spacing: { before: 100 } }),
  heading2('Clinical Applications of Gate Control', C.orange),
  new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [
      headerRow(['Intervention', 'Fiber Activated', 'Gate Effect']),
      altRow(['Rubbing / stroking', 'A-beta (touch)', 'Closes gate → reduces pain'], 0),
      altRow(['Vibration therapy', 'A-beta (mechanoreceptors)', 'Closes gate → segmental inhibition'], 1),
      altRow(['High-frequency low-intensity TENS', 'A-beta', 'Closes gate (segmental)'], 0),
      altRow(['Brief intense TENS', 'A-delta + A-beta', 'Peripheral block + gate closure'], 1),
      altRow(['Massage', 'A-beta (large fibers)', 'Closes gate + peripheral effects'], 0),
      altRow(['Cold/hot therapy', 'Mixed', 'Peripheral + segmental effects'], 1),
      altRow(['Interferential current', 'A-beta', 'Segmental gate closure'], 0),
    ]
  }),
  new Paragraph({ spacing: { before: 100 } }),
  divider(),
];

// ── SECTION 8: Descending Inhibitory Pathways ─────────────────────────────────
const sec8 = [
  heading1('8. Descending Inhibitory Pathways'),
  heading2('Top-Down Pain Suppression System'),
  new Paragraph({ spacing: { before: 60 } }),
  heading2('FLOWCHART: Descending Inhibitory Pathway', C.blue),

  flowBox('CORTEX + LIMBIC SYSTEM\n(Prefrontal Cortex, ACC, Amygdala, Thalamus)\nCognitive & emotional pain modulation', C.lpurple, C.purple),
  arrow(),
  flowBox('PERIAQUEDUCTAL GRAY (PAG)\nMidbrain\nKey relay station – stimulation produces widespread analgesia', C.lblue, C.navy),
  arrow(),
  new Table({
    width: { size: 80, type: WidthType.PERCENTAGE },
    alignment: AlignmentType.CENTER,
    rows: [new TableRow({ children: [
      new TableCell({
        children: [new Paragraph({ children: [new TextRun({ text: 'NUCLEUS RAPHE MAGNUS (NRM)\nRostral Ventromedial Medulla\n→ Serotonergic pathway', bold: true, size: 19, color: C.white, font: 'Calibri' })], alignment: AlignmentType.CENTER, spacing: { before: 80, after: 80 } })],
        shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.teal },
        margins: { top: 100, bottom: 100, left: 120, right: 120 },
        borders: { top: { style: BorderStyle.SINGLE, size: 8, color: C.teal }, bottom: { style: BorderStyle.SINGLE, size: 8, color: C.teal }, left: { style: BorderStyle.SINGLE, size: 8, color: C.teal }, right: { style: BorderStyle.SINGLE, size: 8, color: C.teal } }
      }),
      new TableCell({
        children: [new Paragraph({ children: [new TextRun({ text: 'AND', bold: true, size: 22, color: C.navy, font: 'Calibri' })], alignment: AlignmentType.CENTER })],
        shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.white },
        margins: { top: 80, bottom: 80 }
      }),
      new TableCell({
        children: [new Paragraph({ children: [new TextRun({ text: 'LOCUS COERULEUS\nDorsolateral Pons\n→ Noradrenergic pathway', bold: true, size: 19, color: C.white, font: 'Calibri' })], alignment: AlignmentType.CENTER, spacing: { before: 80, after: 80 } })],
        shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.purple },
        margins: { top: 100, bottom: 100, left: 120, right: 120 },
        borders: { top: { style: BorderStyle.SINGLE, size: 8, color: C.purple }, bottom: { style: BorderStyle.SINGLE, size: 8, color: C.purple }, left: { style: BorderStyle.SINGLE, size: 8, color: C.purple }, right: { style: BorderStyle.SINGLE, size: 8, color: C.purple } }
      }),
    ]})]
  }),
  arrow(),
  flowBox('DORSAL HORN – SPINAL CORD\nPre-synaptic inhibition (↓ Substance P, glutamate release)\n+ Post-synaptic inhibition of 2nd-order neurons', C.lgreen, C.green),
  arrow(),
  flowBox('PAIN SUPPRESSED\nReduced ascending nociceptive transmission', C.lgreen, C.green, true),

  new Paragraph({ spacing: { before: 140 } }),
  heading2('Three Descending Neurotransmitter Pathways'),
  new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [
      headerRow(['Pathway', 'Transmitter', 'Receptor', 'Origin', 'Mechanism']),
      new TableRow({ children: [
        cell('Serotonergic', { bg: C.lteal, bold: true, color: C.teal }),
        cell('Serotonin (5-HT)', { bg: C.lteal }),
        cell('5-HT receptors', { bg: C.lteal }),
        cell('NRM → dorsal horn\n(dorsolateral funiculus)', { bg: C.lteal }),
        cell('Inhibits dorsal horn neurons', { bg: C.lteal }),
      ]}),
      new TableRow({ children: [
        cell('Noradrenergic', { bg: C.lpurple, bold: true, color: C.purple }),
        cell('Norepinephrine (NE)', { bg: C.lpurple }),
        cell('α2-adrenergic', { bg: C.lpurple }),
        cell('Locus coeruleus → dorsal horn', { bg: C.lpurple }),
        cell('Pre/post-synaptic inhibition', { bg: C.lpurple }),
      ]}),
      new TableRow({ children: [
        cell('Opioidergic', { bg: C.lgreen, bold: true, color: C.green }),
        cell('β-endorphin, Enkephalins, Dynorphins', { bg: C.lgreen }),
        cell('μ, δ, κ opioid receptors', { bg: C.lgreen }),
        cell('PAG, NRM, Locus coeruleus, Dorsal horn', { bg: C.lgreen }),
        cell('↓ Substance P + glutamate; hyperpolarizes neurons', { bg: C.lgreen }),
      ]}),
    ]
  }),
  new Paragraph({ spacing: { before: 100 } }),
  heading2('Endogenous Opioids'),
  bullet('Beta-endorphin – from hypothalamus/pituitary; released by exercise, stress'),
  bullet('Enkephalins (met-enkephalin, leu-enkephalin) – in dorsal horn, NRM'),
  bullet('Dynorphins – in dorsal horn and limbic system'),
  note('All endogenous opioids are ANTAGONIZED by naloxone – this is why naloxone can partially reverse placebo analgesia'),
  new Paragraph({ spacing: { before: 80 } }),
  heading2('Clinical Significance of Descending Inhibition'),
  new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [
      headerRow(['Clinical Application', 'Mechanism via Descending Inhibition']),
      altRow(['Low-frequency high-intensity TENS\n(Acupuncture-like TENS)', 'Activates PAG → opioid release'], 0),
      altRow(['Acupuncture', 'Supraspinal opioid release via PAG/NRM activation'], 1),
      altRow(['Tricyclic antidepressants (amitriptyline)', 'Block reuptake of serotonin + NE → enhance descending inhibition'], 0),
      altRow(['SNRIs (duloxetine)', 'Same mechanism – serotonin + NE reuptake inhibition'], 1),
      altRow(['Exercise-induced analgesia', 'β-endorphin release from hypothalamus'], 0),
      altRow(['Placebo analgesia', 'Real opioid-mediated PAG activation (reversible by naloxone)'], 1),
      altRow(['UV radiation / counter-irritation', 'Supraspinal descending opioid activation'], 0),
    ]
  }),
  new Paragraph({ spacing: { before: 100 } }),
  divider(),
];

// ── SECTION 9: Cortical Modulation ────────────────────────────────────────────
const sec9 = [
  heading1('9. Cortical Modulation & Psychological Influence'),
  heading2('The Brain as an Active Pain Modulator'),
  para('The brain is NOT a passive receiver – it actively amplifies or suppresses pain through top-down control.'),
  new Paragraph({ spacing: { before: 80 } }),
  new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [
      headerRow(['AMPLIFIES Pain ↑', 'SUPPRESSES Pain ↓']),
      altRow(['Fear and anxiety', 'Reassurance and education'], 0),
      altRow(['Attention and hypervigilance', 'Distraction and positive focus'], 1),
      altRow(['Catastrophizing', 'Relaxation and mindfulness'], 0),
      altRow(['Depression', 'Positive coping strategies'], 1),
      altRow(['Negative past experience', 'Placebo (opioid-mediated)'], 0),
      altRow(['Stress (acute or chronic)', 'Exercise (endorphin release)'], 1),
    ]
  }),
  new Paragraph({ spacing: { before: 100 } }),
  heading2('PET Imaging Evidence'),
  new Table({
    width: { size: 90, type: WidthType.PERCENTAGE },
    alignment: AlignmentType.CENTER,
    rows: [new TableRow({ children: [new TableCell({
      children: [
        para('Subjects hypnotized to feel HOT water as "not painful":'),
        bullet('NO difference in somatosensory cortex activation'),
        bullet('Significantly LESS activation in Anterior Cingulate Cortex (ACC)'),
        para('→ Proves the emotional/cognitive component modulates pain at the brain level'),
      ],
      shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.lteal },
      margins: { top: 80, bottom: 80, left: 160, right: 160 },
      borders: { top: { style: BorderStyle.THICK, size: 8, color: C.teal }, bottom: { style: BorderStyle.THICK, size: 8, color: C.teal }, left: { style: BorderStyle.THICK, size: 8, color: C.teal }, right: { style: BorderStyle.THICK, size: 8, color: C.teal } }
    })] })]
  }),
  new Paragraph({ spacing: { before: 100 } }),
  heading2('Cortical Modulation Interventions'),
  bullet('Cognitive Behavioral Therapy (CBT) – restructures catastrophic thoughts'),
  bullet('Graded Exposure Therapy – addresses fear-avoidance in chronic pain'),
  bullet('Patient Education – reduces fear and uncertainty about pain'),
  bullet('Relaxation techniques – reduces limbic activation'),
  bullet('Mindfulness-based stress reduction (MBSR)'),
  note('These have MEASURABLE PHYSIOLOGICAL effects on descending inhibitory pathways – not just psychology!'),
  divider(),
];

// ── SECTION 10: Physiotherapy Framework ──────────────────────────────────────
const sec10 = [
  heading1('10. Pain Modulation – Physiotherapy Framework'),
  heading2('Four Levels of Intervention'),
  new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [
      headerRow(['Level', 'Target', 'Mechanism', 'Clinical Examples'], C.navy),
      new TableRow({ children: [
        cell('PERIPHERAL', { bg: C.lred, bold: true, color: C.red }),
        cell('Nociceptors\nInflammatory mediators', { bg: C.lred }),
        cell('Reduce chemical mediators\nDecrease tissue irritation', { bg: C.lred }),
        cell('NSAIDs, ice, compression,\nultrasound, PEME, massage', { bg: C.lred }),
      ]}),
      new TableRow({ children: [
        cell('SPINAL\nSEGMENTAL', { bg: C.lpurple, bold: true, color: C.purple }),
        cell('Dorsal horn gate\nA-beta activation', { bg: C.lpurple }),
        cell('Gate control (large fiber)\nPhysiological conduction block', { bg: C.lpurple }),
        cell('High-freq TENS, vibration,\nmanual therapy, brief intense TENS,\ninterferential current', { bg: C.lpurple }),
      ]}),
      new TableRow({ children: [
        cell('SUPRASPINAL', { bg: C.lblue, bold: true, color: C.blue }),
        cell('PAG → NRM\nDescending inhibition', { bg: C.lblue }),
        cell('Opioid/serotonin/NE release\nCounter-irritation', { bg: C.lblue }),
        cell('Acupuncture, low-freq TENS,\nUV radiation, counter-irritation,\nplacebo, didynamic current', { bg: C.lblue }),
      ]}),
      new TableRow({ children: [
        cell('CORTICAL', { bg: C.lgreen, bold: true, color: C.green }),
        cell('Prefrontal cortex\nLimbic system', { bg: C.lgreen }),
        cell('Cognitive restructuring\nAttention + fear modulation', { bg: C.lgreen }),
        cell('CBT, graded exposure,\neducation, relaxation,\ntherapist interaction', { bg: C.lgreen }),
      ]}),
    ]
  }),
  new Paragraph({ spacing: { before: 100 } }),
  divider(),
];

// ── SECTION 11: Modulation Summary Flowchart ─────────────────────────────────
const sec11 = [
  heading1('11. Complete Pain Modulation – Summary Flowchart'),
  new Paragraph({ spacing: { before: 80 } }),

  flowBox('NOXIOUS STIMULUS', C.lred, C.red),
  arrow(),

  new Table({
    width: { size: 90, type: WidthType.PERCENTAGE },
    alignment: AlignmentType.CENTER,
    rows: [new TableRow({ children: [
      new TableCell({
        children: [new Paragraph({ children: [new TextRun({ text: 'PERIPHERAL LEVEL\n(Nociceptor threshold)\nNSAIDs, ice, compression, US', bold: true, size: 19, color: C.red, font: 'Calibri' })], alignment: AlignmentType.CENTER, spacing: { before: 80, after: 80 } })],
        shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.lred },
        margins: { top: 80, bottom: 80, left: 80, right: 80 },
        borders: { top: { style: BorderStyle.SINGLE, size: 6, color: C.red }, bottom: { style: BorderStyle.SINGLE, size: 6, color: C.red }, left: { style: BorderStyle.SINGLE, size: 6, color: C.red }, right: { style: BorderStyle.SINGLE, size: 6, color: C.red } }
      }),
      new TableCell({
        children: [new Paragraph({ children: [new TextRun({ text: 'SPINAL LEVEL\n(Gate Control)\nTENS, vibration, massage', bold: true, size: 19, color: C.purple, font: 'Calibri' })], alignment: AlignmentType.CENTER, spacing: { before: 80, after: 80 } })],
        shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.lpurple },
        margins: { top: 80, bottom: 80, left: 80, right: 80 },
        borders: { top: { style: BorderStyle.SINGLE, size: 6, color: C.purple }, bottom: { style: BorderStyle.SINGLE, size: 6, color: C.purple }, left: { style: BorderStyle.SINGLE, size: 6, color: C.purple }, right: { style: BorderStyle.SINGLE, size: 6, color: C.purple } }
      }),
      new TableCell({
        children: [new Paragraph({ children: [new TextRun({ text: 'SUPRASPINAL LEVEL\n(Descending inhibition)\nAcupuncture, low-freq TENS', bold: true, size: 19, color: C.blue, font: 'Calibri' })], alignment: AlignmentType.CENTER, spacing: { before: 80, after: 80 } })],
        shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.lblue },
        margins: { top: 80, bottom: 80, left: 80, right: 80 },
        borders: { top: { style: BorderStyle.SINGLE, size: 6, color: C.blue }, bottom: { style: BorderStyle.SINGLE, size: 6, color: C.blue }, left: { style: BorderStyle.SINGLE, size: 6, color: C.blue }, right: { style: BorderStyle.SINGLE, size: 6, color: C.blue } }
      }),
      new TableCell({
        children: [new Paragraph({ children: [new TextRun({ text: 'CORTICAL LEVEL\n(Cognitive modulation)\nCBT, education, relaxation', bold: true, size: 19, color: C.green, font: 'Calibri' })], alignment: AlignmentType.CENTER, spacing: { before: 80, after: 80 } })],
        shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.lgreen },
        margins: { top: 80, bottom: 80, left: 80, right: 80 },
        borders: { top: { style: BorderStyle.SINGLE, size: 6, color: C.green }, bottom: { style: BorderStyle.SINGLE, size: 6, color: C.green }, left: { style: BorderStyle.SINGLE, size: 6, color: C.green }, right: { style: BorderStyle.SINGLE, size: 6, color: C.green } }
      }),
    ]})]
  }),
  arrow(),
  flowBox('PAIN PERCEPTION AT CORTEX\n(Somatosensory + Limbic + Prefrontal)', C.yellow, C.amber),
  arrow(),
  flowBox('MODULATION REDUCES/MODIFIES PAIN EXPERIENCE', C.lgreen, C.green, true),
  new Paragraph({ spacing: { before: 100 } }),
  divider(),
];

// ── SECTION 12: High-Yield Key Points ────────────────────────────────────────
const sec12 = [
  heading1('12. High-Yield Exam Key Points'),
  new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [
      headerRow(['#', 'Key Fact to Remember']),
      altRow(['1', 'First pain = A-delta (sharp, fast) | Second pain = C fibers (dull, slow, burning)'], 0),
      altRow(['2', 'Gate is in substantia gelatinosa (Lamina II) of dorsal horn – Melzack & Wall 1965'], 1),
      altRow(['3', 'Large fibers (A-beta) CLOSE the gate; Small fibers (A-delta, C) OPEN the gate'], 0),
      altRow(['4', 'PAG + NRM = the descending pain suppressive system'], 1),
      altRow(['5', 'Three descending transmitters: Serotonin, Norepinephrine, Opioids (SNO)'], 0),
      altRow(['6', 'Endogenous opioids: β-endorphin (hypothalamus), enkephalins (dorsal horn), dynorphins'], 1),
      altRow(['7', 'Referred pain: viscero-somatic convergence at dorsal horn → brain misinterprets origin'], 0),
      altRow(['8', 'Phantom pain = neuropathic (cortical map reorganization + central sensitization)'], 1),
      altRow(['9', 'WDR neurons: key in sensitization, wind-up, and chronic pain'], 0),
      altRow(['10', 'GABA + Glycine = inhibitory interneuron transmitters mediating gate closure'], 1),
      altRow(['11', 'Exercise-induced analgesia = β-endorphin release from hypothalamus/pituitary'], 0),
      altRow(['12', 'Peripheral sensitization = receptor level | Central sensitization = spinal/brain level'], 1),
      altRow(['13', 'Allodynia = pain from non-painful stimulus | Hyperalgesia = exaggerated pain from painful stimulus'], 0),
      altRow(['14', 'Tricyclics/SNRIs reduce chronic pain by enhancing descending serotonin + NE inhibition'], 1),
      altRow(['15', 'Placebo analgesia is REAL – mediated by opioids, reversed by naloxone'], 0),
    ]
  }),
  new Paragraph({ spacing: { before: 100 } }),
  divider(),
];

// ── SECTION 13: Answer Writing Guide ─────────────────────────────────────────
const sec13 = [
  heading1('13. 20-Mark Answer Writing Structure'),
  new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [
      headerRow(['Section', 'Content', 'Marks Approx.']),
      altRow(['Introduction', 'IASP definition + multidimensional concept (5–7 lines)', '1–2'], 0),
      altRow(['Three Dimensions', 'Sensory-discriminative, Motivational-affective, Cognitive-evaluative (table)', '2'], 1),
      altRow(['Pain Fibers', 'A-delta, C, A-beta – table with clinical relevance', '2'], 0),
      altRow(['Transmission Pathway', 'Draw the flow diagram from nociceptor to cortex', '2–3'], 1),
      altRow(['Peripheral Sensitization', 'Mediators + mechanism + hyperalgesia/allodynia', '2'], 0),
      altRow(['Clinical Types', 'Acute vs chronic table + referred + phantom pain', '2'], 1),
      altRow(['Gate Control Theory', 'Diagram + mechanism (substantia gelatinosa) – draw!', '3–4'], 0),
      altRow(['Descending Inhibitory Pathways', 'PAG → NRM diagram + 3 neurotransmitters + endorphins', '3'], 1),
      altRow(['Cortical Modulation', 'Psychological influence with PET imaging evidence', '1'], 0),
      altRow(['Physiotherapy Applications', 'Table by 4 levels', '1–2'], 1),
      altRow(['Conclusion', '3–4 lines tying it together', '1'], 0),
    ]
  }),
  new Paragraph({ spacing: { before: 100 } }),
  note('DIAGRAMS EARN EXTRA MARKS – Practice the Gate Control diagram and Descending Pathway diagram before the exam!'),
  new Paragraph({ spacing: { before: 120 } }),
  new Table({
    width: { size: 90, type: WidthType.PERCENTAGE },
    alignment: AlignmentType.CENTER,
    rows: [new TableRow({ children: [new TableCell({
      children: [
        new Paragraph({ children: [new TextRun({ text: 'CONCLUSION', bold: true, size: 24, color: C.navy, font: 'Calibri' })], alignment: AlignmentType.CENTER, spacing: { before: 80, after: 60 } }),
        para('Pain is a multidimensional protective experience mediated by peripheral nociceptors, spinal transmission, ascending tracts, and brain processing. Modulation occurs through gate control at the spinal level, descending inhibitory pathways via PAG and NRM with opioid/serotonin/noradrenergic mechanisms, and cortical cognitive-behavioral influences. A clear understanding of these mechanisms is essential for rational physiotherapy and pain management.'),
      ],
      shading: { type: ShadingType.CLEAR, color: 'auto', fill: C.lblue },
      margins: { top: 120, bottom: 120, left: 160, right: 160 },
      borders: { top: { style: BorderStyle.THICK, size: 10, color: C.navy }, bottom: { style: BorderStyle.THICK, size: 10, color: C.navy }, left: { style: BorderStyle.THICK, size: 10, color: C.navy }, right: { style: BorderStyle.THICK, size: 10, color: C.navy } }
    })] })]
  }),
];

// ── ASSEMBLE DOCUMENT ──────────────────────────────────────────────────────────
const allChildren = [
  ...cover,
  ...sec1, ...sec2, ...sec3,
  pageBreak(),
  ...sec4,
  pageBreak(),
  ...sec5, ...sec6,
  pageBreak(),
  ...sec7,
  pageBreak(),
  ...sec8,
  pageBreak(),
  ...sec9, ...sec10,
  pageBreak(),
  ...sec11, ...sec12,
  pageBreak(),
  ...sec13,
];

const doc = new Document({
  styles: {
    default: {
      document: {
        run: { font: 'Calibri', size: 20, color: C.gray }
      }
    }
  },
  sections: [{
    properties: {
      page: {
        margin: { top: 900, bottom: 900, left: 900, right: 900 }
      }
    },
    children: allChildren
  }]
});

Packer.toBuffer(doc).then(buffer => {
  fs.writeFileSync('/home/daytona/workspace/pain-modulation/Pain_Modulation_MPT_Summary.docx', buffer);
  console.log('SUCCESS: Document written.');
}).catch(err => {
  console.error('ERROR:', err);
});
Running Command

cd /home/daytona/workspace/pain-modulation && node create_pain_doc.js

Running Command

python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/workspace/pain-modulation/Pain_Modulation_MPT_Summary.docx

Running Command

python3 -c " from pypdf import PdfReader import zipfile, os # Quick structural check – can we unzip the docx? path = '/home/daytona/workspace/pain-modulation/Pain_Modulation_MPT_Summary.docx' print('File size:', os.path.getsize(path), 'bytes') with zipfile.ZipFile(path) as z: names = z.namelist() print('DOCX contents:', names[:10]) # Check document.xml exists and has content with z.open('word/document.xml') as f: content = f.read() print('document.xml size:', len(content), 'bytes') print('First 200 chars:', content[:200]) "

Your document is ready! Download it here:

Pain Modulation MPT Summary

Word Document · DOCX


Here's what's inside the document (13 sections, fully color-coded):
SectionWhat's Included
Cover PageTitle, topic list, visual summary box
1. DefinitionIASP definition in highlighted box + key points
2. Three DimensionsColor table: Sensory-discriminative, Motivational-affective, Cognitive-evaluative
3. Pain FibersFull color table: A-delta (red), C fibers (purple), A-beta (green) with gate effect
4. Transmission PathwayFull step-by-step flowchart from nociceptor → cortex + WDR vs NS neuron table
5. Peripheral SensitizationInflammatory mediator table + hyperalgesia/allodynia definitions
6. Clinical TypesAcute vs chronic comparison table + referred pain + phantom pain mechanisms
7. Gate Control TheoryVisual gate diagram (open gate in red/orange vs closed gate in green/teal) + inhibitory transmitters + clinical applications table
8. Descending InhibitionFull descending pathway flowchart (PAG → NRM/LC → dorsal horn) + 3-transmitter table (serotonergic, noradrenergic, opioidergic) + clinical applications
9. Cortical ModulationAmplifiers vs suppressors table + PET imaging evidence box
10. PT Framework4-level color-coded table (peripheral/spinal/supraspinal/cortical)
11. Master Summary FlowchartOne-page overview of all 4 modulation levels in parallel
12. High-Yield Key Points15 must-know facts as a quick-revision table
13. Answer Writing GuideSection-by-section marks breakdown for exam strategy + conclusion box
This is a shared conversation. Sign in to Orris to start your own chat.