~/dm-anaesthesia/cerebral-autoregulation/build.js
const pptxgen = require("pptxgenjs");
const { execSync } = require("child_process");
// ── Fetch images ──────────────────────────────────────────────────────────────
const imgUrls = [
"https://cdn.orris.care/cdss_images/6144a365e5722ef6ef1b077504d7222862dbb439596517a9bdf0dd05e8fcb214.png", // integrated regulation / autoregulation curve
"https://cdn.orris.care/cdss_images/519df37e2f3e66d05bfc289edcf8162de33b25e9acdfb81b53b6a07dab6a793e.png", // volatile agents CBF vs MAC
"https://cdn.orris.care/cdss_images/7629cd61007d1b2842ba3d047f4bb9c165a7828a7828cabdffcb5cec74d9ba18.png", // integrated regulatory processes diagram
];
const imgs = JSON.parse(
execSync(
`node /home/daytona/skills/shared/scripts/fetch_images.js ${imgUrls.map(u => `"${u}"`).join(" ")}`
).toString()
);
// ── Palette ───────────────────────────────────────────────────────────────────
const C = {
navy: "0A1628", // dominant bg
slate: "142035", // section bg
teal: "00B4C5", // accent headings
gold: "F0A500", // accent 2 / highlights
white: "FFFFFF",
light: "D6E4F0",
muted: "8BA3BD",
red: "E84545",
green: "27AE60",
orange: "E67E22",
};
// ── Helper: standard slide background ────────────────────────────────────────
function addBg(slide, color = C.navy) {
slide.background = { color };
}
// ── Helper: header bar ────────────────────────────────────────────────────────
function addHeader(slide, title, subtitle = "") {
// Top accent strip
slide.addShape("rect", { x: 0, y: 0, w: 10, h: 0.08, fill: { color: C.teal }, line: { color: C.teal } });
slide.addText(title, {
x: 0.35, y: 0.14, w: 9.3, h: 0.55,
fontSize: 22, bold: true, color: C.teal, fontFace: "Calibri",
margin: 0,
});
if (subtitle) {
slide.addText(subtitle, {
x: 0.35, y: 0.65, w: 9.3, h: 0.32,
fontSize: 11, color: C.muted, fontFace: "Calibri", italic: true, margin: 0,
});
}
// Divider line
slide.addShape("line", { x: 0.35, y: 0.95, w: 9.3, h: 0, line: { color: C.teal, width: 1 } });
}
// ── Helper: bottom source bar ─────────────────────────────────────────────────
function addSource(slide, text) {
slide.addShape("rect", { x: 0, y: 5.35, w: 10, h: 0.28, fill: { color: C.slate }, line: { color: C.slate } });
slide.addText(text, {
x: 0.3, y: 5.37, w: 9.4, h: 0.22,
fontSize: 7.5, color: C.muted, fontFace: "Calibri", margin: 0,
});
}
// ── Helper: pill badge ────────────────────────────────────────────────────────
function addPill(slide, label, x, y, w = 1.5, bg = C.teal) {
slide.addShape("roundRect", { x, y, w, h: 0.32, fill: { color: bg }, line: { color: bg }, rectRadius: 0.08 });
slide.addText(label, { x, y: y + 0.03, w, h: 0.26, fontSize: 9.5, bold: true, color: C.white, fontFace: "Calibri", align: "center", margin: 0 });
}
// ── Helper: bullet text block ─────────────────────────────────────────────────
function bulletBlock(slide, items, x, y, w, h, opts = {}) {
const rows = items.map((item, i) => ({
text: item,
options: { bullet: { code: "2022" }, breakLine: i < items.length - 1, fontSize: opts.fontSize || 13, color: opts.color || C.white, fontFace: "Calibri", paraSpaceAfter: opts.paraSpaceAfter || 4 }
}));
slide.addText(rows, { x, y, w, h, valign: "top" });
}
// ── Helper: data card ─────────────────────────────────────────────────────────
function dataCard(slide, label, value, unit, x, y, w = 2.1, bg = C.slate) {
slide.addShape("roundRect", { x, y, w, h: 0.9, fill: { color: bg }, line: { color: C.teal, width: 1 }, rectRadius: 0.1 });
slide.addText(label, { x: x + 0.08, y: y + 0.04, w: w - 0.16, h: 0.22, fontSize: 9, color: C.muted, fontFace: "Calibri", margin: 0 });
slide.addText(value, { x: x + 0.08, y: y + 0.26, w: w - 0.16, h: 0.36, fontSize: 20, bold: true, color: C.teal, fontFace: "Calibri", margin: 0 });
slide.addText(unit, { x: x + 0.08, y: y + 0.62, w: w - 0.16, h: 0.22, fontSize: 8.5, color: C.muted, fontFace: "Calibri", margin: 0 });
}
// ═════════════════════════════════════════════════════════════════════════════
// BUILD PRESENTATION
// ═════════════════════════════════════════════════════════════════════════════
const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.author = "Orris Medical";
pres.title = "Cerebral Autoregulation & Anesthetic Effects on CBF";
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 1 — Title Slide
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl);
// Left accent column
sl.addShape("rect", { x: 0, y: 0, w: 0.18, h: 5.625, fill: { color: C.teal }, line: { color: C.teal } });
sl.addShape("rect", { x: 0.18, y: 0, w: 0.06, h: 5.625, fill: { color: C.gold }, line: { color: C.gold } });
sl.addText("Cerebral Autoregulation", {
x: 0.5, y: 1.1, w: 9, h: 0.82,
fontSize: 36, bold: true, color: C.teal, fontFace: "Calibri", margin: 0,
});
sl.addText("& Anesthetic Effects on Cerebral Blood Flow", {
x: 0.5, y: 1.88, w: 9, h: 0.55,
fontSize: 22, color: C.gold, fontFace: "Calibri", margin: 0,
});
sl.addShape("line", { x: 0.5, y: 2.52, w: 5.5, h: 0, line: { color: C.muted, width: 0.75 } });
sl.addText("MD Anesthesia | Neurosurgical Anesthesia", {
x: 0.5, y: 2.62, w: 9, h: 0.32,
fontSize: 13, color: C.muted, fontFace: "Calibri", italic: true, margin: 0,
});
// Sub-topics as small tags
const tags = ["Physiology of CBF", "Autoregulation", "CO₂ & O₂ Reactivity", "Volatile Agents", "IV Agents", "ICP", "CPP"];
tags.forEach((t, i) => {
addPill(sl, t, 0.5 + i * 1.35, 3.3, 1.28, i % 2 === 0 ? C.teal : "1A4060");
});
sl.addText("Sources: Miller's Anesthesia 10e · Barash Clinical Anesthesia 9e · Morgan & Mikhail 7e", {
x: 0.5, y: 5.1, w: 9, h: 0.22,
fontSize: 8, color: C.muted, fontFace: "Calibri", italic: true, margin: 0,
});
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 2 — Normal CBF: Physiology & Key Values
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl);
addHeader(sl, "Normal Cerebral Blood Flow — Key Values", "Miller's Anesthesia 10e, Ch. 10");
// Data cards
const cards = [
["Mean CBF", "50", "mL/100 g/min (PaCO₂ 40 mmHg)"],
["Gray Matter", "80", "mL/100 g/min"],
["White Matter", "20", "mL/100 g/min"],
["Total CBF", "750", "mL/min (15–20% CO)"],
["CMRO₂", "3–4", "mL O₂/100 g/min"],
["Normal ICP", "<15", "mmHg"],
];
cards.forEach(([label, value, unit], i) => {
const row = Math.floor(i / 3);
const col = i % 3;
dataCard(sl, label, value, unit, 0.35 + col * 3.12, 1.1 + row * 1.1, 2.9);
});
// Thresholds section
sl.addText("CBF Thresholds & Brain Function", {
x: 0.35, y: 3.35, w: 9.3, h: 0.3,
fontSize: 13, bold: true, color: C.gold, fontFace: "Calibri", margin: 0,
});
const thresholds = [
{ label: "EEG Slowing", value: "< 20–25", bg: C.orange },
{ label: "Isoelectric EEG", value: "< 20", bg: "#B7410E" },
{ label: "Irreversible Damage", value: "< 10", bg: C.red },
{ label: "MCA TCD Normal", value: "~55", bg: C.green },
{ label: "Vasospasm (TCD)", value: "> 120", bg: C.red },
];
thresholds.forEach((t, i) => {
sl.addShape("roundRect", { x: 0.35 + i * 1.88, y: 3.75, w: 1.75, h: 0.9, fill: { color: t.bg }, line: { color: t.bg }, rectRadius: 0.1 });
sl.addText(t.value + "\nmL/100 g/min", { x: 0.35 + i * 1.88, y: 3.77, w: 1.75, h: 0.46, fontSize: 13, bold: true, color: C.white, fontFace: "Calibri", align: "center", margin: 0 });
sl.addText(t.label, { x: 0.35 + i * 1.88, y: 4.23, w: 1.75, h: 0.38, fontSize: 9, color: C.white, fontFace: "Calibri", align: "center", margin: 0 });
});
addSource(sl, "Miller's Anesthesia 10e, p. 931 | Morgan & Mikhail Clinical Anesthesiology 7e, p. 1075");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 3 — Cerebral Autoregulation: Classic Concept
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl);
addHeader(sl, "Cerebral Autoregulation — Classic (Lassen) Concept", "Miller's Anesthesia 10e, p. 934–936");
// Left: text
sl.addText("Definition", { x: 0.35, y: 1.08, w: 4.5, h: 0.28, fontSize: 12, bold: true, color: C.gold, fontFace: "Calibri", margin: 0 });
sl.addText(
"The intrinsic ability of the cerebral vasculature to maintain a relatively constant CBF (≈50 mL/100 g/min) despite changes in mean arterial pressure (MAP).",
{ x: 0.35, y: 1.36, w: 4.6, h: 0.72, fontSize: 11.5, color: C.white, fontFace: "Calibri", margin: 0 }
);
// Classic curve illustration (simple shapes)
// LLA / ULA labels
sl.addText("Classic Autoregulation Curve", { x: 0.35, y: 2.1, w: 4.5, h: 0.28, fontSize: 12, bold: true, color: C.gold, fontFace: "Calibri", margin: 0 });
const pts = [
{ label: "Lower Limit of Autoregulation (LLA)", val: "MAP ~50–70 mmHg", col: C.orange },
{ label: "Autoregulatory Plateau", val: "MAP 50–150 mmHg | CBF ≈ constant", col: C.green },
{ label: "Upper Limit of Autoregulation (ULA)", val: "MAP ~150 mmHg", col: C.red },
{ label: "Pressure-Passive Flow", val: "Below LLA or above ULA — CBF ∝ MAP", col: C.muted },
];
pts.forEach((p, i) => {
sl.addShape("roundRect", { x: 0.35, y: 2.45 + i * 0.62, w: 0.2, h: 0.4, fill: { color: p.col }, line: { color: p.col }, rectRadius: 0.04 });
sl.addText(p.label, { x: 0.62, y: 2.46 + i * 0.62, w: 4.3, h: 0.22, fontSize: 10.5, bold: true, color: p.col, fontFace: "Calibri", margin: 0 });
sl.addText(p.val, { x: 0.62, y: 2.67 + i * 0.62, w: 4.3, h: 0.2, fontSize: 10, color: C.light, fontFace: "Calibri", margin: 0 });
});
// Right: image
if (imgs[0] && imgs[0].base64) {
sl.addImage({ data: imgs[0].base64, x: 5.15, y: 1.05, w: 4.6, h: 4.15 });
}
addSource(sl, "Miller's Anesthesia 10e, p. 934–937 | Lassen NA, Acta Neurol Scand, 1959");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 4 — Mechanisms of Autoregulation
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl);
addHeader(sl, "Mechanisms Regulating Cerebral Blood Flow", "Miller's Anesthesia 10e, Table 10.1");
const mechanisms = [
{
title: "Myogenic (Pressure)",
color: C.teal,
points: ["Vascular smooth muscle contracts in response to↑ transmural pressure", "Bayliss effect — intrinsic property of vessel wall", "Primary mechanism of static autoregulation", "Operates over MAP 50–150 mmHg"],
},
{
title: "Chemical / Metabolic",
color: C.gold,
points: ["CO₂ is the most potent vasodilator", "PaCO₂ ↑ → vasodilation → ↑CBF (4% per mmHg)", "PaO₂ < 50 mmHg → marked vasodilation", "Hypoxia and hypercarbia both IMPAIR autoregulation"],
},
{
title: "Neurogenic",
color: C.orange,
points: ["Adrenergic: sympathetic activation → vasoconstriction (shifts ULA rightward)", "Cholinergic, serotonergic, VIPergic pathways modulate tone", "Limits CBF surge in acute hypertension", "Reduced capacity for vasodilation during hypotension"],
},
{
title: "Neurovascular Coupling",
color: C.green,
points: ["Regional CBF closely matches local metabolic demand", "Mediators: NO, K⁺, adenosine, CO₂, EETs", "Gray matter CBF 4× white matter", "Basis for functional MRI (BOLD signal)"],
},
];
mechanisms.forEach((m, i) => {
const col = i % 2;
const row = Math.floor(i / 2);
const x = 0.35 + col * 4.82;
const y = 1.1 + row * 2.2;
sl.addShape("roundRect", { x, y, w: 4.55, h: 2.08, fill: { color: C.slate }, line: { color: m.color, width: 1.5 }, rectRadius: 0.12 });
sl.addShape("roundRect", { x, y, w: 4.55, h: 0.4, fill: { color: m.color }, line: { color: m.color }, rectRadius: 0.12 });
sl.addShape("rect", { x, y: y + 0.25, w: 4.55, h: 0.15, fill: { color: m.color }, line: { color: m.color } });
sl.addText(m.title, { x: x + 0.15, y: y + 0.06, w: 4.25, h: 0.3, fontSize: 12, bold: true, color: C.white, fontFace: "Calibri", margin: 0 });
const bulletItems = m.points.map((p, pi) => ({ text: p, options: { bullet: { code: "25B8" }, breakLine: pi < m.points.length - 1, fontSize: 10.5, color: C.white, fontFace: "Calibri", paraSpaceAfter: 3 } }));
sl.addText(bulletItems, { x: x + 0.12, y: y + 0.46, w: 4.3, h: 1.55, valign: "top" });
});
addSource(sl, "Miller's Anesthesia 10e, p. 932–938 | Barash Clinical Anesthesia 9e, p. 1413–1415");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 5 — CO₂ and O₂ Reactivity
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl);
addHeader(sl, "CO₂ and O₂ Reactivity of Cerebral Vessels", "Miller's Anesthesia 10e, p. 940–944");
// CO2 section
sl.addShape("roundRect", { x: 0.35, y: 1.08, w: 4.55, h: 4.15, fill: { color: C.slate }, line: { color: C.teal, width: 1.5 }, rectRadius: 0.12 });
sl.addText("CO₂ Reactivity", { x: 0.45, y: 1.14, w: 4.35, h: 0.34, fontSize: 14, bold: true, color: C.teal, fontFace: "Calibri", margin: 0 });
const co2Items = [
["Most potent physiologic modulator", C.white],
["~4% change in CBF per 1 mmHg PaCO₂", C.teal],
["Linear between PaCO₂ 20–80 mmHg", C.white],
["Mechanism: CO₂ → H⁺ → vasodilation via NO and prostaglandins", C.white],
["Hyperventilation (PaCO₂ ↓) → vasoconstriction → ↓CBF & ↓ICP", C.gold],
["Hypocarbia effect lasts ~4–6 hours (CSF pH equilibration)", C.white],
["PaCO₂ < 20 mmHg → risk of cerebral ischemia (not routinely used)", C.red],
["Anesthetic agents preserve CO₂ reactivity (unlike autoregulation)", C.green],
];
co2Items.forEach(([text, color], i) => {
sl.addText([{ text, options: { bullet: { code: "2022" }, fontSize: 10.5, color, fontFace: "Calibri" } }], {
x: 0.45, y: 1.56 + i * 0.44, w: 4.35, h: 0.42, valign: "top",
});
});
// O2 section
sl.addShape("roundRect", { x: 5.12, y: 1.08, w: 4.55, h: 4.15, fill: { color: C.slate }, line: { color: C.gold, width: 1.5 }, rectRadius: 0.12 });
sl.addText("O₂ Reactivity", { x: 5.22, y: 1.14, w: 4.35, h: 0.34, fontSize: 14, bold: true, color: C.gold, fontFace: "Calibri", margin: 0 });
const o2Items = [
["Normal PaO₂: minimal effect on CBF", C.white],
["PaO₂ < 50–60 mmHg → steep ↑ in CBF", C.orange],
["Hypoxic vasodilation mediated by: adenosine, NO, K⁺ ATP channels", C.white],
["Hyperoxia (PaO₂ >300 mmHg) → mild vasoconstriction (10–15%)", C.white],
["Hypoxia IMPAIRS cerebral autoregulation", C.red],
["Brain tissue O₂ tension (PbtO₂): normal 20–50 mmHg", C.teal],
["PbtO₂ < 20 mmHg → intervention warranted", C.orange],
["PbtO₂ < 10 mmHg → cerebral ischemia", C.red],
];
o2Items.forEach(([text, color], i) => {
sl.addText([{ text, options: { bullet: { code: "2022" }, fontSize: 10.5, color, fontFace: "Calibri" } }], {
x: 5.22, y: 1.56 + i * 0.44, w: 4.35, h: 0.42, valign: "top",
});
});
addSource(sl, "Miller's Anesthesia 10e, p. 940–944 | Morgan & Mikhail 7e, p. 1076");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 6 — Integrated Regulation Diagram (image slide)
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl);
addHeader(sl, "Integrated Regulation of CBF — Contemporary View", "Miller's Anesthesia 10e, Fig. 10.10, p. 966–968");
if (imgs[2] && imgs[2].base64) {
sl.addImage({ data: imgs[2].base64, x: 0.35, y: 1.05, w: 5.5, h: 4.2 });
}
// Key callouts on right
sl.addText("Key Takeaways", { x: 6.05, y: 1.05, w: 3.65, h: 0.32, fontSize: 13, bold: true, color: C.gold, fontFace: "Calibri", margin: 0 });
const takeaways = [
{ text: "Autoregulation is dynamic, not static", color: C.teal },
{ text: "Multiple pathways act simultaneously on cerebral resistance vessels", color: C.white },
{ text: "Anesthetics affect CBF at MULTIPLE levels", color: C.gold },
{ text: "↓Metabolism → indirect vasoconstriction", color: C.green },
{ text: "Direct vasodilation → ↑CBF (volatile agents)", color: C.orange },
{ text: "↓Sympathetic tone → impaired ULA protection", color: C.white },
{ text: "↓Cardiac output → ↓cerebral perfusion", color: C.red },
{ text: "Plateau width varies significantly between individuals", color: C.muted },
];
takeaways.forEach((t, i) => {
sl.addShape("roundRect", { x: 6.05, y: 1.46 + i * 0.45, w: 0.18, h: 0.28, fill: { color: t.color }, line: { color: t.color }, rectRadius: 0.04 });
sl.addText(t.text, { x: 6.28, y: 1.47 + i * 0.45, w: 3.35, h: 0.28, fontSize: 10.5, color: t.color, fontFace: "Calibri", margin: 0 });
});
addSource(sl, "Miller's Anesthesia 10e, Fig. 10.10, p. 966–968");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 7 — Volatile Anesthetic Agents & CBF
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl);
addHeader(sl, "Volatile Anesthetic Agents — Effects on CBF & Autoregulation", "Barash Clinical Anesthesia 9e, p. 1413–1415");
// Image on left
if (imgs[1] && imgs[1].base64) {
sl.addImage({ data: imgs[1].base64, x: 0.3, y: 1.05, w: 5.1, h: 3.5 });
}
sl.addText("CBF vs MAC — volatile agents (normocapnia)", {
x: 0.3, y: 4.55, w: 5.1, h: 0.28,
fontSize: 9, italic: true, color: C.muted, fontFace: "Calibri", align: "center", margin: 0,
});
// Table right
const agents = [
{ name: "Halothane", cbf: "↑↑↑ dose-dep.", cmro2: "↓↓", ar: "Abolished", icp: "↑↑", col: C.red },
{ name: "Isoflurane", cbf: "↑ at >1 MAC", cmro2: "↓↓↓", ar: "Impaired ↑dose", icp: "↑ (mild)", col: C.orange },
{ name: "Sevoflurane", cbf: "Minimal <1 MAC", cmro2: "↓↓↓", ar: "Preserved ≤1 MAC", icp: "↑ minimal", col: C.green },
{ name: "Desflurane", cbf: "Minimal <1 MAC", cmro2: "↓↓", ar: "Impaired ↑dose", icp: "↑ mild", col: C.teal },
{ name: "N₂O", cbf: "↑ (sympathetic)", cmro2: "↑ (metabolic)", ar: "Some impairment", icp: "↑", col: C.muted },
];
// Header row
const hdrs = ["Agent", "CBF", "CMRO₂", "Autoregulation", "ICP"];
const colW = [1.35, 0.9, 0.9, 1.35, 0.72];
const startX = 5.55;
hdrs.forEach((h, i) => {
const xPos = startX + colW.slice(0, i).reduce((a, b) => a + b, 0);
sl.addShape("rect", { x: xPos, y: 1.05, w: colW[i], h: 0.38, fill: { color: C.teal }, line: { color: C.teal } });
sl.addText(h, { x: xPos + 0.04, y: 1.07, w: colW[i] - 0.08, h: 0.3, fontSize: 10, bold: true, color: C.white, fontFace: "Calibri", align: "center", margin: 0 });
});
agents.forEach((ag, ri) => {
const rowY = 1.48 + ri * 0.7;
const rowBg = ri % 2 === 0 ? C.slate : C.navy;
sl.addShape("rect", { x: startX, y: rowY, w: 4.22, h: 0.64, fill: { color: rowBg }, line: { color: rowBg } });
// Left color stripe
sl.addShape("rect", { x: startX, y: rowY, w: 0.06, h: 0.64, fill: { color: ag.col }, line: { color: ag.col } });
const vals = [ag.name, ag.cbf, ag.cmro2, ag.ar, ag.icp];
vals.forEach((v, ci) => {
const xPos = startX + colW.slice(0, ci).reduce((a, b) => a + b, 0);
sl.addText(v, {
x: xPos + (ci === 0 ? 0.1 : 0.04), y: rowY + 0.1, w: colW[ci] - 0.08, h: 0.44,
fontSize: 9.5, color: ci === 0 ? ag.col : C.white, bold: ci === 0, fontFace: "Calibri", align: ci === 0 ? "left" : "center", valign: "middle", margin: 0,
});
});
});
sl.addText("All volatile agents: direct cerebral vasodilators + impair autoregulation dose-dependently", {
x: 5.55, y: 5.05, w: 4.22, h: 0.24,
fontSize: 9, color: C.gold, fontFace: "Calibri", italic: true, align: "center", margin: 0,
});
addSource(sl, "Barash Clinical Anesthesia 9e, Fig. 18-10, p. 1413 | Miller's Anesthesia 10e, p. 946–950");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 8 — Intravenous Anesthetic Agents
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl);
addHeader(sl, "Intravenous Anesthetic Agents — Effects on CBF", "Miller's Anesthesia 10e, p. 950–960");
const agents = [
{
name: "Propofol", color: C.teal,
points: ["↓CBF and ↓CMRO₂ (coupled)", "Preserves autoregulation and CO₂ reactivity", "Preferred for neuroanesthesia TIVA", "↓ICP — favoured in raised ICP management", "Risk: hypotension → ↓CPP if MAP falls"],
},
{
name: "Barbiturates\n(Thiopental)", color: C.gold,
points: ["↓↓CBF and ↓↓CMRO₂ (maximum at EEG silence)", "Preserves autoregulation", "Max CMRO₂ reduction = dose causing isoelectric EEG", "No further ↓CMRO₂ beyond EEG silence", "Barbiturate coma used for ICP rescue"],
},
{
name: "Ketamine", color: C.red,
points: ["↑CBF and ↑CMRO₂ — cerebral vasodilator", "IMPAIRS autoregulation", "↑ICP — traditionally avoided in neurosurgery", "Recent evidence: safe with controlled ventilation", "Preserves CO₂ reactivity"],
},
{
name: "Etomidate", color: C.orange,
points: ["↓CBF and ↓CMRO₂", "Preserves autoregulation and CO₂ reactivity", "Cardiovascular stability — useful for induction", "Adrenocortical suppression limits infusion use", "Increases epileptiform EEG activity"],
},
{
name: "Dexmedetomidine", color: C.green,
points: ["↓CBF modestly (sympatholytic)", "CMRO₂ reduction minimal", "Preserves autoregulation and CO₂ reactivity", "Enhances glymphatic clearance (vs. volatile agents)", "Useful for awake craniotomy sedation"],
},
{
name: "Benzodiazepines\n(Midazolam)", color: C.muted,
points: ["↓CBF and ↓CMRO₂ (mild-moderate)", "Preserves autoregulation", "Plateau effect on CMRO₂ reduction", "Does not cause EEG silence alone", "↓ICP proportional to baseline ICP"],
},
];
agents.forEach((ag, i) => {
const col = i % 3;
const row = Math.floor(i / 3);
const x = 0.35 + col * 3.2;
const y = 1.08 + row * 2.18;
sl.addShape("roundRect", { x, y, w: 3.05, h: 2.05, fill: { color: C.slate }, line: { color: ag.color, width: 1.5 }, rectRadius: 0.1 });
sl.addShape("roundRect", { x, y, w: 3.05, h: 0.38, fill: { color: ag.color }, line: { color: ag.color }, rectRadius: 0.1 });
sl.addShape("rect", { x, y: y + 0.24, w: 3.05, h: 0.14, fill: { color: ag.color }, line: { color: ag.color } });
sl.addText(ag.name, { x: x + 0.1, y: y + 0.05, w: 2.85, h: 0.3, fontSize: 11, bold: true, color: C.white, fontFace: "Calibri", margin: 0 });
const bulletItems = ag.points.map((p, pi) => ({
text: p,
options: { bullet: { code: "25B8" }, breakLine: pi < ag.points.length - 1, fontSize: 9.5, color: C.white, fontFace: "Calibri", paraSpaceAfter: 2 }
}));
sl.addText(bulletItems, { x: x + 0.08, y: y + 0.44, w: 2.9, h: 1.55, valign: "top" });
});
addSource(sl, "Miller's Anesthesia 10e, p. 950–960 | Barash Clinical Anesthesia 9e, Ch. 18");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 9 — ICP, CPP and Monro-Kellie Doctrine
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl);
addHeader(sl, "ICP, CPP & the Monro-Kellie Doctrine", "Miller's Anesthesia 10e, p. 929–930");
// Monro-Kellie box
sl.addShape("roundRect", { x: 0.35, y: 1.1, w: 9.3, h: 0.85, fill: { color: C.slate }, line: { color: C.teal, width: 1.5 }, rectRadius: 0.1 });
sl.addText("Monro-Kellie Doctrine:", { x: 0.55, y: 1.18, w: 2.2, h: 0.3, fontSize: 11.5, bold: true, color: C.teal, fontFace: "Calibri", margin: 0 });
sl.addText(
"The cranium is a rigid, non-expandable box. Its contents — brain parenchyma (~80%), CSF (~10%), and blood (~10%) — are constant in volume. An increase in any component must be compensated by a decrease in another, or ICP rises.",
{ x: 2.75, y: 1.15, w: 6.7, h: 0.72, fontSize: 11, color: C.light, fontFace: "Calibri", margin: 0 }
);
// Left: ICP and CPP
sl.addText("Intracranial Pressure", { x: 0.35, y: 2.08, w: 4.4, h: 0.3, fontSize: 12.5, bold: true, color: C.gold, fontFace: "Calibri", margin: 0 });
const icpItems = [
"Normal ICP: < 15 mmHg",
"Raised ICP: > 20 mmHg (requires intervention)",
"Severe ICP: > 40 mmHg",
"CPP = MAP − ICP (target > 60–70 mmHg)",
"Low CPP → ischaemia; High CPP → hyperaemia + edema",
"Cushing's reflex: severe ICP → hypertension + bradycardia",
];
bulletBlock(sl, icpItems, 0.35, 2.42, 4.45, 2.6, { fontSize: 11 });
// Right: factors and management
sl.addText("Anesthetic Management of ↑ICP", { x: 5.2, y: 2.08, w: 4.5, h: 0.3, fontSize: 12.5, bold: true, color: C.gold, fontFace: "Calibri", margin: 0 });
const mgmt = [
{ label: "AVOID", items: ["Ketamine, high-dose volatile agents", "Coughing, straining, Trendelenburg", "Hypercarbia, hypoxia, hyperthermia", "Suxamethonium (mild ↑ICP)"], color: C.red },
{ label: "USE", items: ["Propofol TIVA or low-dose sevoflurane ≤1 MAC", "Hyperventilation: PaCO₂ 30–35 mmHg", "Head up 15–30°, avoid neck compression", "Mannitol 0.25–1 g/kg, hypertonic saline"], color: C.green },
];
mgmt.forEach((m, i) => {
const y = 2.45 + i * 1.4;
sl.addShape("roundRect", { x: 5.2, y, w: 4.45, h: 1.28, fill: { color: C.slate }, line: { color: m.color, width: 1.5 }, rectRadius: 0.1 });
sl.addText(m.label, { x: 5.3, y: y + 0.06, w: 0.7, h: 0.28, fontSize: 10.5, bold: true, color: m.color, fontFace: "Calibri", margin: 0 });
const bItems = m.items.map((it, pi) => ({
text: it,
options: { bullet: { code: "2022" }, breakLine: pi < m.items.length - 1, fontSize: 10, color: C.white, fontFace: "Calibri", paraSpaceAfter: 2 }
}));
sl.addText(bItems, { x: 5.3, y: y + 0.36, w: 4.25, h: 0.88, valign: "top" });
});
addSource(sl, "Miller's Anesthesia 10e, p. 929–930, 961–965 | Barash Clinical Anesthesia 9e, p. 1413");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 10 — Clinical Scenarios Summary
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl);
addHeader(sl, "High-Yield Clinical Scenarios for Anesthesia Practice", "Miller's Anesthesia 10e · Morgan & Mikhail 7e");
const scenarios = [
{
scenario: "Carotid Endarterectomy",
concern: "ICA cross-clamp → ↓CBF to ipsilateral hemisphere",
strategy: "Maintain MAP at/above awake baseline; TCD/EEG monitoring; use shunt if needed. Avoid hypotension.",
color: C.teal,
},
{
scenario: "Craniotomy for Tumor",
concern: "↑ICP, brain relaxation, herniation risk",
strategy: "TIVA (propofol) preferred. Maintain PaCO₂ 30–35 mmHg. Mannitol/hypertonic saline. Avoid N₂O.",
color: C.gold,
},
{
scenario: "Head Injury (TBI)",
concern: "Impaired autoregulation, pressure-passive CBF",
strategy: "CPP > 60 mmHg; target ICP < 20 mmHg. Avoid hypoxia, hypercarbia, hyperthermia. Barbiturate coma for refractory ICP.",
color: C.red,
},
{
scenario: "Sitting Position Surgery",
concern: "↓Venous return → ↓MAP → ↓CPP; air embolism",
strategy: "Maintain MAP ≥ 60 mmHg at brain level. PEEP cautiously. Precordial Doppler + end-tidal CO₂ monitoring.",
color: C.orange,
},
{
scenario: "Subarachnoid Hemorrhage",
concern: "Vasospasm; impaired autoregulation",
strategy: "TCD monitoring for vasospasm (MCA velocity > 120 cm/s = Lindegaard ratio > 3). Triple-H therapy. Nimodipine.",
color: C.green,
},
{
scenario: "Controlled Hypotension",
concern: "Below LLA → pressure-passive CBF; ischaemia",
strategy: "Keep MAP ≥ 50–60 mmHg. NB: LLA shifts rightward in chronic hypertension. Monitor EEG/NIRS.",
color: C.muted,
},
];
scenarios.forEach((sc, i) => {
const col = i % 2;
const row = Math.floor(i / 2);
const x = 0.35 + col * 4.85;
const y = 1.1 + row * 1.48;
sl.addShape("roundRect", { x, y, w: 4.6, h: 1.38, fill: { color: C.slate }, line: { color: sc.color, width: 1.5 }, rectRadius: 0.1 });
sl.addShape("roundRect", { x, y, w: 4.6, h: 0.34, fill: { color: sc.color }, line: { color: sc.color }, rectRadius: 0.1 });
sl.addShape("rect", { x, y: y + 0.22, w: 4.6, h: 0.12, fill: { color: sc.color }, line: { color: sc.color } });
sl.addText(sc.scenario, { x: x + 0.1, y: y + 0.04, w: 4.4, h: 0.28, fontSize: 11, bold: true, color: C.white, fontFace: "Calibri", margin: 0 });
sl.addText("⚠ " + sc.concern, { x: x + 0.1, y: y + 0.4, w: 4.4, h: 0.3, fontSize: 9.5, color: sc.color, fontFace: "Calibri", italic: true, margin: 0 });
sl.addText("→ " + sc.strategy, { x: x + 0.1, y: y + 0.68, w: 4.4, h: 0.64, fontSize: 9.5, color: C.white, fontFace: "Calibri", margin: 0 });
});
addSource(sl, "Miller's Anesthesia 10e | Morgan & Mikhail 7e, p. 1075–1078 | Barash Clinical Anesthesia 9e");
}
// ─────────────────────────────────────────────────────────────────────────────
// SLIDE 11 — Summary Comparison Table
// ─────────────────────────────────────────────────────────────────────────────
{
const sl = pres.addSlide();
addBg(sl);
addHeader(sl, "Summary: Anesthetic Effects on Cerebral Physiology", "Quick Reference for MD Anesthesia Exam");
const headers = ["Agent", "CBF", "CMRO₂", "Autoregulation", "CO₂ React.", "ICP", "Best Use"];
const colWidths = [1.55, 0.85, 0.85, 1.25, 0.9, 0.75, 1.4];
const rows = [
["Propofol", "↓", "↓↓", "Preserved", "Preserved", "↓", "Neuro TIVA", C.teal],
["Thiopental", "↓↓", "↓↓↓", "Preserved", "Preserved", "↓↓", "ICP rescue", C.gold],
["Isoflurane", "↑>1MAC","↓↓", "Impaired dose", "Preserved", "↑", "General anesthesia",C.orange],
["Sevoflurane", "Min", "↓↓", "≤1MAC OK", "Preserved", "↑min","Neuro (low dose)", C.green],
["Desflurane", "Min", "↓", "Impaired", "Preserved", "↑", "General", C.teal],
["Ketamine", "↑↑", "↑", "Impaired", "Preserved", "↑↑", "Avoid in ↑ICP", C.red],
["Dexmedetomidine","↓mod", "Min", "Preserved", "Preserved", "↓", "Awake craniotomy", C.green],
["N₂O", "↑", "↑", "Some impair.", "Preserved", "↑", "Avoid neuro", C.muted],
];
// Header row
let xCur = 0.25;
headers.forEach((h, i) => {
sl.addShape("rect", { x: xCur, y: 1.05, w: colWidths[i], h: 0.38, fill: { color: C.teal }, line: { color: C.teal } });
sl.addText(h, { x: xCur + 0.03, y: 1.07, w: colWidths[i] - 0.06, h: 0.3, fontSize: 9.5, bold: true, color: C.white, fontFace: "Calibri", align: "center", margin: 0 });
xCur += colWidths[i];
});
rows.forEach((row, ri) => {
const color = row[8] || C.teal;
const rowY = 1.48 + ri * 0.46;
const rowBg = ri % 2 === 0 ? C.slate : C.navy;
sl.addShape("rect", { x: 0.25, y: rowY, w: 9.55, h: 0.42, fill: { color: rowBg }, line: { color: rowBg } });
sl.addShape("rect", { x: 0.25, y: rowY, w: 0.06, h: 0.42, fill: { color: color }, line: { color: color } });
let xC = 0.25;
row.slice(0, 7).forEach((cell, ci) => {
const cellColor = ci === 0 ? color : (
cell.includes("↑↑") ? C.red : cell.includes("↑") ? C.orange :
cell.includes("↓↓") ? C.green : cell.includes("↓") ? "#4FC3F7" :
cell === "Preserved" ? C.green : cell.includes("Impaired") ? C.orange :
cell.includes("Avoid") ? C.red : C.white
);
sl.addText(cell, {
x: xC + (ci === 0 ? 0.1 : 0.03), y: rowY + 0.04, w: colWidths[ci] - 0.1, h: 0.34,
fontSize: ci === 0 ? 10 : 9.5, bold: ci === 0, color: cellColor, fontFace: "Calibri",
align: ci === 0 ? "left" : "center", valign: "middle", margin: 0,
});
xC += colWidths[ci];
});
});
sl.addText("Green = favourable for neurosurgery | Orange = use with caution | Red = generally avoid in raised ICP", {
x: 0.25, y: 5.2, w: 9.5, h: 0.22,
fontSize: 8.5, color: C.muted, fontFace: "Calibri", italic: true, align: "center", margin: 0,
});
addSource(sl, "Miller's Anesthesia 10e | Barash Clinical Anesthesia 9e | Morgan & Mikhail Clinical Anesthesiology 7e");
}
// ─────────────────────────────────────────────────────────────────────────────
// Write file
// ─────────────────────────────────────────────────────────────────────────────
const outPath = "/home/daytona/workspace/dm-anaesthesia/cerebral-autoregulation/Cerebral_Autoregulation_Anesthesia.pptx";
pres.writeFile({ fileName: outPath }).then(() => {
console.log("✓ Saved:", outPath);
}).catch(err => {
console.error("Error:", err);
process.exit(1);
});