attachment
attachment

Give answer for all question , for 5 or 10 marks

Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Here are comprehensive answers for all Special Senses topics from the image:

SPECIAL SENSES - Complete Answers (5/10 Marks)


1. AUDITORY PATHWAY

The auditory pathway carries sound signals from the cochlea to the auditory cortex.
Pathway:
  1. Hair cells (Organ of Corti) - Sound waves cause vibration of the basilar membrane, deflecting stereocilia of hair cells. This mechanotransduction generates action potentials in the cochlear nerve.
  2. Cochlear nerve (CN VIII) - Afferent fibers enter the brainstem and end in the dorsal and ventral cochlear nuclei of the medulla.
  3. Cochlear nuclei - From here, fibers take multiple routes:
    • Most fibers cross the midline (decussate) via the trapezoid body and ascend in the lateral lemniscus
    • A few fibers remain ipsilateral
  4. Superior Olivary Nucleus - Located at the level of the pons. This is where binaural convergence first occurs (inputs from both ears). Important for sound localization.
  5. Inferior Colliculus - Located in the midbrain tectum. This is the center for auditory reflexes (e.g., turning head toward a sound).
  6. Medial Geniculate Body (MGB) - Located in the thalamus. Relay station for auditory signals.
  7. Auditory Cortex - Located on the superior temporal gyrus (Heschl's gyrus) of the temporal lobe (Brodmann areas 41, 42).
    • Low tones are represented anterolaterally; high tones posteromedially (tonotopic organization)
    • Wernicke's area (left hemisphere) processes speech; right hemisphere processes melody, pitch, and sound intensity
Note: Beyond the superior olive, most neurons respond to inputs from both ears (bilateral representation).
(Ganong's Review of Medical Physiology, 26th ed.)

2. VISUAL PATHWAY AND DEFECTS

Pathway:
  1. Retina - Photoreceptors (rods and cones) → bipolar cells → ganglion cells. Axons of ganglion cells form the optic nerve.
  2. Optic nerve (CN II) - Carries signals from each eye.
  3. Optic chiasma - Partial decussation: nasal fibers (from nasal/medial retina, representing temporal visual field) cross to the opposite side; temporal fibers remain ipsilateral.
  4. Optic tract - Each optic tract carries:
    • Ipsilateral temporal retinal fibers
    • Contralateral nasal retinal fibers Thus each optic tract carries information from the contralateral visual field.
  5. Lateral Geniculate Body (LGB) of the thalamus - Main relay station.
  6. Optic radiations (Geniculocalcarine tract) - Fibers pass through the internal capsule to reach the visual cortex.
    • Upper fibers: carry lower field → pass through the parietal lobe
    • Lower fibers (Meyer's loop): carry upper field → loop through the temporal lobe
  7. Primary Visual Cortex (V1) - Located on the calcarine fissure of the occipital lobe (Brodmann area 17).
Visual Field Defects:
Lesion SiteDefect
One optic nerveMonocular blindness (same eye)
Optic chiasma (central, e.g., pituitary tumor)Bitemporal hemianopia
Optic tractContralateral homonymous hemianopia
Meyer's loop (temporal lobe)Contralateral upper quadrantanopia ("pie in the sky")
Parietal optic radiationContralateral lower quadrantanopia
Complete optic radiation / visual cortexContralateral homonymous hemianopia with macular sparing (macular sparing is due to dual blood supply of occipital pole)

3. TASTE PATHWAY

Receptor organs: Taste buds on the tongue, soft palate, and epiglottis. Taste cells respond to 5 basic modalities: sweet, sour, salty, bitter, and umami.
Cranial nerves carrying taste:
  • Anterior 2/3 of tongue - Chorda tympani branch of CN VII (Facial nerve)
  • Posterior 1/3 of tongue - CN IX (Glossopharyngeal nerve)
  • Epiglottis and pharynx - CN X (Vagus nerve)
Central pathway:
  1. All three nerves → Nucleus of the Tractus Solitarius (NTS) in the medulla (rostral gustatory portion)
  2. From NTS → fibers ascend in the central tegmental tractventral posteromedial (VPM) nucleus of the thalamus (medial part)
  3. Thalamus → Primary gustatory cortex - located in the anterior insula and adjacent frontal operculum (parietal lobe, area 43)
  4. Also projects to the orbitofrontal cortex for conscious taste perception and food reward
Note: Unlike most sensory pathways, the gustatory pathway does NOT completely decussate - there is bilateral cortical representation.

4. OLFACTORY PATHWAY

Receptor cells: Olfactory sensory neurons in the olfactory epithelium of the roof of the nasal cavity. These are bipolar neurons (the only neurons directly exposed to the external environment that can regenerate). Each neuron expresses only one type of odorant receptor (out of ~400 functional types).
Pathway:
  1. Olfactory sensory neurons - their axons (forming the olfactory nerve, CN I) pass through the cribriform plate of the ethmoid bone.
  2. Olfactory bulb - Axons synapse on primary dendrites of mitral cells and tufted cells, forming olfactory glomeruli. Each glomerulus receives input from neurons expressing the same receptor type, creating an odorant-specific 2D map.
    • Periglomerular cells and granule cells provide lateral inhibition (sharpening).
  3. Lateral olfactory stria - Axons of mitral and tufted cells travel posteriorly to terminate in 5 regions of the olfactory cortex (primary olfactory cortex):
    • Anterior olfactory nucleus
    • Olfactory tubercle
    • Piriform cortex (most important)
    • Amygdala (emotional responses to smell)
    • Entorhinal cortex (olfactory memories)
  4. From olfactory cortex → orbitofrontal cortex (conscious odor discrimination) via thalamus
Key feature: Olfaction is the only sensory system that bypasses the thalamus for its primary cortical projections.
Mechanism of transduction:
  • Odorant binds to G-protein-coupled receptor
  • Activates adenylyl cyclase → increases cAMP
  • cAMP opens cation channels → Na⁺ and Ca²⁺ influx → depolarization
(Ganong's Review of Medical Physiology, 26th ed.)

5. MIDDLE EAR FUNCTIONS / SOUND CONDUCTION THROUGH MIDDLE EAR

The middle ear is an air-filled space lined by mucosa, containing the ossicular chain (malleus, incus, stapes).
Functions:
1. Impedance Matching (Most important function)
  • Sound travels through air but must be transmitted to fluid in the cochlea.
  • There is a large impedance mismatch between air and fluid (fluid requires much more pressure to vibrate).
  • The middle ear overcomes this by amplifying pressure ~22-fold, via:
    • Area effect: Tympanic membrane area (~55 mm²) is much larger than oval window (~3.2 mm²) → ratio ~17:1 pressure amplification
    • Lever action of ossicles: Malleus arm is longer than incus arm → additional ~1.3:1 amplification
    • Total amplification: ~22x (about 25-30 dB gain)
2. Sound Conduction:
  • Sound waves → vibrate tympanic membrane (eardrum) → malleus → incus → stapes → stapes footplate pushes on oval window → creates waves in the perilymph of the cochlea → vibrates basilar membrane → stimulates hair cells
3. Acoustic Reflex (Attenuation reflex):
  • Loud sounds (>80 dB) trigger contraction of the stapedius muscle (CN VII) and tensor tympani muscle (CN V) → stiffen ossicular chain → reduce transmission of low-frequency sounds → protects cochlea from loud noise
4. Eustachian Tube:
  • Connects middle ear to nasopharynx
  • Normally closed, opens during swallowing/yawning
  • Equalizes pressure between middle ear and atmosphere
  • Allows drainage of middle ear secretions
5. Round window:
  • Acts as a pressure-release valve; when the oval window is pushed inward, the round window bulges outward, allowing the cochlear fluid to move.

6. THEORIES OF HEARING

Three major theories explain how the cochlea analyzes frequency:

A. Place Theory (Helmholtz / von Bekesy's Traveling Wave Theory)

  • Helmholtz (1857): Each point on the basilar membrane resonates like a string of a piano at a specific frequency (higher frequency at base, lower at apex).
  • Von Bekesy (Nobel Prize 1961): Sound produces a traveling wave along the basilar membrane. Each frequency produces maximal vibration at a specific location:
    • High frequencies → maximum vibration at base (near oval window) - narrow and stiff
    • Low frequencies → maximum vibration at apex (near helicotrema) - wide and flexible
  • This is the basis of tonotopic organization of the cochlea.
  • Best supported theory for frequency discrimination.

B. Frequency (Telephone) Theory (Rutherford, 1886)

  • The basilar membrane vibrates as a whole, and the frequency of vibration is directly proportional to the frequency of the sound.
  • The auditory nerve fires at the same frequency as the sound wave.
  • Limitation: Nerve fibers cannot fire faster than ~1000 Hz (refractory period), but humans hear up to 20,000 Hz.

C. Volley Theory (Wever & Bray, 1937)

  • Modifies the frequency theory: groups of nerve fibers fire in turns (in volleys), so that the combined frequency of nerve firing matches the sound frequency even when individual fibers cannot.
  • Works up to about 4000 Hz.
  • Combined place + volley theory best explains the full range of human hearing.
Current understanding: Place theory governs high frequencies; volley/frequency theory governs low frequencies.

7. THEORIES OF COLOUR VISION

A. Young-Helmholtz Trichromatic Theory (Three-Color Theory)

  • Proposed by Thomas Young (1801), refined by Hermann von Helmholtz.
  • The retina contains three types of cone photoreceptors, each maximally sensitive to one wavelength:
    • S-cones (Short) - peak sensitivity ~420 nm (Blue/violet)
    • M-cones (Medium) - peak sensitivity ~530 nm (Green)
    • L-cones (Long) - peak sensitivity ~560 nm (Red/yellow)
  • All colors are perceived by combining signals from these three cone types.
  • Explains: Color mixing, color blindness (dichromacy = absence of one cone type; monochromacy = absence of two).

B. Hering's Opponent Color Theory (Opponent Process Theory)

  • Proposed by Ewald Hering (1878).
  • Color is processed as opponent pairs:
    • Red vs. Green
    • Blue vs. Yellow
    • Black vs. White (brightness)
  • Each channel can signal only one of the pair at a time (they are mutually inhibitory).
  • Explains: Color afterimages (after staring at red, you see green), simultaneous color contrast, and why you cannot perceive "reddish-green."

C. Modern Combined Theory (Zone/Stage Theory)

  • Both theories are correct at different levels:
    • Stage 1 (Retina): Trichromatic - three types of cones (Young-Helmholtz).
    • Stage 2 (Retinal ganglion cells and LGB): Opponent processing - ganglion cells and LGB neurons respond in an opponent manner (Hering).
    • Stage 3 (Visual cortex): Further complex color processing.

8. PHOTOTRANSDUCTION

Phototransduction is the process by which light energy is converted into an electrical (neural) signal.
In Rods (most studied):
In Darkness:
  • Intracellular cGMP levels are high
  • cGMP keeps cGMP-gated Na⁺/Ca²⁺ channels OPEN in the outer segment
  • Na⁺ and Ca²⁺ enter → cell is depolarized (-40 mV)
  • Continuously releases glutamate at the synapse with bipolar cells ("dark current")
When Light Hits:
  1. Photon absorbed by 11-cis-retinal (chromophore of rhodopsin)
  2. 11-cis-retinal isomerizes to all-trans-retinal (within 1 picosecond)
  3. This changes opsin conformation → activates opsin (metarhodopsin II)
  4. Activated opsin activates transducin (Gt protein) - GDP is exchanged for GTP
  5. α-subunit of transducin activates phosphodiesterase (PDE)
  6. PDE hydrolyzes cGMP → 5'-GMP → cGMP levels fall
  7. cGMP-gated channels close → less Na⁺/Ca²⁺ entry
  8. Cell hyperpolarizes (to about -70 mV)
  9. Reduced glutamate release → signals bipolar cell → ganglion cell → optic nerve
In Cones:
  • Same general mechanism but uses different iodopsins (cone opsins):
    • Red-sensitive (L-opsin), Green-sensitive (M-opsin), Blue-sensitive (S-opsin)
  • Less sensitive to light than rods, but responsible for color vision and high acuity
Recovery/Restoration:
  • All-trans-retinal dissociates, moves to pigment epithelium → regenerated back to 11-cis-retinal by retinal isomerase → combines with opsin to restore rhodopsin ("bleaching and regeneration cycle")
(Ganong's 26th ed.; Junqueira's Histology 17th ed.)

9. DARK ADAPTATION

Definition: The increase in sensitivity of the eyes (decrease in visual threshold) when moving from a brightly lit to a dark environment.
Time course: Nearly maximal in ~20 minutes, though some further decline occurs over longer periods.
Mechanism:
Phase 1 - Cone adaptation (fast):
  • First 5-8 minutes: rapid but small drop in threshold
  • Due to regeneration of cone photopigments (iodopsins)
  • Tested by isolating the fovea (rod-free area)
Phase 2 - Rod adaptation (slow):
  • After 8-10 minutes: slower but much larger drop in threshold
  • Due to gradual regeneration of rhodopsin in rods
  • In bright light, rhodopsin is continuously bleached; in darkness, it is regenerated
  • Total change between light-adapted and fully dark-adapted eye is very large (~10,000-fold)
The Purkinje Shift:
  • In dim light (scotopic vision), the peak sensitivity shifts from ~555 nm (cones) to ~505 nm (rods)
  • This is why blue-green objects look relatively brighter in dim light compared to red objects
Practical application:
  • Radiologists, pilots, and others wearing red goggles can stay in bright light while their rods dark-adapt (red light stimulates cones but not rods significantly)
Light Adaptation:
  • The reverse process - moving from dark to bright light; takes only ~5 minutes (disappearance of dark adaptation)
(Ganong's Review of Medical Physiology, 26th ed.)

10. LIGHT REFLEX PATHWAY (Pupillary Light Reflex)

Definition: Constriction of the pupil in response to light.
  • Direct light reflex: Light in one eye → constriction of the pupil of the SAME eye
  • Consensual light reflex: Light in one eye → constriction of the pupil of the OTHER eye
Afferent limb:
  1. Light hits retinal receptor cells
  2. Signals pass through bipolar cells → retinal ganglion cells (a special class of intrinsically photosensitive ganglion cells using melanopsin)
  3. Optic nerve (CN II)
  4. → Optic chiasma (partial decussation occurs)
  5. → Optic tract
  6. Fibers leave the optic tract BEFORE the lateral geniculate body and go to the pretectal nuclei (in the midbrain, at the level of the superior colliculus)
Interneuronal connection:
  • Pretectal nucleus projects bilaterally to both Edinger-Westphal (EW) nuclei (this explains consensual reflex)
Efferent limb (parasympathetic):
  1. Edinger-Westphal nucleus (accessory nucleus of CN III)
  2. → Preganglionic parasympathetic fibers travel in CN III (oculomotor nerve)
  3. → Synapse in the ciliary ganglion
  4. → Short ciliary nerves
  5. Sphincter pupillae muscle → pupil constricts (miosis)
Clinical importance:
  • Used to assess brainstem integrity in comatose patients
  • RAPD (Relative Afferent Pupillary Defect / Marcus Gunn pupil): Afferent limb lesion
  • Hutchinson's pupil: CN III compression (dilated pupil, no light reflex) - sign of uncal herniation

11. ACCOMMODATION REFLEX PATHWAY

Definition: A three-part response when shifting gaze from a far to a near object. The three components are:
  1. Accommodation (lens becomes more convex)
  2. Convergence of visual axes
  3. Miosis (pupil constricts)
Stimulus: Blurred image on the retina when viewing a near object.
Pathway:
Afferent limb:
  1. Retina → optic nerve → optic chiasma → optic tract
  2. Lateral Geniculate Body (LGB)
  3. → Optic radiations → Primary visual cortex (Area 17)
  4. Visual association cortex (Areas 18, 19)
Efferent limb:
  1. Cortical signals pass to the Edinger-Westphal (EW) nucleus via the pretectal area and superior colliculus
  2. Preganglionic fibers in CN IIIciliary ganglion
  3. Short ciliary nerves → ciliary muscle contracts (circular/sphincter muscle of ciliary body)
  4. Ciliary muscle contraction relaxes the zonular fibers (suspensory ligament of lens)
  5. Lens becomes more spherical/convex → increases refractive power → focuses near objects on the retina
Convergence: Medial rectus muscles contract bilaterally (CN III).
Miosis: Sphincter pupillae contracts (same pathway as light reflex efferent limb).
Clinical note:
  • Adie's tonic pupil: Loss of accommodation reflex but light reflex may be preserved
  • Argyll Robertson pupil: Accommodation reflex PRESENT but light reflex ABSENT (lesion in pretectal area, classically syphilis) - "prostitute's pupil - accommodates but does not react"
  • Presbyopia: Loss of accommodation with age due to increasing lens hardness (becomes evident at ~40-45 years)

12. ENDOCOCHLEAR POTENTIAL

  • The scala media (cochlear duct) is filled with endolymph, which is unique extracellular fluid with high K⁺ (~150 mEq/L) and low Na⁺ - more like intracellular fluid than typical extracellular fluid.
  • The scala vestibuli and scala tympani contain perilymph, which has the usual extracellular composition (low K⁺, high Na⁺).
  • The endocochlear potential (EP) is approximately +80 to +85 mV in the scala media relative to scala vestibuli and scala tympani.
  • This is generated and maintained by the stria vascularis (metabolically active epithelium lining the lateral wall of scala media).
  • The hair cell resting membrane potential is about -60 mV. Thus the electrical gradient across the hair cell stereocilia tip into the endolymph is: 80 - (-60) = ~140 mV (the "endocochlear battery"), which strongly drives K⁺ into hair cells when channels open.
  • This large driving force is what gives the cochlea its remarkable sensitivity.

13. PHYSIOLOGY OF TASTE (Mechanism / How Depolarisation Occurs)

Taste receptor cells are modified epithelial cells (not neurons) clustered in taste buds. They have microvilli (taste hairs) that project through a taste pore to the oral cavity.
Mechanisms for the 5 taste modalities:
TasteMechanism
SaltyNa⁺ enters taste cells through amiloride-sensitive Na⁺ channels → direct depolarization
SourH⁺ (acid) blocks K⁺ channels AND directly enters through H⁺-gated channels → depolarization
BitterBinds G-protein-coupled receptor (T2R family) → activates gustducin → ↑IP₃ → Ca²⁺ release from ER → depolarization; also can close K⁺ channels
SweetBinds G-protein-coupled receptor (T1R2 + T1R3) → ↑cAMP → PKA → closes K⁺ channels → depolarization
UmamiBinds T1R1 + T1R3 receptor → similar to sweet pathway
Final common pathway: Depolarization of the receptor cell → Ca²⁺ influx → vesicle fusion → release of neurotransmitter (ATP, serotonin) → activates afferent nerve fibers.

14. PHYSIOLOGY OF SMELL

Receptor: ~10-12 million olfactory sensory neurons in the olfactory epithelium (roof of nasal cavity).
  • These are bipolar neurons (unique - they are neurons, not modified epithelial cells like taste)
  • Dendrites project into mucous layer as olfactory cilia
  • Lifespan ~30-60 days; can regenerate from basal cells
Transduction mechanism:
  1. Odorant molecules dissolve in the mucus overlying the epithelium
  2. Bind to olfactory receptor proteins (G-protein-coupled receptors; 400 functional types in humans)
  3. Activate Golf protein (olfactory G-protein)
  4. Activate adenylyl cyclase III → ↑cAMP
  5. cAMP opens cAMP-gated cation channels → Na⁺ and Ca²⁺ influx
  6. Ca²⁺ opens Ca²⁺-activated Cl⁻ channels → further depolarization
  7. Action potential generated in the olfactory neuron
Adaptation (habituation):
  • Rapid adaptation to persistent odors due to desensitization of receptor proteins and adaptation at higher centers.
Anosmia: Inability to smell; can result from head injury (shearing of CN I at cribriform plate), viral infections, or neurodegenerative diseases (early sign in Parkinson's and Alzheimer's disease).

15. PHYSIOLOGY OF HEARING

Sound transduction (from sound to action potential):
  1. Outer ear (Pinna + External auditory canal): Collects and funnels sound waves to the tympanic membrane.
  2. Tympanic membrane: Vibrates in response to sound waves.
  3. Middle ear (Ossicular chain): Malleus → Incus → Stapes. The stapes footplate vibrates at the oval window. This achieves impedance matching (~22-fold pressure amplification).
  4. Cochlea (Inner ear):
    • Stapes movement creates pressure waves in the perilymph of scala vestibuli
    • Pressure wave displaces the Reissner's membrane and then travels through the scala media
    • The basilar membrane vibrates - different frequencies cause maximal vibration at different points (tonotopy - high freq at base, low freq at apex) - Place Theory (von Bekesy)
    • Vibration of the basilar membrane causes deflection of stereocilia of hair cells in the Organ of Corti against the tectorial membrane
  5. Hair cell transduction:
    • When stereocilia bend toward the tallest cilium, tip links open mechanosensitive K⁺ channels
    • K⁺ and Ca²⁺ flow in from the endolymph (driven by the endocochlear potential)
    • Hair cell depolarizes → Ca²⁺ influx at the base → vesicle release of glutamate → stimulates CN VIII
  6. Cochlear nerve (CN VIII) → auditory pathway (see Q1 above)
Outer hair cells (3 rows): Amplify the basilar membrane response via electromotility (prestin protein). Responsible for cochlear amplifier (active process, ~40-60 dB gain). Inner hair cells (1 row): True sensory transducers (95% of CN VIII fibers come from inner hair cells).

Sources: Ganong's Review of Medical Physiology (26th ed.), Neuroscience: Exploring the Brain (5th ed.), Junqueira's Basic Histology (17th ed.), Adams & Victor's Principles of Neurology (12th ed.)

Create a comprehensive study guide PDF covering all special senses pathways

Reading File
Running Command

mkdir -p /tmp/workspace/special-senses-pdf && ls /tmp/workspace/

Writing File

~/special-senses-pdf/generate_pdf.py


from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.lib import colors
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, KeepTogether
)
from reportlab.platypus.flowables import BalancedColumns
from reportlab.lib.colors import HexColor
import os

OUTPUT_PATH = "/tmp/workspace/special-senses-pdf/Special_Senses_Study_Guide.pdf"

# ── Colour palette ──────────────────────────────────────────────────────────
DARK_NAVY   = HexColor("#1A2B4A")
MID_BLUE    = HexColor("#2E5FA3")
LIGHT_BLUE  = HexColor("#D6E4F7")
TEAL        = HexColor("#1B7A8A")
TEAL_LIGHT  = HexColor("#D0EFF3")
GOLD        = HexColor("#C8922A")
GOLD_LIGHT  = HexColor("#FDF3DC")
RED_ACCENT  = HexColor("#B33000")
GREEN       = HexColor("#2A6B3A")
GREEN_LIGHT = HexColor("#DCF0E2")
GRAY_BG     = HexColor("#F4F6F9")
GRAY_LINE   = HexColor("#BEC8D9")
WHITE       = colors.white

# ── Document setup ───────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
    OUTPUT_PATH,
    pagesize=A4,
    rightMargin=1.8*cm, leftMargin=1.8*cm,
    topMargin=2*cm, bottomMargin=2*cm,
    title="Special Senses – Comprehensive Study Guide",
    author="Orris Medical",
    subject="Physiology – Special Senses Pathways"
)
W, H = A4
CONTENT_W = W - 3.6*cm

# ── Base styles ──────────────────────────────────────────────────────────────
base = getSampleStyleSheet()

def S(name, **kw):
    """Create a ParagraphStyle inheriting from 'Normal'."""
    return ParagraphStyle(name, parent=base["Normal"], **kw)

style_cover_title = S("CoverTitle",
    fontSize=32, textColor=WHITE, fontName="Helvetica-Bold",
    alignment=TA_CENTER, leading=38, spaceAfter=6)
style_cover_sub = S("CoverSub",
    fontSize=15, textColor=HexColor("#D6E4F7"), fontName="Helvetica",
    alignment=TA_CENTER, leading=20, spaceAfter=4)
style_cover_tag = S("CoverTag",
    fontSize=11, textColor=GOLD_LIGHT, fontName="Helvetica-Oblique",
    alignment=TA_CENTER, leading=16)

style_toc_head = S("TOCHead",
    fontSize=18, textColor=DARK_NAVY, fontName="Helvetica-Bold",
    alignment=TA_CENTER, spaceAfter=12, spaceBefore=8)
style_toc_item = S("TOCItem",
    fontSize=11, textColor=MID_BLUE, fontName="Helvetica",
    leading=18, leftIndent=10)

style_ch_title = S("ChTitle",
    fontSize=22, textColor=WHITE, fontName="Helvetica-Bold",
    alignment=TA_CENTER, leading=28)
style_ch_num = S("ChNum",
    fontSize=11, textColor=HexColor("#A8C4E8"), fontName="Helvetica-Oblique",
    alignment=TA_CENTER, leading=16, spaceAfter=2)

style_h1 = S("H1",
    fontSize=14, textColor=DARK_NAVY, fontName="Helvetica-Bold",
    spaceBefore=10, spaceAfter=4, leading=18)
style_h2 = S("H2",
    fontSize=12, textColor=MID_BLUE, fontName="Helvetica-Bold",
    spaceBefore=8, spaceAfter=3, leading=16)
style_h3 = S("H3",
    fontSize=11, textColor=TEAL, fontName="Helvetica-Bold",
    spaceBefore=6, spaceAfter=2, leading=14)

style_body = S("Body",
    fontSize=10, textColor=HexColor("#1E1E2E"), fontName="Helvetica",
    leading=15, spaceAfter=4, alignment=TA_JUSTIFY)
style_bullet = S("Bullet",
    fontSize=10, textColor=HexColor("#1E1E2E"), fontName="Helvetica",
    leading=14, leftIndent=14, firstLineIndent=-8, spaceAfter=2)
style_subbullet = S("SubBullet",
    fontSize=9.5, textColor=HexColor("#2E2E3E"), fontName="Helvetica",
    leading=13, leftIndent=26, firstLineIndent=-8, spaceAfter=2)
style_numbered = S("Numbered",
    fontSize=10, textColor=HexColor("#1E1E2E"), fontName="Helvetica",
    leading=14, leftIndent=18, firstLineIndent=-12, spaceAfter=3)

style_box_title = S("BoxTitle",
    fontSize=11, textColor=DARK_NAVY, fontName="Helvetica-Bold",
    leading=15, spaceAfter=3)
style_box_body = S("BoxBody",
    fontSize=9.5, textColor=HexColor("#1E1E2E"), fontName="Helvetica",
    leading=14, spaceAfter=2)
style_note = S("Note",
    fontSize=9.5, textColor=RED_ACCENT, fontName="Helvetica-BoldOblique",
    leading=13, spaceBefore=3, spaceAfter=3)
style_source = S("Source",
    fontSize=8.5, textColor=HexColor("#556070"), fontName="Helvetica-Oblique",
    leading=12, alignment=TA_CENTER, spaceAfter=6)
style_footer_pg = S("FooterPg",
    fontSize=8, textColor=HexColor("#8090A0"), fontName="Helvetica",
    alignment=TA_CENTER)

# ── Helper flowables ─────────────────────────────────────────────────────────

def hr(color=GRAY_LINE, thickness=0.8):
    return HRFlowable(width="100%", thickness=thickness, color=color, spaceAfter=4, spaceBefore=4)

def sp(h=6):
    return Spacer(1, h)

def bullet(text, style=style_bullet):
    return Paragraph(f"\u2022  {text}", style)

def subbullet(text):
    return Paragraph(f"\u2013  {text}", style_subbullet)

def numbered(n, text):
    return Paragraph(f"{n}.  {text}", style_numbered)

def chapter_header(num, title, subtitle=""):
    """A full-width coloured chapter header block."""
    rows = [[Paragraph(f"Chapter {num}", style_ch_num)],
            [Paragraph(title, style_ch_title)]]
    if subtitle:
        rows.append([Paragraph(subtitle, S("ChSub",
            fontSize=11, textColor=HexColor("#B0CCEE"), fontName="Helvetica-Oblique",
            alignment=TA_CENTER, leading=16))])
    t = Table(rows, colWidths=[CONTENT_W])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), DARK_NAVY),
        ("ROWBACKGROUNDS", (0,0), (-1,-1), [DARK_NAVY]),
        ("TOPPADDING",    (0,0), (-1,-1), 14),
        ("BOTTOMPADDING", (0,0), (-1,-1), 14),
        ("LEFTPADDING",   (0,0), (-1,-1), 12),
        ("RIGHTPADDING",  (0,0), (-1,-1), 12),
        ("ROUNDEDCORNERS", [8]),
    ]))
    return t

def section_title(text, color=MID_BLUE):
    bar = Table([[Paragraph(text, S("SecTitle",
        fontSize=13, textColor=WHITE, fontName="Helvetica-Bold",
        leading=18, leftIndent=4))]],
        colWidths=[CONTENT_W])
    bar.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), color),
        ("TOPPADDING",    (0,0), (-1,-1), 6),
        ("BOTTOMPADDING", (0,0), (-1,-1), 6),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("RIGHTPADDING",  (0,0), (-1,-1), 10),
    ]))
    return bar

def callout_box(title, items, bg=TEAL_LIGHT, border=TEAL):
    """A highlighted callout/info box."""
    content = [Paragraph(title, style_box_title)]
    for item in items:
        content.append(Paragraph(f"\u2022  {item}", style_box_body))
    t = Table([[content]], colWidths=[CONTENT_W])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("BOX",        (0,0), (-1,-1), 1.2, border),
        ("TOPPADDING",    (0,0), (-1,-1), 8),
        ("BOTTOMPADDING", (0,0), (-1,-1), 8),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("RIGHTPADDING",  (0,0), (-1,-1), 10),
    ]))
    return t

def memory_box(title, items):
    return callout_box(title, items, bg=GOLD_LIGHT, border=GOLD)

def clinical_box(title, items):
    return callout_box(title, items, bg=GREEN_LIGHT, border=GREEN)

def pathway_table(headers, rows, col_widths=None):
    """Styled pathway/comparison table."""
    if col_widths is None:
        n = len(headers)
        col_widths = [CONTENT_W/n]*n
    data = [headers] + rows
    t = Table(data, colWidths=col_widths, repeatRows=1)
    style = [
        ("BACKGROUND", (0,0), (-1,0), MID_BLUE),
        ("TEXTCOLOR",  (0,0), (-1,0), WHITE),
        ("FONTNAME",   (0,0), (-1,0), "Helvetica-Bold"),
        ("FONTSIZE",   (0,0), (-1,0), 10),
        ("ALIGN",      (0,0), (-1,0), "CENTER"),
        ("ROWBACKGROUNDS", (0,1), (-1,-1), [WHITE, LIGHT_BLUE]),
        ("FONTNAME",   (0,1), (-1,-1), "Helvetica"),
        ("FONTSIZE",   (0,1), (-1,-1), 9.5),
        ("ALIGN",      (0,1), (-1,-1), "LEFT"),
        ("VALIGN",     (0,0), (-1,-1), "MIDDLE"),
        ("GRID",       (0,0), (-1,-1), 0.5, GRAY_LINE),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 7),
        ("RIGHTPADDING",  (0,0), (-1,-1), 7),
    ]
    t.setStyle(TableStyle(style))
    return t

# ── Page templates (header/footer) ───────────────────────────────────────────

def on_page(canvas, doc):
    canvas.saveState()
    pg = doc.page
    # header bar
    canvas.setFillColor(DARK_NAVY)
    canvas.rect(1.8*cm, H - 1.4*cm, CONTENT_W, 0.55*cm, fill=1, stroke=0)
    canvas.setFont("Helvetica-Bold", 8)
    canvas.setFillColor(WHITE)
    canvas.drawString(2.1*cm, H - 1.1*cm, "SPECIAL SENSES — COMPREHENSIVE STUDY GUIDE")
    canvas.drawRightString(W - 1.8*cm, H - 1.1*cm, "Orris Medical  |  Physiology")
    # footer
    canvas.setFillColor(GRAY_LINE)
    canvas.rect(1.8*cm, 1.3*cm, CONTENT_W, 0.04*cm, fill=1, stroke=0)
    canvas.setFont("Helvetica", 8)
    canvas.setFillColor(HexColor("#8090A0"))
    canvas.drawCentredString(W/2, 1.0*cm, f"Page {pg}")
    canvas.restoreState()

def on_cover(canvas, doc):
    # No header/footer on cover
    pass

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

# ════════════════════════════════════════════════════════
# COVER PAGE
# ════════════════════════════════════════════════════════
# Full-page navy background
cover_bg = Table([
    [Paragraph("", style_cover_title)],
], colWidths=[CONTENT_W], rowHeights=[2*cm])
cover_bg.setStyle(TableStyle([("BACKGROUND",(0,0),(-1,-1), DARK_NAVY)]))

# Cover box
cover_inner = [
    sp(40),
    Table([[Paragraph("✦  PHYSIOLOGY  ✦", style_cover_tag)]], colWidths=[CONTENT_W]),
    sp(16),
    Table([[Paragraph("SPECIAL SENSES", style_cover_title)]], colWidths=[CONTENT_W]),
    sp(8),
    Table([[Paragraph("Comprehensive Study Guide", style_cover_sub)]], colWidths=[CONTENT_W]),
    sp(6),
    Table([[Paragraph("All Pathways · Mechanisms · Clinical Applications", style_cover_tag)]], colWidths=[CONTENT_W]),
    sp(30),
    hr(GOLD, 1.5),
    sp(14),
    Table([[Paragraph(
        "Auditory  •  Visual  •  Taste  •  Olfactory  •  Hearing  •  Colour Vision",
        S("CovList", fontSize=11, textColor=LIGHT_BLUE, fontName="Helvetica",
          alignment=TA_CENTER, leading=18)
    )]], colWidths=[CONTENT_W]),
    sp(14),
    hr(GOLD, 1.5),
    sp(30),
    Table([[Paragraph("For MBBS / MD Examinations  |  5 & 10 Mark Questions",
        S("CovExam", fontSize=10, textColor=HexColor("#A8C4E8"), fontName="Helvetica-Oblique",
          alignment=TA_CENTER, leading=16)
    )]], colWidths=[CONTENT_W]),
    sp(10),
    Table([[Paragraph("Sources: Ganong's 26th Ed. · Junqueira's 17th Ed. · Neuroscience 5th Ed.",
        style_source
    )]], colWidths=[CONTENT_W]),
]
for fl in cover_inner:
    story.append(fl)

story.append(PageBreak())

# ════════════════════════════════════════════════════════
# TABLE OF CONTENTS
# ════════════════════════════════════════════════════════
story.append(sp(8))
story.append(Paragraph("TABLE OF CONTENTS", style_toc_head))
story.append(hr(MID_BLUE, 1.5))
story.append(sp(6))

toc_entries = [
    ("1", "Auditory Pathway", "Central auditory pathway, tonotopy, cortical areas"),
    ("2", "Visual Pathway & Defects", "Optic nerve to cortex, field defects"),
    ("3", "Taste Pathway", "Cranial nerves, NTS, cortex"),
    ("4", "Olfactory Pathway", "Transduction, bulb, cortical projections"),
    ("5", "Middle Ear Functions", "Impedance matching, ossicular chain, Eustachian tube"),
    ("6", "Theories of Hearing", "Place, Frequency, Volley theories"),
    ("7", "Theories of Colour Vision", "Trichromatic, Opponent, Zone theory"),
    ("8", "Phototransduction", "Rhodopsin cycle, cGMP cascade, rods & cones"),
    ("9", "Dark Adaptation", "Two phases, rhodopsin regeneration, Purkinje shift"),
    ("10", "Light Reflex Pathway", "Afferent, pretectal, efferent limbs"),
    ("11", "Accommodation Reflex", "Near response, ciliary muscle, clinical"),
    ("12", "Endocochlear Potential", "Stria vascularis, K+ gradient, 80 mV"),
    ("13", "Physiology of Taste", "5 modalities, receptor mechanisms, depolarisation"),
    ("14", "Physiology of Smell", "Transduction, cAMP pathway, anosmia"),
    ("15", "Physiology of Hearing", "Hair cells, basilar membrane, organ of Corti"),
]
for num, title, desc in toc_entries:
    row_data = [
        [Paragraph(f"<font color='#2E5FA3'><b>{num}.</b></font>  {title}", S("TOCTitle",
            fontSize=11, textColor=DARK_NAVY, fontName="Helvetica-Bold", leading=16)),
         Paragraph(desc, S("TOCDesc",
            fontSize=9.5, textColor=HexColor("#556070"), fontName="Helvetica-Oblique", leading=14))],
    ]
    t = Table(row_data, colWidths=[5.5*cm, CONTENT_W - 5.5*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), GRAY_BG),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 8),
        ("RIGHTPADDING",  (0,0), (-1,-1), 8),
        ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ]))
    story.append(t)
    story.append(sp(3))

story.append(PageBreak())

# ════════════════════════════════════════════════════════
# CHAPTER 1 – AUDITORY PATHWAY
# ════════════════════════════════════════════════════════
story.append(chapter_header("1", "AUDITORY PATHWAY", "Central pathway from cochlea to auditory cortex"))
story.append(sp(10))

story.append(section_title("Overview"))
story.append(sp(4))
story.append(Paragraph(
    "Sound waves → Hair cells (Organ of Corti) → Cochlear nerve (CN VIII) → "
    "Cochlear nuclei → Superior olive → Lateral lemniscus → Inferior colliculus → "
    "Medial Geniculate Body → Auditory Cortex.",
    style_body))
story.append(sp(6))

story.append(Paragraph("Step-by-Step Pathway", style_h1))
steps = [
    ("Hair Cells / Organ of Corti",
     "Mechanotransduction: stereocilia deflection → K⁺ influx → depolarisation → glutamate release → CN VIII action potentials."),
    ("Cochlear Nerve (CN VIII)",
     "Enters brainstem at the pontomedullary junction. Bifurcates to end in dorsal and ventral cochlear nuclei (medulla)."),
    ("Cochlear Nuclei (Medulla)",
     "First synapse. Responses are similar to individual auditory nerve fibres. Second-order neurons show sharper low-frequency cutoff due to brainstem inhibition."),
    ("Superior Olivary Nucleus (Pons)",
     "First site of BINAURAL convergence (inputs from both ears). Critical for sound localisation — detects interaural time & intensity differences."),
    ("Lateral Lemniscus",
     "Ascending tract carrying auditory fibres rostrally; most fibres have already crossed the midline."),
    ("Inferior Colliculus (Midbrain tectum)",
     "Centre for auditory REFLEXES (e.g., head-turning toward sound). All ascending fibres synapse here."),
    ("Medial Geniculate Body / MGB (Thalamus)",
     "Thalamic relay station for auditory signals. Projects via auditory radiations to the cortex."),
    ("Primary Auditory Cortex — A1",
     "Superior temporal gyrus (Heschl's gyrus), Brodmann areas 41 & 42. Tonotopic: low tones anterolateral, high tones posteromedial."),
]
for i, (title, desc) in enumerate(steps, 1):
    story.append(numbered(i, f"<b>{title}:</b>  {desc}"))
story.append(sp(6))

story.append(Paragraph("Key Features", style_h2))
story.append(bullet("Decussation: Most fibres cross at the trapezoid body (pons); hence each auditory cortex receives bilateral input."))
story.append(bullet("Tonotopic organisation preserved from cochlea all the way to cortex."))
story.append(bullet("Hemispheric specialisation: Wernicke area (left) — speech; Right hemisphere — melody, pitch, sound intensity."))
story.append(bullet("Auditory cortex is highly plastic: sign language activates auditory areas in pre-lingually deaf individuals."))
story.append(sp(6))

story.append(memory_box("MNEMONIC: Auditory pathway stations",
    ["Cochlear nerve (CN VIII)",
     "Cochlear Nuclei (dorsal & ventral)",
     "Superior Olive — binaural convergence",
     "Inferior Colliculus — auditory reflexes",
     "Medial Geniculate Body (thalamus)",
     "Auditory Cortex (superior temporal gyrus)"]))
story.append(sp(8))

story.append(Paragraph("Hearing Loss", style_h2))
story.append(pathway_table(
    ["Type", "Site", "Character", "Tuning Fork Tests"],
    [["Sensorineural", "Cochlear hair cells / CN VIII / central", "Frequency-specific loss",
      "Rinne +ve (AC>BC); Weber lateralises to GOOD ear"],
     ["Conductive", "External or middle ear", "Affects all frequencies equally",
      "Rinne -ve (BC>AC); Weber lateralises to AFFECTED ear"]],
    col_widths=[3.2*cm, 4.2*cm, 4.5*cm, 4.5*cm]
))
story.append(sp(4))
story.append(Paragraph("Sources: Ganong's Review of Medical Physiology, 26th Ed.", style_source))
story.append(PageBreak())

# ════════════════════════════════════════════════════════
# CHAPTER 2 – VISUAL PATHWAY & DEFECTS
# ════════════════════════════════════════════════════════
story.append(chapter_header("2", "VISUAL PATHWAY & DEFECTS",
    "Retina → Optic nerve → Chiasma → LGB → Visual cortex"))
story.append(sp(10))

story.append(section_title("Pathway"))
story.append(sp(4))
steps_vis = [
    ("Retina", "Photoreceptors → Bipolar cells → Ganglion cells. Axons of ganglion cells form the optic nerve (~1.2 million fibres per nerve)."),
    ("Optic Nerve (CN II)", "Carries all visual information from one eye."),
    ("Optic Chiasma", "PARTIAL decussation: Nasal (medial) retinal fibres cross; Temporal fibres stay ipsilateral. Lesion here → bitemporal hemianopia."),
    ("Optic Tract", "Each tract carries: ipsilateral temporal + contralateral nasal retinal fibres → represents CONTRALATERAL visual field."),
    ("Lateral Geniculate Body / LGB (Thalamus)", "Main thalamic relay. 6 layers: layers 1,2 = magnocellular (M-pathway, motion/depth); layers 3-6 = parvocellular (P-pathway, colour/detail)."),
    ("Optic Radiations (Geniculocalcarine tract)", "Upper fibres → parietal lobe → inferior calcarine cortex (lower visual field). Lower fibres = Meyer's loop → temporal lobe → superior calcarine cortex (upper visual field)."),
    ("Primary Visual Cortex — V1 (Area 17)", "Calcarine fissure of occipital lobe. Retinotopic map: macula over-represented posteriorly (dual blood supply → macular sparing in occipital lesions)."),
]
for i, (t, d) in enumerate(steps_vis, 1):
    story.append(numbered(i, f"<b>{t}:</b>  {d}"))
story.append(sp(8))

story.append(section_title("Visual Field Defects"))
story.append(sp(4))
story.append(pathway_table(
    ["Lesion Site", "Defect", "Notes"],
    [["Optic nerve (1 eye)", "Monocular blindness", "Same eye only"],
     ["Optic chiasma — central (e.g. pituitary tumour)", "Bitemporal hemianopia", "Nasal fibres from both eyes cut"],
     ["Optic tract", "Contralateral homonymous hemianopia", "Incongruous (unequal)"],
     ["Meyer's loop (temporal lobe)", "Contralateral upper quadrantanopia", "'Pie-in-the-sky' defect"],
     ["Upper optic radiation (parietal lobe)", "Contralateral lower quadrantanopia", "'Pie-on-the-floor'"],
     ["Complete optic radiation or V1", "Contralateral homonymous hemianopia", "Macular sparing (occipital)"]],
    col_widths=[5.5*cm, 5.5*cm, 4.5*cm]
))
story.append(sp(6))
story.append(clinical_box("Clinical Pearl — Macular Sparing",
    ["Lesions of the occipital cortex spare central (macular) vision.",
     "Reason: Macular cortex at the occipital pole has a dual blood supply (MCA + PCA).",
     "This differentiates occipital lesions from optic tract lesions (which do NOT spare macula)."]))
story.append(sp(4))
story.append(Paragraph("Sources: Ganong's 26th Ed.; Gray's Anatomy for Students", style_source))
story.append(PageBreak())

# ════════════════════════════════════════════════════════
# CHAPTER 3 – TASTE PATHWAY
# ════════════════════════════════════════════════════════
story.append(chapter_header("3", "TASTE PATHWAY",
    "Gustatory pathway from tongue to cortex"))
story.append(sp(10))

story.append(section_title("Peripheral Cranial Nerves"))
story.append(sp(4))
story.append(pathway_table(
    ["Region", "Cranial Nerve", "Branch", "Nucleus"],
    [["Anterior 2/3 tongue", "CN VII (Facial)", "Chorda tympani", "NTS"],
     ["Posterior 1/3 tongue", "CN IX (Glossopharyngeal)", "Lingual branch", "NTS"],
     ["Epiglottis & pharynx", "CN X (Vagus)", "Superior laryngeal nerve", "NTS"]],
    col_widths=[3.5*cm, 3.5*cm, 4.5*cm, 4*cm]
))
story.append(sp(8))

story.append(section_title("Central Pathway"))
story.append(sp(4))
central_steps = [
    "CN VII, IX, X → Nucleus of Tractus Solitarius (NTS), rostral gustatory nucleus, medulla",
    "NTS → Central tegmental tract → Ventral Posteromedial (VPM) nucleus of thalamus (medial part)",
    "VPM → Primary Gustatory Cortex: anterior insula + adjacent frontal operculum (area 43)",
    "Also projects to Orbitofrontal Cortex — conscious taste perception, food reward, flavour",
]
for i, s in enumerate(central_steps, 1):
    story.append(numbered(i, s))
story.append(sp(6))

story.append(memory_box("Note on Decussation",
    ["Unlike other sensory pathways, the gustatory pathway does NOT completely decussate.",
     "There is BILATERAL cortical representation of taste.",
     "Therefore, unilateral cortical lesions rarely cause complete ageusia."]))
story.append(sp(8))

story.append(section_title("Five Basic Taste Modalities"))
story.append(sp(4))
story.append(pathway_table(
    ["Taste", "Stimulus", "Receptor Mechanism", "Depolarisation Pathway"],
    [["Salty", "Na⁺", "Amiloride-sensitive ENaC channels", "Direct Na⁺ influx → depolarisation"],
     ["Sour", "H⁺ (acid)", "H⁺ blocks K⁺ channels; H⁺-gated channels", "Reduced K⁺ efflux → depolarisation"],
     ["Bitter", "Various toxins", "T2R GPCRs → gustducin → ↑IP₃ → ↑Ca²⁺", "Ca²⁺ from ER → vesicle release"],
     ["Sweet", "Sugars", "T1R2+T1R3 GPCRs → ↑cAMP → PKA", "Closes K⁺ channels → depolarisation"],
     ["Umami", "Glutamate", "T1R1+T1R3 GPCRs → similar to sweet", "↑cAMP → depolarisation"]],
    col_widths=[2.0*cm, 2.5*cm, 5.5*cm, 5.5*cm]
))
story.append(sp(4))
story.append(Paragraph("Sources: Ganong's 26th Ed.", style_source))
story.append(PageBreak())

# ════════════════════════════════════════════════════════
# CHAPTER 4 – OLFACTORY PATHWAY
# ════════════════════════════════════════════════════════
story.append(chapter_header("4", "OLFACTORY PATHWAY",
    "From olfactory epithelium to orbitofrontal cortex"))
story.append(sp(10))

story.append(section_title("Key Features of Olfactory Neurons"))
story.append(sp(4))
for b in [
    "Only cranial nerve that projects DIRECTLY to cortex WITHOUT first synapsing in thalamus",
    "Receptor neurons are TRUE BIPOLAR NEURONS (not modified epithelial cells, unlike taste)",
    "Unique ability to REGENERATE (lifespan ~30-60 days, replaced from basal cells)",
    "~400 functional olfactory receptor genes in humans; ~1000 in rodents",
    "Each neuron expresses only ONE type of odorant receptor",
    "Each odorant activates a pattern of multiple receptor types (combinatorial coding)",
]:
    story.append(bullet(b))
story.append(sp(6))

story.append(section_title("Pathway"))
story.append(sp(4))
olf_steps = [
    ("Olfactory Sensory Neurons", "In olfactory epithelium (roof of nasal cavity). Dendrites project as cilia into mucus layer. Axons form CN I (olfactory nerve)."),
    ("Cribriform Plate", "Axons pass through foramina in the cribriform plate of the ethmoid bone to reach the olfactory bulb. (Fracture here → anosmia / CSF rhinorrhoea)"),
    ("Olfactory Bulb", "Axons synapse on mitral cells & tufted cells forming OLFACTORY GLOMERULI. Each glomerulus receives neurons with the same receptor type → odorant-specific 2D map. Periglomerular & granule cells provide lateral inhibition (sharpening)."),
    ("Lateral Olfactory Stria", "Axons of mitral/tufted cells travel to 5 areas of the primary olfactory cortex."),
    ("Primary Olfactory Cortex", "5 regions: (a) Anterior olfactory nucleus, (b) Olfactory tubercle, (c) Piriform cortex (main), (d) Amygdala (emotional responses), (e) Entorhinal cortex (olfactory memory)"),
    ("Higher Cortex", "Piriform cortex / entorhinal → Orbitofrontal cortex (via thalamus) → conscious odour discrimination. Amygdala → emotional/fear responses to odours. Entorhinal → hippocampus → olfactory memories."),
]
for i, (t, d) in enumerate(olf_steps, 1):
    story.append(numbered(i, f"<b>{t}:</b>  {d}"))
story.append(sp(6))

story.append(section_title("Transduction Mechanism"))
story.append(sp(4))
trans_steps = [
    "Odorant binds to G-protein-coupled olfactory receptor",
    "Activates Golf (olfactory Gs-type G-protein)",
    "Golf activates Adenylyl cyclase III → ↑cAMP",
    "cAMP opens cAMP-gated cation channels (CNG channels) → Na⁺ & Ca²⁺ influx",
    "Ca²⁺ also opens Ca²⁺-activated Cl⁻ channels → amplifies depolarisation",
    "Action potential generated in olfactory neuron → CN I",
]
for i, s in enumerate(trans_steps, 1):
    story.append(numbered(i, s))
story.append(sp(6))

story.append(clinical_box("Clinical — Anosmia",
    ["Loss of smell; can be unilateral or bilateral.",
     "Causes: Cribriform plate fracture (shearing CN I), viral infection (COVID-19, flu), Zinc deficiency, Kallmann syndrome (anosmia + hypogonadism).",
     "Early sign in Parkinson's and Alzheimer's disease (before motor symptoms).",
     "Kallmann syndrome: GnRH neurons fail to migrate from olfactory placode → hypogonadotropic hypogonadism + anosmia."]))
story.append(sp(4))
story.append(Paragraph("Sources: Ganong's 26th Ed.; Eric Kandel Principles of Neural Science, 6th Ed.", style_source))
story.append(PageBreak())

# ════════════════════════════════════════════════════════
# CHAPTER 5 – MIDDLE EAR FUNCTIONS
# ════════════════════════════════════════════════════════
story.append(chapter_header("5", "MIDDLE EAR FUNCTIONS",
    "Sound conduction, impedance matching & protection"))
story.append(sp(10))

story.append(Paragraph("Structure of the Middle Ear", style_h1))
story.append(bullet("Air-filled space in the temporal bone; lined by mucosa."))
story.append(bullet("Contains the ossicular chain: Malleus → Incus → Stapes."))
story.append(bullet("The stapes footplate articulates with the oval window of the cochlea."))
story.append(bullet("Divided into: Hypotympanum, Mesotympanum, and Epitympanum."))
story.append(sp(6))

story.append(section_title("Functions"))
story.append(sp(4))
functions = [
    ("1. Impedance Matching (Most important)",
     ["Air and cochlear fluid have very different acoustic impedances.",
      "Without the middle ear, ~99.9% of sound energy would be reflected at the air-fluid interface (30 dB loss).",
      "Middle ear achieves ~22-fold (25-30 dB) pressure amplification via:",
      "Area effect: Tympanic membrane area (~55 mm²) >> Oval window area (~3.2 mm²) → ratio ~17:1",
      "Lever action of ossicles: Malleus arm > Incus arm → additional ~1.3:1 amplification",
      "Total amplification = 17 × 1.3 ≈ 22× (~25 dB)"]),
    ("2. Sound Conduction",
     ["Sound waves → Tympanic membrane vibrates → Malleus → Incus → Stapes footplate",
      "Stapes pushes on oval window → pressure wave in perilymph of scala vestibuli",
      "Waves travel up scala vestibuli → displace Reissner's membrane & basilar membrane",
      "Round window acts as pressure-release valve (compensatory bulge)"]),
    ("3. Acoustic Reflex (Attenuation Reflex)",
     ["Loud sounds (>80 dB) trigger contraction of Stapedius (CN VII) and Tensor tympani (CN V).",
      "Stiffens the ossicular chain → reduces transmission of LOW-frequency sounds.",
      "Protects cochlea from loud sustained noise. Latency ~150 ms — too slow to protect from sudden loud sounds (gunshot).",
      "Loss of stapedius reflex → Hyperacusis (sounds seem too loud) in Bell's palsy."]),
    ("4. Eustachian (Auditory) Tube",
     ["Connects middle ear to nasopharynx; normally collapsed, opens during swallowing/yawning.",
      "Functions: Equalises middle ear pressure with atmosphere; drains secretions.",
      "Tensor veli palatini muscle opens the tube (CN V).",
      "Dysfunction → negative pressure in middle ear → serous otitis media, retracted TM."]),
    ("5. Round Window",
     ["Membrane-covered opening between middle and inner ear on the scala tympani side.",
      "When the oval window moves in, round window moves out — allows cochlear fluid to move.",
      "Without this pressure relief, sound transmission through the cochlea would be impossible."]),
]
for title, pts in functions:
    story.append(Paragraph(title, style_h2))
    for p in pts:
        story.append(bullet(p))
    story.append(sp(4))

story.append(Paragraph("Sources: Cummings Otolaryngology, 6th Ed.; Ganong's 26th Ed.", style_source))
story.append(PageBreak())

# ════════════════════════════════════════════════════════
# CHAPTER 6 – THEORIES OF HEARING
# ════════════════════════════════════════════════════════
story.append(chapter_header("6", "THEORIES OF HEARING",
    "How the cochlea analyses frequency"))
story.append(sp(10))

theories = [
    ("A. Place Theory (Resonance / Travelling Wave Theory)",
     "Helmholtz (1857); refined by von Bekesy (Nobel Prize 1961)",
     [
         "Basilar membrane vibrates differently along its length depending on the frequency of sound.",
         "HIGH frequencies → maximal vibration at the BASE of the cochlea (narrow, stiff).",
         "LOW frequencies → maximal vibration at the APEX (wide, flexible, near helicotrema).",
         "Von Bekesy demonstrated a 'travelling wave' that peaks at a specific location for each frequency.",
         "This is the basis of TONOTOPIC organisation preserved from cochlea → cortex.",
         "BEST supported theory for frequency discrimination above 4000 Hz.",
         "Limitation: Cannot fully explain discrimination of very low frequencies.",
     ]),
    ("B. Frequency (Telephone) Theory",
     "Rutherford (1886)",
     [
         "The basilar membrane vibrates as a whole at the same frequency as the incoming sound.",
         "Nerve fibres fire at the same frequency as the sound → brain interprets frequency.",
         "Limitation: Nerve fibres cannot fire faster than ~1000 Hz (absolute refractory period ~1 ms).",
         "Cannot explain hearing frequencies up to 20,000 Hz.",
         "Works only for very low frequencies (<400 Hz).",
     ]),
    ("C. Volley Theory",
     "Wever & Bray (1937)",
     [
         "Modification of frequency theory: Groups of nerve fibres fire in TURNS (volleys).",
         "While one group is in its refractory period, another fires → combined discharge matches sound frequency.",
         "Extends the frequency range of neural coding up to ~4000 Hz.",
         "Above 4000 Hz, place theory dominates.",
     ]),
]
for name, author, pts in theories:
    story.append(Paragraph(name, style_h2))
    story.append(Paragraph(f"Proposed by: <i>{author}</i>", style_box_body))
    for p in pts:
        story.append(bullet(p))
    story.append(sp(5))

story.append(memory_box("Current Understanding — Combined Theory",
    ["< 400 Hz → Frequency / Volley Theory (firing rate encodes frequency)",
     "400 – 4000 Hz → Volley Theory (groups of fibres fire in volleys)",
     "> 4000 Hz → Place Theory (location of maximal basilar membrane vibration)",
     "Place theory governs most of the human hearing range (up to 20,000 Hz)"]))
story.append(sp(4))
story.append(Paragraph("Sources: Ganong's 26th Ed.; Neuroscience: Exploring the Brain, 5th Ed.", style_source))
story.append(PageBreak())

# ════════════════════════════════════════════════════════
# CHAPTER 7 – THEORIES OF COLOUR VISION
# ════════════════════════════════════════════════════════
story.append(chapter_header("7", "THEORIES OF COLOUR VISION",
    "Trichromatic theory, opponent process theory & zone theory"))
story.append(sp(10))

story.append(Paragraph("A. Young-Helmholtz Trichromatic Theory", style_h2))
story.append(Paragraph("Thomas Young (1801), Hermann von Helmholtz (1850s)", style_box_body))
story.append(sp(3))
for b in [
    "Three types of cone photoreceptors, each with maximum sensitivity at a different wavelength:",
    "All colours perceived by combining outputs of these three cone types.",
    "Explains colour mixing and colour blindness.",
]:
    story.append(bullet(b))
story.append(pathway_table(
    ["Cone Type", "Peak Wavelength", "Perceived Colour", "Opsin Gene"],
    [["S-cones (Short)", "~420 nm", "Blue/Violet", "OPN1SW (autosome)"],
     ["M-cones (Medium)", "~530 nm", "Green", "OPN1MW (X-linked)"],
     ["L-cones (Long)", "~560 nm", "Red/Yellow", "OPN1LW (X-linked)"]],
    col_widths=[3*cm, 3.5*cm, 3.5*cm, 5.5*cm]
))
story.append(sp(4))

story.append(Paragraph("B. Hering's Opponent Colour Theory", style_h2))
story.append(Paragraph("Ewald Hering (1878)", style_box_body))
story.append(sp(3))
for b in [
    "Colour is processed in OPPONENT PAIRS — each channel signals one or the other, not both:",
    "Pair 1: Red ↔ Green (excitatory-inhibitory)",
    "Pair 2: Blue ↔ Yellow",
    "Pair 3: Black ↔ White (luminance channel)",
    "Explains colour AFTERIMAGES: After staring at red, you see green (opponent rebound).",
    "Explains why 'reddish-green' and 'yellowish-blue' colours do not exist.",
    "Explains simultaneous colour contrast.",
]:
    story.append(bullet(b))
story.append(sp(6))

story.append(Paragraph("C. Zone Theory (Stage Theory) — Modern Combined Approach", style_h2))
story.append(Paragraph("Both theories are correct at different stages of the visual pathway:", style_body))
story.append(pathway_table(
    ["Stage", "Location", "Theory Operating", "Mechanism"],
    [["Stage 1", "Photoreceptors (retina)", "Trichromatic", "3 cone types absorb light based on wavelength"],
     ["Stage 2", "Retinal ganglion cells & LGB", "Opponent Process", "Ganglion cells: centre-surround colour opponency (R+G-, G+R-, B+Y-)"],
     ["Stage 3", "Visual cortex (V1, V4)", "Complex colour processing", "Double-opponent cells; colour constancy in V4"]],
    col_widths=[2.2*cm, 3.8*cm, 3.5*cm, 5.9*cm]
))
story.append(sp(6))

story.append(clinical_box("Colour Blindness",
    ["Protanopia: Missing L (red) cones — cannot distinguish red/green",
     "Deuteranopia: Missing M (green) cones — most common form of colour blindness",
     "Tritanopia: Missing S (blue) cones — rare, autosomal; cannot distinguish blue/yellow",
     "Red-green colour blindness: X-linked recessive; 8% of males, 0.5% of females",
     "Achromatopsia (monochromacy): Complete absence of colour vision, all cones absent; extremely rare"]))
story.append(sp(4))
story.append(Paragraph("Sources: Ganong's 26th Ed.; Neuroscience: Exploring the Brain, 5th Ed.", style_source))
story.append(PageBreak())

# ════════════════════════════════════════════════════════
# CHAPTER 8 – PHOTOTRANSDUCTION
# ════════════════════════════════════════════════════════
story.append(chapter_header("8", "PHOTOTRANSDUCTION",
    "Conversion of light into electrical signal"))
story.append(sp(10))

story.append(section_title("The Rhodopsin Molecule"))
story.append(sp(4))
for b in [
    "Rhodopsin = Retinal (chromophore, vitamin A derivative) + Opsin (7-transmembrane GPCR protein, 41 kDa)",
    "Located in the membranous discs of rod outer segments; makes up 90% of total disc protein",
    "One rod contains ~1 BILLION rhodopsin molecules",
    "Retinal is attached to opsin at Lysine-296 in the 7th transmembrane domain",
    "Cones use iodopsins (photopsins): L-opsin (red), M-opsin (green), S-opsin (blue)",
]:
    story.append(bullet(b))
story.append(sp(6))

story.append(section_title("In DARKNESS — The Dark Current"))
story.append(sp(4))
for b in [
    "Phosphodiesterase (PDE) activity is LOW → cGMP levels are HIGH",
    "High cGMP keeps cGMP-gated Na⁺/Ca²⁺ channels OPEN in the outer segment",
    "Na⁺ and Ca²⁺ continuously enter → cell is DEPOLARISED (~−40 mV)",
    "This inward current is called the DARK CURRENT",
    "Depolarised cell continuously releases GLUTAMATE at synapse with bipolar cells",
]:
    story.append(bullet(b))
story.append(sp(6))

story.append(section_title("When LIGHT Hits — The Phototransduction Cascade"))
story.append(sp(4))
cascade_steps = [
    "Photon absorbed by 11-cis-retinal → isomerises to ALL-TRANS-RETINAL (within 1 picosecond)",
    "Conformational change in opsin → ACTIVE opsin (Metarhodopsin II / R*)",
    "R* activates TRANSDUCIN (Gt protein) → GDP exchanged for GTP → α-subunit released",
    "α-subunit activates PHOSPHODIESTERASE (PDE)",
    "PDE hydrolyses cGMP → 5'-GMP → intracellular cGMP FALLS",
    "cGMP-gated channels CLOSE → less Na⁺/Ca²⁺ entry → cell HYPERPOLARISES (~−70 mV)",
    "Reduced GLUTAMATE release → change in bipolar cell activity → ganglion cell → optic nerve",
    "Ca²⁺ also decreases → removes negative feedback on guanylyl cyclase → cGMP regeneration begins (adaptation)",
]
for i, s in enumerate(cascade_steps, 1):
    story.append(numbered(i, s))
story.append(sp(6))

story.append(section_title("Signal Termination & Recovery"))
story.append(sp(4))
for b in [
    "Rhodopsin kinase phosphorylates active opsin → β-arrestin binds → terminates transducin activation",
    "All-trans-retinal detaches from opsin ('bleaching') → moves to pigment epithelium",
    "Retinal isomerase converts all-trans → 11-cis-retinal → transported back to rod",
    "11-cis-retinal recombines with opsin → rhodopsin restored",
    "Rate of rhodopsin regeneration determines the rate of dark adaptation",
]:
    story.append(bullet(b))
story.append(sp(6))

story.append(memory_box("Rods vs. Cones — Quick Comparison",
    ["RODS: 120 million/eye; periphery; scotopic vision (dim light); 1 type; very sensitive (respond to single photon); no colour; convergent pathway",
     "CONES: 6 million/eye; fovea; photopic vision (bright light); 3 types (L/M/S); low sensitivity; colour vision; point-to-point pathway (high acuity)",
     "Fovea: contains ONLY cones; each cone → 1 bipolar → 1 ganglion cell → highest visual acuity",
     "Outer hair cells: Active amplification (electromotility, prestin protein) → cochlear amplifier"]))
story.append(sp(4))
story.append(Paragraph("Sources: Ganong's 26th Ed.; Junqueira's Basic Histology, 17th Ed.", style_source))
story.append(PageBreak())

# ════════════════════════════════════════════════════════
# CHAPTER 9 – DARK ADAPTATION
# ════════════════════════════════════════════════════════
story.append(chapter_header("9", "DARK ADAPTATION",
    "Increasing retinal sensitivity in the dark"))
story.append(sp(10))

story.append(Paragraph("Definition", style_h1))
story.append(Paragraph(
    "Dark adaptation is the progressive decrease in visual threshold (increase in sensitivity) "
    "that occurs when a person moves from a brightly lit to a dark environment. "
    "It takes approximately 20 minutes to become nearly maximal.",
    style_body))
story.append(sp(6))

story.append(section_title("Two Phases of Dark Adaptation"))
story.append(sp(4))
story.append(pathway_table(
    ["Phase", "Photoreceptor", "Time Course", "Magnitude", "Mechanism"],
    [["Phase 1 (fast)", "Cones", "0–8 minutes", "Small drop in threshold",
      "Regeneration of cone iodopsins"],
     ["Phase 2 (slow)", "Rods", "8–20+ minutes", "Large drop in threshold (~10,000×)",
      "Slow regeneration of rhodopsin from vitamin A"]],
    col_widths=[2.5*cm, 2.5*cm, 3*cm, 3.5*cm, 4.9*cm]
))
story.append(sp(6))

story.append(Paragraph("The Duplicity Theory and Purkinje Shift", style_h1))
for b in [
    "In photopic (bright) conditions, CONES are active; peak spectral sensitivity ~555 nm (yellow-green).",
    "In scotopic (dim) conditions, RODS are active; peak spectral sensitivity shifts to ~505 nm (blue-green).",
    "This shift in spectral sensitivity with illumination is called the PURKINJE SHIFT.",
    "Clinically: red objects appear relatively darker in dim light than blue-green objects.",
]:
    story.append(bullet(b))
story.append(sp(6))

story.append(section_title("Mechanism of Rhodopsin Regeneration"))
story.append(sp(4))
for b in [
    "In bright light, rhodopsin is continuously BLEACHED (11-cis-retinal → all-trans-retinal → released from opsin).",
    "In darkness, all-trans-retinal is transported to the pigment epithelium.",
    "Retinal isomerase converts it back to 11-cis-retinal.",
    "11-cis-retinal returns to the rod outer segment and recombines with opsin → rhodopsin.",
    "The rate of rhodopsin regeneration is the rate-limiting step for dark adaptation.",
    "Vitamin A deficiency → insufficient retinal → impaired rhodopsin synthesis → night blindness (nyctalopia).",
]:
    story.append(bullet(b))
story.append(sp(6))

story.append(memory_box("Practical Application",
    ["Aircraft pilots and radiologists can maintain dark adaptation by wearing RED GOGGLES in bright light.",
     "Red light (~700 nm) stimulates L-cones (colour vision preserved) but barely stimulates rods.",
     "This allows rods to remain dark-adapted while cones are still functional for fine work.",
     "Light adaptation (bright light after dark) takes only ~5 minutes (reverse of dark adaptation)."]))
story.append(sp(4))
story.append(Paragraph("Sources: Ganong's Review of Medical Physiology, 26th Ed.", style_source))
story.append(PageBreak())

# ════════════════════════════════════════════════════════
# CHAPTER 10 – LIGHT REFLEX PATHWAY
# ════════════════════════════════════════════════════════
story.append(chapter_header("10", "LIGHT REFLEX PATHWAY",
    "Pupillary light reflex — afferent & efferent limbs"))
story.append(sp(10))

story.append(Paragraph("Definition", style_h1))
story.append(Paragraph(
    "The pupillary light reflex is the constriction of the pupil (miosis) in response to light. "
    "It has two forms: the DIRECT reflex (same eye) and the CONSENSUAL reflex (opposite eye).",
    style_body))
story.append(sp(6))

story.append(section_title("Pathway"))
story.append(sp(4))
light_reflex_steps = [
    ("Retina — Afferent", "Light → retinal photoreceptors → bipolar cells → intrinsically photosensitive retinal ganglion cells (ipRGCs, using melanopsin pigment). These are a special class of irradiance detectors distinct from visual ganglion cells."),
    ("Optic Nerve (CN II)", "Afferent fibres travel in the optic nerve."),
    ("Optic Chiasma", "Partial decussation occurs (same as visual pathway)."),
    ("Optic Tract", "Fibres travel in the optic tract but LEAVE BEFORE the LGB."),
    ("Pretectal Nucleus (Midbrain)", "Light reflex fibres branch off and synapse in the PRETECTAL NUCLEUS at the level of the superior colliculus. This is the key relay point."),
    ("Bilateral Projection", "Each pretectal nucleus sends fibres bilaterally to BOTH Edinger-Westphal (EW) nuclei — this explains the CONSENSUAL reflex."),
    ("Edinger-Westphal Nucleus — Efferent", "Preganglionic parasympathetic nucleus (accessory CN III nucleus). Preganglionic fibres travel in the oculomotor nerve (CN III)."),
    ("Ciliary Ganglion", "Postganglionic parasympathetic synapse in the orbit."),
    ("Short Ciliary Nerves", "Postganglionic fibres → SPHINCTER PUPILLAE muscle → MIOSIS (pupil constriction)."),
]
for i, (t, d) in enumerate(light_reflex_steps, 1):
    story.append(numbered(i, f"<b>{t}:</b>  {d}"))
story.append(sp(6))

story.append(section_title("Clinical Applications"))
story.append(sp(4))
story.append(pathway_table(
    ["Condition", "Finding", "Lesion / Cause"],
    [["RAPD (Marcus Gunn pupil)", "Swinging flashlight test: affected eye shows paradoxical pupil dilation", "Afferent limb lesion (optic nerve disease, e.g., optic neuritis)"],
     ["CN III palsy (Hutchinson pupil)", "Dilated, fixed pupil; no direct or consensual reflex", "Efferent limb; CN III compression (uncal herniation, posterior communicating artery aneurysm)"],
     ["Horner syndrome", "Miosis + ptosis + anhidrosis", "Sympathetic pathway lesion (any level from hypothalamus to eye)"],
     ["Argyll Robertson pupil", "No light reflex; accommodation reflex INTACT", "Pretectal lesion (classically neurosyphilis)"],
     ["Adie's tonic pupil", "Poorly reactive to light; slow to accommodate", "Ciliary ganglion degeneration; benign"]],
    col_widths=[4*cm, 4.5*cm, 7*cm]
))
story.append(sp(4))
story.append(Paragraph("Sources: Ganong's 26th Ed.; Adams & Victor's Principles of Neurology, 12th Ed.", style_source))
story.append(PageBreak())

# ════════════════════════════════════════════════════════
# CHAPTER 11 – ACCOMMODATION REFLEX
# ════════════════════════════════════════════════════════
story.append(chapter_header("11", "ACCOMMODATION REFLEX PATHWAY",
    "The near triad — accommodation, convergence & miosis"))
story.append(sp(10))

story.append(Paragraph("Definition & Components", style_h1))
story.append(Paragraph(
    "When gaze shifts from a far to a near object, three simultaneous responses occur (the 'Near Triad'):",
    style_body))
story.append(sp(3))
for b in [
    "ACCOMMODATION — lens becomes more convex (increased refractive power)",
    "CONVERGENCE — both eyes turn medially (medial rectus muscles contract)",
    "MIOSIS — pupils constrict (reduces optical aberrations, increases depth of focus)",
]:
    story.append(bullet(b))
story.append(sp(6))

story.append(section_title("Pathway"))
story.append(sp(4))
acc_steps = [
    ("Afferent — Retina", "Blurred image on retina (near object) → retinal ganglion cells → optic nerve."),
    ("Afferent — Optic pathway", "Optic nerve → chiasma → optic tract → LGB → Optic radiations → Primary visual cortex (Area 17)."),
    ("Higher cortex", "V1 → Visual association areas (Areas 18, 19) → Frontal eye fields (Area 8)."),
    ("Efferent — Midbrain", "Cortical signals descend to the pretectal area and SUPERIOR COLLICULUS → Edinger-Westphal (EW) nucleus."),
    ("Efferent — CN III", "EW nucleus → preganglionic parasympathetic fibres travel in CN III."),
    ("Ciliary Ganglion", "Synapse here; postganglionic fibres travel in short ciliary nerves."),
    ("Ciliary muscle", "Contraction of the circular ciliary muscle → RELAXES zonular fibres (suspensory ligament of lens) → lens becomes MORE CONVEX → increased refractive power."),
    ("Medial Rectus (CN III)", "Simultaneous contraction of both medial recti → CONVERGENCE."),
    ("Sphincter Pupillae", "Contraction → MIOSIS (same efferent pathway as light reflex)."),
]
for i, (t, d) in enumerate(acc_steps, 1):
    story.append(numbered(i, f"<b>{t}:</b>  {d}"))
story.append(sp(6))

story.append(Paragraph("Mechanism of Accommodation", style_h2))
for b in [
    "Ciliary body muscle = CIRCULAR/SPHINCTER type smooth muscle innervated by parasympathetics.",
    "At rest (far vision): ciliary muscle RELAXED → zonules TAUT → lens is FLAT (less powerful).",
    "Near vision: ciliary muscle CONTRACTS → zonules RELAX → lens becomes CONVEX (more powerful).",
    "Near point: closest point at which clear focus is possible; recedes with age (presbyopia).",
    "Presbyopia: At 40-45 years, lens hardness increases, reducing accommodation amplitude → reading glasses (convex lens).",
]:
    story.append(bullet(b))
story.append(sp(6))

story.append(clinical_box("Key Clinical Distinctions",
    ["Accommodation reflex pathway goes through LGB and VISUAL CORTEX (unlike light reflex, which bypasses LGB).",
     "Argyll Robertson pupil: Light reflex ABSENT; Accommodation reflex PRESENT → lesion in pretectal area (above EW nucleus), typically neurosyphilis.",
     "Adie's tonic pupil: Both reflexes sluggish → ciliary ganglion degeneration.",
     "CN III palsy: Both reflexes absent (efferent limb affected) + ptosis + 'down and out' eye.",
     "Convergence insufficiency: Near triad breaks down → esophoria, eyestrain when reading."]))
story.append(sp(4))
story.append(Paragraph("Sources: Ganong's 26th Ed.", style_source))
story.append(PageBreak())

# ════════════════════════════════════════════════════════
# CHAPTER 12 – ENDOCOCHLEAR POTENTIAL
# ════════════════════════════════════════════════════════
story.append(chapter_header("12", "ENDOCOCHLEAR POTENTIAL",
    "The cochlear battery that drives hearing"))
story.append(sp(10))

story.append(Paragraph("The Fluid Compartments of the Cochlea", style_h1))
story.append(pathway_table(
    ["Compartment", "Fluid", "K⁺ (mEq/L)", "Na⁺ (mEq/L)", "Electrical Potential"],
    [["Scala Vestibuli (above Reissner's membrane)", "Perilymph", "~5", "~150", "~0 mV (reference)"],
     ["Scala Media / Cochlear Duct", "Endolymph", "~150 (HIGH)", "~1 (low)", "+80 to +85 mV (ECP)"],
     ["Scala Tympani (below basilar membrane)", "Perilymph", "~5", "~150", "~0 mV"]],
    col_widths=[4.8*cm, 2.5*cm, 2.2*cm, 2.2*cm, 3.7*cm]
))
story.append(sp(6))

story.append(Paragraph("The Endocochlear Potential (ECP)", style_h1))
for b in [
    "The scala media (endolymph) is +80 to +85 mV relative to the perilymph — this is the ECP.",
    "Generated and maintained by the STRIA VASCULARIS (metabolically active epithelium on the lateral wall of scala media).",
    "Stria vascularis contains marginal cells, intermediate cells, and basal cells with extensive gap junctions.",
    "K⁺ recycling pathway: Hair cells → supporting cells → spiral ligament → stria vascularis → back to endolymph.",
    "The ECP is unique in being the ONLY positive potential in the extracellular fluid of the body.",
]:
    story.append(bullet(b))
story.append(sp(6))

story.append(Paragraph("Why the ECP is Critical for Hearing", style_h1))
for b in [
    "Hair cell resting membrane potential = ~−60 mV.",
    "When stereocilia are deflected, the hair cell tip (bathed in endolymph at +80 mV) opens K⁺ channels.",
    "Total electrical gradient = Endolymph (+80 mV) − Intracell (−60 mV) = 140 mV driving force for K⁺ influx.",
    "This huge driving force gives the cochlea exceptional sensitivity — enabling detection of extremely faint sounds.",
    "Without the ECP, the cochlear amplifier would not function; even moderate sounds would not generate responses.",
]:
    story.append(bullet(b))
story.append(sp(6))

story.append(clinical_box("Clinical Relevance",
    ["Aminoglycoside antibiotics (streptomycin, gentamicin) damage stria vascularis and hair cells → loss of ECP → sensorineural hearing loss.",
     "Loop diuretics (furosemide/frusemide) → inhibit Na-K-2Cl cotransporter in stria vascularis → temporarily reduce ECP → reversible hearing loss.",
     "Noise-induced hearing loss: Destroys outer hair cells → loss of cochlear amplifier (40-60 dB loss).",
     "Connexin 26 (GJB2) mutations: Most common cause of hereditary sensorineural hearing loss; disrupts K⁺ recycling pathway."]))
story.append(sp(4))
story.append(Paragraph("Sources: Ganong's 26th Ed.; Neuroscience: Exploring the Brain, 5th Ed.", style_source))
story.append(PageBreak())

# ════════════════════════════════════════════════════════
# CHAPTER 13 – PHYSIOLOGY OF TASTE
# ════════════════════════════════════════════════════════
story.append(chapter_header("13", "PHYSIOLOGY OF TASTE",
    "Receptor mechanisms and depolarisation"))
story.append(sp(10))

story.append(Paragraph("Taste Receptor Cells", style_h1))
for b in [
    "Modified epithelial cells (NOT neurons) organised into TASTE BUDS (~10,000 in humans).",
    "Each taste bud has ~50-150 receptor cells, with microvilli (taste hairs) projecting through a TASTE PORE.",
    "Taste buds located on: Fungiform papillae (anterior tongue), Circumvallate papillae (posterior tongue), Foliate papillae, Soft palate, Epiglottis.",
    "Lifespan: ~10 days; constantly replaced from basal cells.",
    "Receptor cells release ATP and serotonin as neurotransmitters onto afferent nerve fibres.",
]:
    story.append(bullet(b))
story.append(sp(6))

story.append(section_title("Receptor Mechanisms for 5 Tastes"))
story.append(sp(4))
story.append(pathway_table(
    ["Taste", "Stimulus", "Receptor Type", "Mechanism of Depolarisation"],
    [["Salty", "Na⁺ ions", "ENaC (amiloride-sensitive Na⁺ channel)", "Direct Na⁺ influx → membrane depolarisation"],
     ["Sour", "H⁺ ions (acids)", "H⁺-gated channels + K⁺ channel blockade", "Block of K⁺ efflux + direct H⁺ entry → depolarisation"],
     ["Bitter", "Alkaloids, toxins", "T2R family (~25 types); GPCR via gustducin", "↑IP₃ → Ca²⁺ release from ER → vesicle fusion + ATP release"],
     ["Sweet", "Sugars, saccharin", "T1R2 + T1R3 heterodimer GPCR", "↑cAMP → PKA → close K⁺ channels → depolarisation"],
     ["Umami", "L-Glutamate, MSG", "T1R1 + T1R3 heterodimer GPCR", "↑cAMP (similar to sweet) → depolarisation"]],
    col_widths=[1.8*cm, 2.5*cm, 3.8*cm, 7.3*cm]
))
story.append(sp(6))

story.append(Paragraph("Taste Quality and Receptor Specificity", style_h2))
for b in [
    "Labelled line theory: Different receptor cells are tuned to specific taste modalities; these project to distinct brain areas.",
    "Each taste quality is encoded by dedicated neural channels from receptor to cortex.",
    "Bitter receptors are most diverse (25 types) — evolutionary mechanism to detect diverse toxins.",
    "Sweet and umami receptors share the T1R3 subunit (heterodimeric GPCRs).",
]:
    story.append(bullet(b))
story.append(sp(4))
story.append(Paragraph("Sources: Ganong's 26th Ed.", style_source))
story.append(PageBreak())

# ════════════════════════════════════════════════════════
# CHAPTER 14 – PHYSIOLOGY OF SMELL
# ════════════════════════════════════════════════════════
story.append(chapter_header("14", "PHYSIOLOGY OF SMELL",
    "Olfactory transduction and neural coding"))
story.append(sp(10))

story.append(Paragraph("Olfactory Receptor Neurons (ORNs)", style_h1))
for b in [
    "10-12 million ORNs in the olfactory epithelium (roof of nasal cavity, covering ~5 cm² in humans).",
    "TRUE BIPOLAR NEURONS: cell body in epithelium; dendrites project as CILIA into the mucus layer; axons form CN I.",
    "Unique regeneration: lifespan ~30-60 days; replaced from BASAL CELLS — the only known regenerating CNS neurons.",
    "~400 functional olfactory receptor genes (largest gene family in the human genome).",
    "Each neuron expresses ONLY ONE receptor type.",
    "All neurons expressing the same receptor converge on 1-2 specific glomeruli in the olfactory bulb.",
]:
    story.append(bullet(b))
story.append(sp(6))

story.append(section_title("Transduction Mechanism (step-by-step)"))
story.append(sp(4))
smell_steps = [
    "Odorant molecules dissolved in nasal mucus (odorant-binding proteins facilitate delivery)",
    "Odorant binds to GPCR olfactory receptor on cilia membrane",
    "Receptor activates Golf (olfactory Gs-type G-protein) → GDP → GTP exchange",
    "Golf-GTP activates ADENYLYL CYCLASE III → cAMP increases",
    "cAMP opens CNG (cyclic nucleotide-gated) cation channels → Na⁺ and Ca²⁺ influx",
    "Ca²⁺ activates Ca²⁺-sensitive Cl⁻ channels → Cl⁻ efflux → further depolarisation (amplification step)",
    "Action potential generated and propagated along axon to olfactory bulb",
    "Adaptation: Calmodulin binds Ca²⁺ → reduces CNG channel sensitivity → receptor desensitisation",
]
for i, s in enumerate(smell_steps, 1):
    story.append(numbered(i, s))
story.append(sp(6))

story.append(Paragraph("Odour Coding", style_h2))
for b in [
    "COMBINATORIAL CODING: Each odorant activates a unique PATTERN of multiple receptor types.",
    "~400 receptor types can theoretically distinguish >10,000 distinct odours.",
    "Each glomerulus in the olfactory bulb receives input from neurons with the same receptor → spatial map.",
    "Odour identity = which combination of glomeruli is activated.",
    "Odour intensity = firing frequency within activated channels.",
]:
    story.append(bullet(b))
story.append(sp(6))

story.append(clinical_box("Anosmia — Clinical Causes",
    ["Head trauma: Shearing of CN I axons at cribriform plate (most common traumatic cause).",
     "Viral: COVID-19, influenza (direct olfactory epithelium damage; often recovers).",
     "Kallmann syndrome: Failure of GnRH neurons to migrate (anosmia + hypogonadotropic hypogonadism).",
     "Zinc deficiency: Cofactor for olfactory processing enzymes.",
     "Neurodegenerative: Early sign of Parkinson's and Alzheimer's disease (before motor/cognitive symptoms).",
     "Sinonasal disease: Chronic rhinitis, polyps, sinusitis → conductive anosmia (treatable)."]))
story.append(sp(4))
story.append(Paragraph("Sources: Ganong's 26th Ed.; Eric Kandel Principles of Neural Science, 6th Ed.", style_source))
story.append(PageBreak())

# ════════════════════════════════════════════════════════
# CHAPTER 15 – PHYSIOLOGY OF HEARING
# ════════════════════════════════════════════════════════
story.append(chapter_header("15", "PHYSIOLOGY OF HEARING",
    "From sound wave to action potential"))
story.append(sp(10))

story.append(Paragraph("Step-by-Step Hearing Process", style_h1))
hear_steps = [
    ("Outer Ear", "Pinna collects sound; external auditory canal funnels it to the tympanic membrane. The pinna is slightly forward-facing → important for vertical sound localisation."),
    ("Tympanic Membrane", "Vibrates in response to sound pressure waves. Connected to the malleus via the manubrium."),
    ("Ossicular Chain (Middle Ear)", "Malleus → Incus → Stapes. Achieves IMPEDANCE MATCHING (~22-fold pressure amplification). Stapes footplate vibrates at the oval window."),
    ("Oval Window → Perilymph", "Stapes movement creates travelling pressure waves in the PERILYMPH of the scala vestibuli."),
    ("Basilar Membrane", "Pressure waves displace the basilar membrane. TONOTOPIC: High frequencies → base (narrow, stiff); Low frequencies → apex (wide, flexible). This is the physical basis of Place Theory (von Bekesy)."),
    ("Hair Cells / Organ of Corti", "Basilar membrane vibration causes SHEARING of stereocilia against the tectorial membrane. Deflection toward the tallest stereocilium → TIP LINKS pull open K⁺/Ca²⁺ channels → K⁺ influx (from endolymph) → depolarisation → Ca²⁺ influx at basolateral membrane → GLUTAMATE release."),
    ("Outer Hair Cells (OHCs)", "3 rows of OHCs per row of IHCs. Have PRESTIN protein (molecular motor) → electromotility. The cochlear AMPLIFIER: active mechanical amplification of basilar membrane vibration (~40-60 dB gain). Damage → significant sensorineural hearing loss."),
    ("Inner Hair Cells (IHCs)", "1 row; TRUE sensory transducers. 95% of CN VIII afferent fibres arise from IHCs. Each IHC contacts ~10-20 afferent fibres."),
    ("Cochlear Nerve (CN VIII)", "Carries action potentials to the cochlear nuclei in the brainstem → central auditory pathway (see Ch. 1)."),
]
for i, (t, d) in enumerate(hear_steps, 1):
    story.append(numbered(i, f"<b>{t}:</b>  {d}"))
story.append(sp(6))

story.append(section_title("Sound Localisation"))
story.append(sp(4))
for b in [
    "HORIZONTAL LOCALISATION: Detected by the Superior Olivary Nucleus (SON) using two cues:",
    "  — Interaural TIME difference (ITD): which ear receives sound first; dominant <3000 Hz",
    "  — Interaural LEVEL difference (ILD): sound is louder in the nearer ear; dominant >3000 Hz",
    "VERTICAL LOCALISATION: Relies on the shape of the pinna modifying the sound spectrum (head-related transfer function).",
    "Sound localisation is severely disrupted by lesions of the auditory cortex.",
]:
    story.append(bullet(b))
story.append(sp(6))

story.append(memory_box("Organ of Corti Summary",
    ["Located on the basilar membrane within the scala media",
     "Contains ~15,500 hair cells total (3500 IHCs + 12,000 OHCs) in humans",
     "Tectorial membrane: overlies the stereocilia; provides the shearing force",
     "Endocochlear potential (+80 mV in endolymph) provides ~140 mV driving force for K⁺ into hair cells",
     "Reissner's membrane: separates scala media from scala vestibuli; maintains endolymph composition"]))
story.append(sp(6))

story.append(section_title("Quick Summary Table — Special Senses"))
story.append(sp(4))
story.append(pathway_table(
    ["Sense", "Receptor", "Cranial Nerve", "First Cortex"],
    [["Hearing", "Hair cells (Organ of Corti)", "CN VIII", "Superior temporal gyrus (A1, areas 41/42)"],
     ["Vision", "Rods & Cones", "CN II", "Calcarine fissure, occipital (V1, area 17)"],
     ["Taste", "Taste receptor cells (taste buds)", "CN VII, IX, X", "Anterior insula / operculum (area 43)"],
     ["Smell", "Olfactory sensory neurons", "CN I", "Piriform cortex (no thalamic relay!)"],
     ["Touch/pain", "Mechanoreceptors, nociceptors", "CN V / spinal", "Primary somatosensory cortex (areas 1,2,3)"]],
    col_widths=[2.8*cm, 4.5*cm, 3.2*cm, 5*cm]
))
story.append(sp(6))
story.append(Paragraph(
    "Sources: Ganong's Review of Medical Physiology 26th Ed. | Neuroscience: Exploring the Brain 5th Ed. | "
    "Junqueira's Basic Histology 17th Ed. | Adams & Victor's Principles of Neurology 12th Ed. | "
    "Cummings Otolaryngology 6th Ed.",
    style_source))

# ════════════════════════════════════════════════════════
# BUILD PDF
# ════════════════════════════════════════════════════════
doc.build(story, onFirstPage=on_cover, onLaterPages=on_page)
print(f"PDF created: {OUTPUT_PATH}")
print(f"File size: {os.path.getsize(OUTPUT_PATH)/1024:.1f} KB")
Running Command

cd /tmp/workspace/special-senses-pdf && python generate_pdf.py 2>&1

Your study guide PDF is ready! Here's the download link:

Special Senses Study Guide

PDF Document · PDF


What's inside the PDF (62 KB, A4, multi-page):
ChapterTopic
1Auditory Pathway — full central pathway, tonotopy, hearing loss table
2Visual Pathway & Defects — step-by-step, complete defect table, macular sparing
3Taste Pathway — cranial nerves, NTS, 5 modalities receptor table
4Olfactory Pathway — transduction mechanism, 6-step pathway, anosmia box
5Middle Ear Functions — impedance matching, acoustic reflex, Eustachian tube
6Theories of Hearing — Place, Frequency, Volley + combined theory mnemonic
7Theories of Colour Vision — Trichromatic, Opponent, Zone Theory + colour blindness
8Phototransduction — dark current, rhodopsin cascade, rods vs. cones table
9Dark Adaptation — two phases, Purkinje shift, red goggles tip
10Light Reflex Pathway — 9-step pathway, pupil disorders clinical table
11Accommodation Reflex — near triad, ciliary mechanism, Argyll Robertson vs. Adie
12Endocochlear Potential — fluid compartments table, stria vascularis, 140 mV driving force
13Physiology of Taste — 5-modality receptor mechanism table
14Physiology of Smell — olfactory transduction cascade, combinatorial coding
15Physiology of Hearing — 9-step mechanism, hair cells, sound localisation + master summary table
Design features: Navy/blue colour scheme, chapter header blocks, styled tables, colour-coded callout boxes (mnemonics in gold, clinical pearls in green, info boxes in teal), page headers/footers, and a full table of contents.
This is a shared conversation. Sign in to Orris to start your own chat.