Explain dangerous area of face for my anatomy exam of 1st year MBBS
"The upper lip and nose are considered the danger area of the face because infections in this region may be transmitted in a retrograde fashion through a valveless venous system to the cavernous sinus."
- Scott-Brown's Otorhinolaryngology Head & Neck Surgery

There are NO valves in the facial vein or any other venous channels of the head.
| Structure | Location in/near Sinus | Clinical Effect if Involved |
|---|---|---|
| Internal carotid artery | Passes through sinus | Arterial compromise, stroke |
| Abducent nerve (CN VI) | Passes through the interior of the sinus | Lateral rectus palsy (most sensitive sign - eye cannot abduct) |
| Oculomotor nerve (CN III) | Lateral wall of sinus | Ptosis, dilated pupil, "down and out" eye |
| Trochlear nerve (CN IV) | Lateral wall of sinus | Superior oblique palsy |
| Ophthalmic nerve (CN V1) | Lateral wall of sinus | Loss of sensation over forehead/eye |
| Maxillary nerve (CN V2) | Lateral wall of sinus | Loss of sensation over cheek |
"Diagnosis of such complication is made by noting severe constitutional disturbances, proptosis, squint and paralysis of the ocular muscles, especially the rectus lateralis which is supplied by the abducent nerve."
- S. Das, A Manual on Clinical Surgery
| Point | Detail |
|---|---|
| Location | Triangle: apex at root of nose, base at upper lip (upper lip + nose) |
| Key reason | Valveless veins - no valves in facial vein or head veins |
| Route 1 | Facial vein → Angular vein → Superior ophthalmic vein → Cavernous sinus |
| Route 2 | Facial vein → Deep facial vein → Pterygoid plexus → Cavernous sinus (via foramen ovale/lacerum) |
| Most dangerous infection | Boil/furuncle on upper lip or nose - do NOT squeeze it |
| Complication | Cavernous sinus thrombosis (septic) |
| Earliest sign of CST | Lateral rectus palsy (CN VI - abducent nerve) |
| Why CN VI first? | It lies inside the sinus, not in its wall |
| Classic saying | "Never squeeze a pimple in the dangerous area of the face" |
Explain circle of Willis for my 1st year anatomy exam
With its digram and image


| Circulation | Source Vessels | Forms |
|---|---|---|
| Anterior | Left & Right Internal Carotid Arteries (ICA) | ACA + MCA |
| Posterior | Left & Right Vertebral Arteries → fuse to form Basilar Artery | PCA |
"The two anterior cerebral arteries are connected by the anterior communicating artery. The posterior communicating arteries connect the supraclinoid internal carotid arteries with the proximal posterior cerebral arteries."
- Goldman-Cecil Medicine, 22E
ACoA (anterior communicating artery)
|
ACA ——[left]——[right]—— ACA
| |
ICA (left) ICA (right)
| |
PCoA (left) PCoA (right)
| |
PCA (left) ——Basilar—— PCA (right)
|
Vertebral arteries (L + R)
OPAAM
- O - Ophthalmic artery
- P - Posterior communicating artery
- A - Anterior choroidal artery
- A - Anterior cerebral artery
- M - Middle cerebral artery
| Variant | Description |
|---|---|
| Hypoplastic A1 segment | One ACA's proximal part is small/absent; both ACAs fed from one ICA |
| "Fetal" PCA | P1 segment absent; PCA territory supplied by ICA via PCoA instead of basilar |
| Hypoplastic PCoA | Reduces communication between anterior & posterior circulation |
| Vessel | Origin | Supplies | Stroke Deficit |
|---|---|---|---|
| ACA | ICA | Medial frontal/parietal (leg area) | Contralateral leg weakness |
| MCA | ICA | Lateral hemisphere (face, arm, speech) | Face + arm weakness, aphasia |
| PCA | Basilar | Occipital lobe, thalamus | Homonymous hemianopia |
| ACoA | Between ACAs | Communicating vessel only | Aneurysm - SAH, personality change |
| PCoA | ICA to PCA | Communicating vessel only | Aneurysm - CN III palsy |
Generate a quick reference PDF of Circle of Willis anatomy for exam prep
ls -la /home/daytona/workspace/ 2>/dev/null || echo "workspace empty or missing"
mkdir -p /home/daytona/workspace/circle-of-willis && python3 -c "import reportlab; print('reportlab ok')"
~/circle-of-willis/generate_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm, cm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, KeepTogether
)
from reportlab.graphics.shapes import Drawing, Circle, Rect, Line, Ellipse, String, Polygon
from reportlab.graphics import renderPDF
from reportlab.platypus import Flowable
import math
OUTPUT = "/home/daytona/workspace/circle-of-willis/Circle_of_Willis_Quick_Reference.pdf"
# ── Colour palette ──────────────────────────────────────────────────────────
DARK_BLUE = colors.HexColor("#1a2d5a")
MED_BLUE = colors.HexColor("#2e5fa3")
LIGHT_BLUE = colors.HexColor("#dce9f7")
ACCENT_RED = colors.HexColor("#c0392b")
ACCENT_ORG = colors.HexColor("#e67e22")
ACCENT_GRN = colors.HexColor("#27ae60")
PALE_GOLD = colors.HexColor("#fff8e1")
PALE_RED = colors.HexColor("#fdecea")
PALE_GRN = colors.HexColor("#e8f5e9")
WHITE = colors.white
GREY = colors.HexColor("#555555")
LIGHT_GREY = colors.HexColor("#f4f4f4")
# ── Styles ───────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()
def S(name, **kw):
base = styles.get(name, styles["Normal"])
return ParagraphStyle(name + str(id(kw)), parent=base, **kw)
title_style = S("Title",
fontSize=22, textColor=WHITE, alignment=TA_CENTER,
fontName="Helvetica-Bold", spaceAfter=2)
subtitle_style = S("Normal",
fontSize=11, textColor=colors.HexColor("#cfe0ff"), alignment=TA_CENTER,
fontName="Helvetica", spaceAfter=4)
section_style = S("Normal",
fontSize=12, textColor=WHITE, fontName="Helvetica-Bold",
backColor=MED_BLUE, leftIndent=6, rightIndent=6,
spaceBefore=8, spaceAfter=4, borderPad=4)
body_style = S("Normal",
fontSize=9.5, textColor=colors.HexColor("#1a1a1a"),
fontName="Helvetica", leading=14, spaceAfter=3, alignment=TA_JUSTIFY)
bullet_style = S("Normal",
fontSize=9, textColor=colors.HexColor("#222222"),
fontName="Helvetica", leading=13, leftIndent=12, spaceAfter=2)
bold_style = S("Normal",
fontSize=9.5, textColor=DARK_BLUE, fontName="Helvetica-Bold",
leading=13, spaceAfter=2)
small_style = S("Normal",
fontSize=8, textColor=GREY, fontName="Helvetica",
leading=11, spaceAfter=1)
caption_style = S("Normal",
fontSize=8, textColor=GREY, fontName="Helvetica-Oblique",
alignment=TA_CENTER, spaceAfter=6)
mnemonic_style = S("Normal",
fontSize=10.5, textColor=DARK_BLUE, fontName="Helvetica-Bold",
leading=15, leftIndent=8, spaceAfter=2)
# ── Custom flowable: Title banner ─────────────────────────────────────────────
class TitleBanner(Flowable):
def __init__(self, width, height=60):
super().__init__()
self.width = width
self.height = height
def draw(self):
c = self.canv
# gradient-like banner (two rects)
c.setFillColor(DARK_BLUE)
c.rect(0, 0, self.width, self.height, fill=1, stroke=0)
c.setFillColor(MED_BLUE)
c.rect(0, 0, self.width * 0.55, self.height, fill=1, stroke=0)
# decorative side bar
c.setFillColor(ACCENT_RED)
c.rect(0, 0, 6, self.height, fill=1, stroke=0)
# ── Custom flowable: Circle of Willis diagram ─────────────────────────────────
class CircleOfWillisDiagram(Flowable):
"""Schematic diagram of the Circle of Willis."""
def __init__(self, width=480, height=320):
super().__init__()
self.width = width
self.height = height
def draw(self):
c = self.canv
w, h = self.width, self.height
# Background
c.setFillColor(colors.HexColor("#f0f4fa"))
c.roundRect(0, 0, w, h, 10, fill=1, stroke=0)
# Title
c.setFillColor(DARK_BLUE)
c.setFont("Helvetica-Bold", 10)
c.drawCentredString(w / 2, h - 16, "Circle of Willis — Schematic Diagram")
# Centre reference point
cx, cy = w / 2, h / 2 - 10
# ── Draw the vascular "ring" ──────────────────────────────────────
# We build a polygon path approximating the circle shape:
# Vessels drawn as thick lines
arterial = colors.HexColor("#c0392b")
comm = colors.HexColor("#e67e22")
vert = colors.HexColor("#8e44ad")
# Coordinates (relative to cx, cy)
# ACA points (top)
aca_l = (cx - 38, cy + 72)
aca_r = (cx + 38, cy + 72)
acoa = (cx, cy + 82) # ACoA label point
# ICA entry points (mid-lateral)
ica_l = (cx - 68, cy + 22)
ica_r = (cx + 68, cy + 22)
# PCoA points (mid)
pcoa_l = (cx - 62, cy - 22)
pcoa_r = (cx + 62, cy - 22)
# PCA points (lower)
pca_l = (cx - 48, cy - 62)
pca_r = (cx + 48, cy - 62)
# Basilar / top
bas_top = (cx, cy - 72)
def thick_line(x1, y1, x2, y2, col, lw=4.5):
c.setStrokeColor(col)
c.setLineWidth(lw)
c.line(x1, y1, x2, y2)
def dashed_line(x1, y1, x2, y2, col, lw=3):
c.setStrokeColor(col)
c.setLineWidth(lw)
c.setDash([5, 4])
c.line(x1, y1, x2, y2)
c.setDash([])
# ── Left ICA trunk (enters from bottom-left) ──
thick_line(cx - 68, cy - 80, ica_l[0], ica_l[1], arterial, 5)
thick_line(ica_r[0], ica_r[1], cx + 68, cy - 80, arterial, 5)
# ── ACA segments ──
thick_line(ica_l[0], ica_l[1], aca_l[0], aca_l[1], arterial)
thick_line(ica_r[0], ica_r[1], aca_r[0], aca_r[1], arterial)
# ── ACoA (connects the two ACAs) ──
thick_line(aca_l[0], aca_l[1], aca_r[0], aca_r[1], comm, 4)
# ── MCA exits laterally ──
thick_line(ica_l[0], ica_l[1], cx - 118, cy + 22, arterial, 4)
thick_line(ica_r[0], ica_r[1], cx + 118, cy + 22, arterial, 4)
# ── PCoA (ICA → PCA) ──
dashed_line(ica_l[0], ica_l[1], pcoa_l[0], pcoa_l[1], comm, 3.5)
dashed_line(ica_r[0], ica_r[1], pcoa_r[0], pcoa_r[1], comm, 3.5)
# ── PCA ──
thick_line(pcoa_l[0], pcoa_l[1], pca_l[0], pca_l[1], vert, 4)
thick_line(pcoa_r[0], pcoa_r[1], pca_r[0], pca_r[1], vert, 4)
# ── PCA to basilar ──
thick_line(pca_l[0], pca_l[1], bas_top[0], bas_top[1], vert, 5)
thick_line(pca_r[0], pca_r[1], bas_top[0], bas_top[1], vert, 5)
# ── Basilar trunk going down ──
thick_line(bas_top[0], bas_top[1], cx, cy - 130, vert, 5)
# ── Vertebral arteries ──
thick_line(cx - 30, cy - 130, cx, cy - 130, vert, 4)
thick_line(cx + 30, cy - 130, cx, cy - 130, vert, 4)
thick_line(cx - 30, cy - 130, cx - 60, cy - 155, vert, 4)
thick_line(cx + 30, cy - 130, cx + 60, cy - 155, vert, 4)
# ── ACA continue upward ──
thick_line(aca_l[0], aca_l[1], cx - 38, cy + 118, arterial, 4)
thick_line(aca_r[0], aca_r[1], cx + 38, cy + 118, arterial, 4)
# ── Vessel dots at key junctions ──
junctions = [ica_l, ica_r, aca_l, aca_r, pca_l, pca_r, pcoa_l, pcoa_r, bas_top]
for (jx, jy) in junctions:
c.setFillColor(WHITE)
c.setStrokeColor(DARK_BLUE)
c.setLineWidth(1)
c.circle(jx, jy, 5, fill=1, stroke=1)
# ── Labels ───────────────────────────────────────────────────────
def label(text, x, y, col=DARK_BLUE, size=7.5, bold=False, anchor="middle"):
c.setFillColor(col)
font = "Helvetica-Bold" if bold else "Helvetica"
c.setFont(font, size)
if anchor == "middle":
c.drawCentredString(x, y, text)
elif anchor == "left":
c.drawString(x, y, text)
else:
c.drawRightString(x, y, text)
# Boxes for labels
def label_box(text, x, y, bg=WHITE, tc=DARK_BLUE, size=7.5, bold=True, w=None):
c.setFont("Helvetica-Bold" if bold else "Helvetica", size)
tw = c.stringWidth(text, "Helvetica-Bold" if bold else "Helvetica", size)
bw = (w or tw) + 8
bh = size + 5
c.setFillColor(bg)
c.setStrokeColor(tc)
c.setLineWidth(0.5)
c.roundRect(x - bw/2, y - 3, bw, bh, 3, fill=1, stroke=1)
c.setFillColor(tc)
c.drawCentredString(x, y + 1, text)
# ACoA
label_box("ACoA", cx, cy + 91, bg=colors.HexColor("#fff3cd"), tc=comm, size=7.5)
# ACAs
label_box("ACA (L)", cx - 38, cy + 126, bg=PALE_RED, tc=arterial, size=7)
label_box("ACA (R)", cx + 38, cy + 126, bg=PALE_RED, tc=arterial, size=7)
# ICAs
label_box("ICA (L)", cx - 85, cy - 92, bg=PALE_RED, tc=arterial, size=7)
label_box("ICA (R)", cx + 85, cy - 92, bg=PALE_RED, tc=arterial, size=7)
# MCAs
label_box("MCA (L)", cx - 138, cy + 29, bg=PALE_RED, tc=arterial, size=7)
label_box("MCA (R)", cx + 138, cy + 29, bg=PALE_RED, tc=arterial, size=7)
# PCoAs
label_box("PCoA (L)", cx - 85, cy - 8, bg=colors.HexColor("#fff3cd"), tc=comm, size=7)
label_box("PCoA (R)", cx + 85, cy - 8, bg=colors.HexColor("#fff3cd"), tc=comm, size=7)
# PCAs
label_box("PCA (L)", cx - 62, cy - 72, bg=colors.HexColor("#ede7f6"), tc=vert, size=7)
label_box("PCA (R)", cx + 62, cy - 72, bg=colors.HexColor("#ede7f6"), tc=vert, size=7)
# Basilar
label_box("Basilar A.", cx, cy - 100, bg=colors.HexColor("#ede7f6"), tc=vert, size=7.5)
# Vertebrals
label_box("Vertebral A. (L)", cx - 60, cy - 160, bg=colors.HexColor("#ede7f6"), tc=vert, size=7)
label_box("Vertebral A. (R)", cx + 60, cy - 160, bg=colors.HexColor("#ede7f6"), tc=vert, size=7)
# ── Legend ────────────────────────────────────────────────────────
lx, ly = 14, 26
c.setFont("Helvetica-Bold", 7.5)
c.setFillColor(DARK_BLUE)
c.drawString(lx, ly + 28, "Legend:")
for col, lbl in [(arterial, "Anterior circulation (ICA)"),
(comm, "Communicating arteries"),
(vert, "Posterior circulation (Vertebrobasilar)")]:
c.setStrokeColor(col); c.setFillColor(col); c.setLineWidth(3)
c.line(lx, ly + 5, lx + 18, ly + 5)
c.setFillColor(DARK_BLUE); c.setFont("Helvetica", 7)
c.drawString(lx + 22, ly + 2, lbl)
ly -= 13
# dashed = communicating note
c.setStrokeColor(comm); c.setLineWidth(2); c.setDash([4,3])
c.line(lx, ly + 5 + 13 - 2, lx + 18, ly + 5 + 13 - 2)
c.setDash([])
c.setFillColor(GREY); c.setFont("Helvetica-Oblique", 6.5)
c.drawString(lx + 22, ly + 5 + 10, "dashed = communicating arteries")
# ── Build document ────────────────────────────────────────────────────────────
def build():
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
leftMargin=18*mm, rightMargin=18*mm,
topMargin=14*mm, bottomMargin=14*mm,
title="Circle of Willis - Quick Reference",
author="Orris Medical"
)
W = A4[0] - 36*mm # usable width
story = []
# ── TITLE BANNER ──────────────────────────────────────────────────────────
story.append(TitleBanner(W, 62))
# Overlay text via table (hacky but works nicely)
title_data = [[
Paragraph("<font color='white'><b>Circle of Willis</b></font>",
ParagraphStyle("t", fontSize=21, fontName="Helvetica-Bold",
textColor=WHITE, alignment=TA_CENTER)),
]]
title_tbl = Table(title_data, colWidths=[W])
title_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), colors.transparent),
("TOPPADDING", (0,0), (-1,-1), -55),
("BOTTOMPADDING", (0,0), (-1,-1), 10),
]))
story.append(title_tbl)
sub_data = [[
Paragraph("<font color='#cfe0ff'>Quick Reference for 1st Year MBBS Anatomy Exam</font>",
ParagraphStyle("s", fontSize=10, fontName="Helvetica",
textColor=colors.HexColor("#cfe0ff"), alignment=TA_CENTER)),
]]
sub_tbl = Table(sub_data, colWidths=[W])
sub_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), DARK_BLUE),
("TOPPADDING", (0,0), (-1,-1), 2),
("BOTTOMPADDING", (0,0), (-1,-1), 8),
]))
story.append(sub_tbl)
story.append(Spacer(1, 6))
# ── SECTION HELPER ────────────────────────────────────────────────────────
def section(title):
data = [[Paragraph(f"<b>{title}</b>",
ParagraphStyle("sh", fontSize=10.5, fontName="Helvetica-Bold",
textColor=WHITE))]]
t = Table(data, colWidths=[W])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), MED_BLUE),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 8),
]))
return t
def info_box(paragraphs_list, bg=LIGHT_BLUE, border=MED_BLUE):
data = [[p] for p in paragraphs_list]
t = Table(data, colWidths=[W - 4])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), bg),
("BOX", (0,0), (-1,-1), 0.8, border),
("TOPPADDING", (0,0), (-1,-1), 3),
("BOTTOMPADDING", (0,0), (-1,-1), 3),
("LEFTPADDING", (0,0), (-1,-1), 8),
("RIGHTPADDING", (0,0), (-1,-1), 8),
]))
return t
# ── 1. DEFINITION ─────────────────────────────────────────────────────────
story.append(section("1. Definition & Location"))
story.append(Spacer(1, 4))
story.append(info_box([
Paragraph(
"The <b>Circle of Willis</b> (cerebral arterial circle) is a <b>polygonal "
"anastomotic ring of arteries</b> located at the <b>base of the brain</b> "
"in the interpeduncular cistern of the subarachnoid space.",
body_style),
Paragraph(
"It unites the <b>anterior circulation</b> (internal carotid arteries) with "
"the <b>posterior circulation</b> (vertebral-basilar system), providing "
"collateral pathways to protect the brain from ischaemia.",
body_style),
]))
story.append(Spacer(1, 6))
# ── 2. DIAGRAM ────────────────────────────────────────────────────────────
story.append(section("2. Schematic Diagram"))
story.append(Spacer(1, 4))
story.append(CircleOfWillisDiagram(width=W, height=295))
story.append(Paragraph(
"Fig: Schematic of the Circle of Willis. Red = anterior circulation; "
"Orange = communicating arteries; Purple = posterior (vertebrobasilar) circulation.",
caption_style))
story.append(Spacer(1, 4))
# ── 3. COMPONENTS TABLE ───────────────────────────────────────────────────
story.append(section("3. Components of the Circle of Willis"))
story.append(Spacer(1, 4))
comp_header = ["Vessel", "Paired/Single", "Origin", "Part of Circle"]
comp_data = [
comp_header,
["Anterior Cerebral A. (ACA)", "Paired (L & R)", "Internal Carotid A.", "Anterior"],
["Anterior Communicating A. (ACoA)", "Single (unpaired)", "Between the 2 ACAs", "Anterior (connector)"],
["Internal Carotid A. (ICA)", "Paired (L & R)", "Common Carotid A.", "Lateral struts (inflow)"],
["Posterior Communicating A. (PCoA)", "Paired (L & R)", "ICA → PCA", "Middle (connector)"],
["Posterior Cerebral A. (PCA)", "Paired (L & R)", "Basilar Artery (top)", "Posterior"],
["Basilar Artery", "Single", "Union of 2 Vertebral A.", "Posterior inflow"],
]
hdr_style = [
("BACKGROUND", (0,0), (-1,0), DARK_BLUE),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 8.5),
("ROWBACKGROUNDS",(0,1),(-1,-1), [WHITE, LIGHT_BLUE]),
("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#aaaaaa")),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING",(0,0), (-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 6),
]
col_w = [W*0.32, W*0.17, W*0.25, W*0.26]
comp_tbl = Table(
[[Paragraph(str(cell), ParagraphStyle("ct", fontSize=8.5, fontName="Helvetica",
textColor=WHITE if r==0 else DARK_BLUE,
leading=11))
for cell in row] for r, row in enumerate(comp_data)],
colWidths=col_w
)
comp_tbl.setStyle(TableStyle(hdr_style))
story.append(comp_tbl)
story.append(Spacer(1, 6))
# ── 4. THREE MAIN CEREBRAL ARTERIES ───────────────────────────────────────
story.append(section("4. The Three Main Cerebral Arteries — Supply & Stroke Effects"))
story.append(Spacer(1, 4))
artery_data = [
["Artery", "Course", "Cortical Supply", "Deep Supply", "Stroke Deficit"],
["ACA\n(Anterior\nCerebral A.)",
"Forward, curves over corpus callosum in interhemispheric fissure",
"Medial frontal & parietal lobes; sensorimotor cortex for lower limb",
"Anterior limb internal capsule, head of caudate (via Heubner's a.)",
"Contralateral LEG weakness/sensory loss"],
["MCA\n(Middle\nCerebral A.)",
"Lateral into Sylvian (lateral) fissure; bifurcates into sup. & inf. divisions",
"Entire lateral hemisphere — face, arm, trunk cortex; Broca's; Wernicke's",
"Internal capsule (posterior limb), basal ganglia (lenticulostriate aa.)",
"Contralateral FACE + ARM weakness; aphasia (dominant side)"],
["PCA\n(Posterior\nCerebral A.)",
"Wraps around cerebral peduncle, passes posteriorly",
"Occipital lobe (primary visual cortex), medial-inferior temporal lobe",
"Thalamus, midbrain, posterior internal capsule",
"Contralateral homonymous hemianopia; thalamic pain syndrome"],
]
artery_col_w = [W*0.10, W*0.18, W*0.26, W*0.22, W*0.24]
row_colors = [DARK_BLUE, colors.HexColor("#fdecea"), colors.HexColor("#e8f5e9"),
colors.HexColor("#ede7f6")]
artery_tbl_data = []
for r, row in enumerate(artery_data):
tc = WHITE if r == 0 else DARK_BLUE
artery_tbl_data.append([
Paragraph(f"<b>{cell}</b>" if r == 0 else str(cell),
ParagraphStyle("at", fontSize=8, fontName="Helvetica-Bold" if r==0 else "Helvetica",
textColor=tc, leading=11))
for cell in row
])
artery_tbl = Table(artery_tbl_data, colWidths=artery_col_w)
artery_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), DARK_BLUE),
("BACKGROUND", (0,1), (-1,1), colors.HexColor("#fdecea")),
("BACKGROUND", (0,2), (-1,2), colors.HexColor("#e8f5e9")),
("BACKGROUND", (0,3), (-1,3), colors.HexColor("#ede7f6")),
("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#aaaaaa")),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 8),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 5),
("VALIGN", (0,0), (-1,-1), "TOP"),
]))
story.append(artery_tbl)
story.append(Spacer(1, 6))
# ── 5. MNEMONICS ──────────────────────────────────────────────────────────
story.append(section("5. Mnemonics"))
story.append(Spacer(1, 4))
mnem_data = [
[
Paragraph("<b>Branches of Supraclinoid ICA</b>", bold_style),
Paragraph("<b>OPAAM</b>", ParagraphStyle("mn", fontSize=13, fontName="Helvetica-Bold",
textColor=ACCENT_RED, alignment=TA_CENTER)),
],
[
Paragraph(
"<b>O</b>phthalmic artery<br/>"
"<b>P</b>osterior communicating artery<br/>"
"<b>A</b>nterior choroidal artery<br/>"
"<b>A</b>nterior cerebral artery<br/>"
"<b>M</b>iddle cerebral artery",
bullet_style),
Paragraph(
"<b>Vessels forming the circle</b><br/><br/>"
"2 ACA + 1 ACoA<br/>"
"2 ICA (supraclinoid)<br/>"
"2 PCoA<br/>"
"2 PCA<br/>"
"<b>= 9 named vessels total</b>",
bullet_style),
]
]
mnem_tbl = Table(mnem_data, colWidths=[W*0.5, W*0.5])
mnem_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (0,0), PALE_GOLD),
("BACKGROUND", (1,0), (1,0), PALE_GOLD),
("BACKGROUND", (0,1), (0,1), PALE_GOLD),
("BACKGROUND", (1,1), (1,1), LIGHT_BLUE),
("BOX", (0,0), (-1,-1), 0.8, MED_BLUE),
("INNERGRID", (0,0), (-1,-1), 0.4, colors.HexColor("#aaaaaa")),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 8),
("VALIGN", (0,0), (-1,-1), "TOP"),
("SPAN", (0,0), (0,0)),
]))
story.append(mnem_tbl)
story.append(Spacer(1, 6))
# ── 6. CLINICAL CORRELATES ────────────────────────────────────────────────
story.append(section("6. Clinical Correlates (High Yield for Exams)"))
story.append(Spacer(1, 4))
clin_data = [
["Condition", "Mechanism", "Key Feature"],
["Berry (Saccular) Aneurysm",
"Congenital weakness at bifurcation points of the circle; haemodynamic stress",
"Rupture → Subarachnoid haemorrhage (SAH) — 'worst headache of life'"],
["PCoA Aneurysm → CN III Palsy",
"Enlarging PCoA aneurysm compresses CN III as it runs nearby",
"Ptosis + dilated pupil + 'down & out' eye — neurosurgical emergency"],
["MCA Stroke",
"Occlusion of MCA (most common stroke territory — largest territory)",
"Contralateral face + arm weakness; aphasia if dominant hemisphere"],
["ACA Stroke",
"Occlusion of ACA; rarer as ACoA provides collateral",
"Contralateral LEG weakness (medial sensorimotor cortex)"],
["Posterior circulation (Basilar) Stroke",
"Basilar artery occlusion affects pons + cerebellum + midbrain",
"'Locked-in' syndrome; cerebellar ataxia; cranial nerve palsies"],
["Incomplete Circle of Willis",
"Present in ~66% of people; common variant: hypoplastic A1 or 'fetal' PCA",
"Reduced collateral reserve; increased stroke risk on vessel occlusion"],
]
clin_col_w = [W*0.26, W*0.38, W*0.36]
clin_tbl_data = []
for r, row in enumerate(clin_data):
tc = WHITE if r == 0 else DARK_BLUE
clin_tbl_data.append([
Paragraph(f"<b>{cell}</b>" if r == 0 else str(cell),
ParagraphStyle("clt", fontSize=8, fontName="Helvetica-Bold" if r==0 else "Helvetica",
textColor=tc, leading=11))
for cell in row
])
clin_tbl = Table(clin_tbl_data, colWidths=clin_col_w)
clin_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), DARK_BLUE),
("ROWBACKGROUNDS",(0,1),(-1,-1), [WHITE, PALE_RED]),
("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#aaaaaa")),
("FONTSIZE", (0,0), (-1,-1), 8),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 5),
("VALIGN", (0,0), (-1,-1), "TOP"),
]))
story.append(clin_tbl)
story.append(Spacer(1, 6))
# ── 7. QUICK REVISION SUMMARY ─────────────────────────────────────────────
story.append(section("7. Quick Revision Summary"))
story.append(Spacer(1, 4))
summary_items = [
("<b>Location:</b>", "Base of brain, interpeduncular cistern, subarachnoid space"),
("<b>Function:</b>", "Equaliser — allows collateral flow between anterior/posterior "
"and left/right circulations when one vessel is occluded"),
("<b>Anterior inflow:</b>", "Internal Carotid Arteries (ICA) — gives ACA + MCA"),
("<b>Posterior inflow:</b>", "Vertebral Arteries → Basilar Artery → PCA"),
("<b>Anterior connector:</b>", "Anterior Communicating Artery (ACoA) — joins the 2 ACAs"),
("<b>Lateral connectors:</b>", "Posterior Communicating Arteries (PCoA) — join ICA to PCA"),
("<b>Completeness:</b>", "Full ring present in only ~34% of individuals"),
("<b>Valves:</b>", "NO valves in cerebral veins/venous sinuses (relevant for infection spread)"),
("<b>Most common aneurysm site:</b>", "ACoA > PCoA > MCA bifurcation"),
("<b>Artery of Heubner:</b>", "Large medial striate branch of ACA — supplies anterior limb of internal capsule"),
]
summary_rows = [[
Paragraph(lbl, ParagraphStyle("sl", fontSize=8.5, fontName="Helvetica-Bold",
textColor=DARK_BLUE, leading=12)),
Paragraph(val, ParagraphStyle("sv", fontSize=8.5, fontName="Helvetica",
textColor=colors.HexColor("#1a1a1a"), leading=12))
] for lbl, val in summary_items]
sum_tbl = Table(summary_rows, colWidths=[W*0.30, W*0.70])
sum_tbl.setStyle(TableStyle([
("ROWBACKGROUNDS", (0,0), (-1,-1), [WHITE, LIGHT_BLUE]),
("GRID", (0,0), (-1,-1), 0.3, colors.HexColor("#cccccc")),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 6),
("VALIGN", (0,0), (-1,-1), "TOP"),
]))
story.append(sum_tbl)
story.append(Spacer(1, 8))
# ── Footer ────────────────────────────────────────────────────────────────
footer_data = [[
Paragraph(
"<font color='white'>Sources: Neuroanatomy through Clinical Cases 3e · Goldman-Cecil Medicine 22E · "
"Miller's Anesthesia 10E · Gray's Anatomy for Students | Generated by Orris Medical AI</font>",
ParagraphStyle("ft", fontSize=7, fontName="Helvetica", textColor=WHITE,
alignment=TA_CENTER, leading=10))
]]
footer_tbl = Table(footer_data, colWidths=[W])
footer_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), DARK_BLUE),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
]))
story.append(footer_tbl)
doc.build(story)
print(f"PDF created: {OUTPUT}")
build()
cd /home/daytona/workspace/circle-of-willis && python3 generate_pdf.py 2>&1
ls -lh /home/daytona/workspace/circle-of-willis/
Circle of Willis Quick Reference
PDF Document · PDF