make wrist joint anatomy mri radiology teaching ppt from textbook include all images from textbook and also need pathologies covered with images

Reading File
Reading File
Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Running Command

ls -la /home/daytona/workspace/ && mkdir -p /home/daytona/workspace/wrist-mri-ppt

Writing File

~/wrist-mri-ppt/build.js

const pptxgen = require("pptxgenjs");
const { execSync } = require("child_process");

const pres = new pptxgen();
pres.layout = "LAYOUT_WIDE";
pres.title = "Wrist Joint Anatomy & MRI Radiology Teaching";
pres.author = "Radiology Teaching Series";

// ── Colour Palette ──────────────────────────────────────────────
const C = {
  navy:    "0D1B2A",
  teal:    "1B4F72",
  accent:  "2E86AB",
  gold:    "F0A500",
  white:   "FFFFFF",
  light:   "E8F4F8",
  gray:    "5D6D7E",
  darkbg:  "0A1628",
  red:     "C0392B",
  green:   "1A8754",
};

// ── Helper: fetch images via the skill script ────────────────────
function fetchImgs(urls) {
  try {
    const raw = execSync(
      `node /home/daytona/skills/shared/scripts/fetch_images.js ${urls.map(u => `"${u}"`).join(" ")}`,
      { maxBuffer: 100 * 1024 * 1024 }
    ).toString();
    return JSON.parse(raw);
  } catch (e) {
    console.error("fetch error:", e.message);
    return urls.map(u => ({ url: u, base64: null, error: e.message }));
  }
}

// ── All image URLs from the textbooks ───────────────────────────
const IMG = {
  // Imaging Anatomy Vol 3 – Wrist MRI
  tfcc_diagram:      "https://cdn.orris.care/cdss_images/74c5c3d44a775cd359b10c7da5df2cf5fd5beadc7195fa5a40d46a6e3c19a6b2.png",
  tfcc_mri:          "https://cdn.orris.care/cdss_images/728fdddb16dba69fd80ff6107ee9866bff0251439ff1095c3e7f9d2b54175535.png",
  tfcc_serial_mri:   "https://cdn.orris.care/cdss_images/6a86bc75f1de7ee4d138bd37c4cf7be5170f5ca41118bb340b41b07050470e4d.png",
  ulnar_tunnel_ax:   "https://cdn.orris.care/cdss_images/b68c6069612407d66eea841f6bacf764578226eb4e0249ec7624786ae094973f.png",
  ulnar_tunnel_sag:  "https://cdn.orris.care/cdss_images/63e3c56e7ad03e0abe54c88d451ac7db7e401c6b489742db9745464ca64e4aeb.png",
  median_artery:     "https://cdn.orris.care/cdss_images/131d19e092e7b60fe0a1ec05d9b5727d6bdac8facd4a39640cdc677d0f21c149.png",
  palmar_arch:       "https://cdn.orris.care/cdss_images/63077a68f55385c8adad2a992c2e3c423123cd9863424b428fbb1b30f04e010a.png",
  incomplete_arch:   "https://cdn.orris.care/cdss_images/5d40a4268c4fa6ee44701a7d99cbb3a7f16976a16e8c05e2333dc41aa48e5d30.png",
  // Grainger & Allison – Carpal pathology
  scaphoid_xr:       "https://cdn.orris.care/cdss_images/186232014c447155208a58861d61bc15b9d9d745054f653028bbdaa8f0e6230c.png",
  scaphoid_avn_mri:  "https://cdn.orris.care/cdss_images/f2a5604bd7ed13f4cfcf96589c9e838f09f09c4371d2cf7070c7c8d3ff093e93.png",
  scaphoid_supply:   "https://cdn.orris.care/cdss_images/820515d7b8940d00c4f23b4125929d9dfd8433a76841294886ab84472966089e.png",
};

// Pre-fetch all images
console.log("Fetching images...");
const keys = Object.keys(IMG);
const urls = keys.map(k => IMG[k]);
const fetched = fetchImgs(urls);
const imgData = {};
keys.forEach((k, i) => { imgData[k] = fetched[i]; });
console.log("Images fetched:", keys.map(k => `${k}: ${imgData[k]?.error ? "ERROR" : "OK"}`).join(", "));

// ── Slide helpers ────────────────────────────────────────────────
function addTitleBar(slide, title, subtitle) {
  // dark bg bar across top
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 1.1, fill: { color: C.navy } });
  slide.addText(title, { x: 0.3, y: 0.08, w: 10, h: 0.6, fontSize: 22, bold: true, color: C.white, fontFace: "Calibri", margin: 0 });
  if (subtitle) {
    slide.addText(subtitle, { x: 0.3, y: 0.68, w: 11, h: 0.4, fontSize: 13, color: C.gold, fontFace: "Calibri", italic: true, margin: 0 });
  }
  // accent line
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 1.1, w: 13.3, h: 0.05, fill: { color: C.gold } });
}

function addSectionLabel(slide, label, x, y) {
  slide.addShape(pres.ShapeType.rect, { x, y, w: 2.5, h: 0.32, fill: { color: C.accent }, line: { color: C.accent } });
  slide.addText(label, { x, y: y + 0.04, w: 2.5, h: 0.32, fontSize: 10, bold: true, color: C.white, align: "center", fontFace: "Calibri", margin: 0 });
}

function addImg(slide, key, x, y, w, h) {
  const d = imgData[key];
  if (d && d.base64 && !d.error) {
    slide.addImage({ data: d.base64, x, y, w, h });
  } else {
    slide.addShape(pres.ShapeType.rect, { x, y, w, h, fill: { color: "CCCCCC" }, line: { color: "999999" } });
    slide.addText(`[Image: ${key}]`, { x, y: y + h/2 - 0.15, w, h: 0.3, fontSize: 9, color: C.gray, align: "center" });
  }
}

function addCaption(slide, text, x, y, w) {
  slide.addText(text, { x, y, w, h: 0.45, fontSize: 8.5, color: C.gray, italic: true, fontFace: "Calibri", wrap: true });
}

function addBullets(slide, items, x, y, w, h, size = 13) {
  const parts = items.map((t, i) => ({ text: t, options: { bullet: { code: "25CF" }, breakLine: i < items.length - 1 } }));
  slide.addText(parts, { x, y, w, h, fontSize: size, color: C.navy, fontFace: "Calibri", lineSpacingMultiple: 1.3 });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 1 – TITLE SLIDE
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.darkbg } });
  // decorative gradient band
  s.addShape(pres.ShapeType.rect, { x: 0, y: 2.8, w: 13.3, h: 0.08, fill: { color: C.gold } });
  s.addShape(pres.ShapeType.rect, { x: 0, y: 2.88, w: 13.3, h: 2.2, fill: { color: C.teal } });

  s.addText("WRIST JOINT", { x: 0.6, y: 0.5, w: 12, h: 1.1, fontSize: 54, bold: true, color: C.white, fontFace: "Calibri", charSpacing: 6 });
  s.addText("ANATOMY & MRI RADIOLOGY", { x: 0.6, y: 1.5, w: 12, h: 0.9, fontSize: 34, bold: true, color: C.gold, fontFace: "Calibri" });
  s.addText("A Comprehensive Teaching Atlas", { x: 0.6, y: 2.95, w: 12, h: 0.55, fontSize: 20, color: C.white, fontFace: "Calibri", italic: true });
  s.addText("Normal Anatomy  ·  Imaging Sequences  ·  Ligamentous Anatomy  ·  TFCC  ·  Pathologies", {
    x: 0.6, y: 3.48, w: 12, h: 0.7, fontSize: 14, color: C.light, fontFace: "Calibri"
  });
  s.addText("Source: Imaging Anatomy – Bones, Joints, Vessels & Nerves (Thieme) | Grainger & Allison's Diagnostic Radiology", {
    x: 0.6, y: 6.9, w: 12, h: 0.4, fontSize: 10, color: C.gray, fontFace: "Calibri", italic: true
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 2 – OVERVIEW / CONTENTS
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.light } });
  addTitleBar(s, "Contents", "What this presentation covers");

  const topics = [
    ["01", "Osseous Anatomy of the Wrist", "Carpal bones, distal radius & ulna"],
    ["02", "Wrist Joint Compartments", "Radiocarpal, midcarpal, DRUJ, pisiform-triquetral"],
    ["03", "Ligamentous Anatomy", "Intrinsic & extrinsic ligaments – MRI correlation"],
    ["04", "TFCC – Triangular Fibrocartilage Complex", "Anatomy, components, MRI sequences"],
    ["05", "Tendons & Tendon Sheaths", "Flexor & extensor compartments on MRI"],
    ["06", "Neurovascular Anatomy", "Median nerve, ulnar nerve/artery, Guyon's canal"],
    ["07", "MRI Protocols & Sequences", "T1, T2, PD, STIR, MR arthrography"],
    ["08", "Pathology – TFCC Tears", "Palmer classification, MRI features"],
    ["09", "Pathology – Ligament Injuries", "SLL, LTL tears; DISI/VISI patterns"],
    ["10", "Pathology – Scaphoid & Carpal Fractures", "Occult fractures, AVN, non-union"],
    ["11", "Pathology – Carpal Instability", "SLAC, SNAC, DISI, VISI"],
    ["12", "Pathology – Carpal Tunnel Syndrome", "MRI findings, space-occupying lesions"],
  ];

  topics.forEach(([num, title, sub], i) => {
    const col = i < 6 ? 0 : 1;
    const row = i % 6;
    const x = col === 0 ? 0.3 : 6.9;
    const y = 1.35 + row * 0.98;
    s.addShape(pres.ShapeType.rect, { x, y, w: 6.2, h: 0.82, fill: { color: C.white }, line: { color: C.accent, pt: 1 } });
    s.addShape(pres.ShapeType.rect, { x, y, w: 0.52, h: 0.82, fill: { color: col === 0 ? C.teal : C.accent } });
    s.addText(num, { x: x + 0.01, y: y + 0.2, w: 0.52, h: 0.4, fontSize: 14, bold: true, color: C.white, align: "center", margin: 0 });
    s.addText(title, { x: x + 0.62, y: y + 0.07, w: 5.4, h: 0.38, fontSize: 12, bold: true, color: C.navy, fontFace: "Calibri", margin: 0 });
    s.addText(sub, { x: x + 0.62, y: y + 0.44, w: 5.4, h: 0.3, fontSize: 10, color: C.gray, fontFace: "Calibri", italic: true, margin: 0 });
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 3 – OSSEOUS ANATOMY
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.white } });
  addTitleBar(s, "Osseous Anatomy of the Wrist", "Eight carpal bones arranged in two rows");

  // Left column – text
  addSectionLabel(s, "PROXIMAL ROW", 0.3, 1.3);
  addBullets(s, [
    "Scaphoid (navicular) – largest carpal bone, bridges both rows",
    "Lunate – articulates with radius; key to carpal kinematics",
    "Triquetrum – pyramidal; articulates with TFCC inferiorly",
    "Pisiform – sesamoid bone within FCU tendon",
  ], 0.3, 1.7, 5.5, 1.9, 12);

  addSectionLabel(s, "DISTAL ROW", 0.3, 3.7);
  addBullets(s, [
    "Trapezium – articulates with 1st metacarpal (saddle joint)",
    "Trapezoid – smallest carpal bone; very stable",
    "Capitate – largest; keystone of the arch; axis of rotation",
    "Hamate – hook (hamulus) forms ulnar wall of carpal tunnel",
  ], 0.3, 4.1, 5.5, 1.9, 12);

  addSectionLabel(s, "DISTAL RADIUS & ULNA", 0.3, 6.15);
  s.addText("Distal radius: radial styloid, scaphoid/lunate facets, sigmoid notch | Distal ulna: ulnar styloid, ulnar head", {
    x: 0.3, y: 6.5, w: 5.5, h: 0.6, fontSize: 10.5, color: C.gray, italic: true, fontFace: "Calibri"
  });

  // Right column – image placeholder + anatomy table
  s.addShape(pres.ShapeType.rect, { x: 6.2, y: 1.3, w: 6.8, h: 3.2, fill: { color: C.light }, line: { color: C.accent, pt: 1 } });
  s.addText("Wrist Osseous Anatomy", { x: 6.2, y: 2.5, w: 6.8, h: 0.5, fontSize: 13, color: C.teal, align: "center", bold: true });
  s.addText("8 Carpal Bones · Distal Radius · Distal Ulna", { x: 6.2, y: 3.0, w: 6.8, h: 0.4, fontSize: 11, color: C.gray, align: "center", italic: true });

  // Mnemonic box
  s.addShape(pres.ShapeType.rect, { x: 6.2, y: 4.65, w: 6.8, h: 2.55, fill: { color: C.navy }, line: { color: C.gold, pt: 2 } });
  s.addText("Memory Aid", { x: 6.3, y: 4.72, w: 6.6, h: 0.4, fontSize: 13, bold: true, color: C.gold });
  s.addText('"Some Lovers Try Positions That They Cannot Handle"', {
    x: 6.3, y: 5.12, w: 6.6, h: 0.5, fontSize: 13, bold: true, color: C.white, italic: true
  });
  s.addText("Scaphoid · Lunate · Triquetrum · Pisiform\nTrapezium · Trapezoid · Capitate · Hamate", {
    x: 6.3, y: 5.65, w: 6.6, h: 0.75, fontSize: 11, color: C.light, fontFace: "Calibri"
  });
  s.addText("(Proximal row → Distal row, lateral to medial)", {
    x: 6.3, y: 6.45, w: 6.6, h: 0.4, fontSize: 10, color: C.gold, italic: true
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 4 – WRIST JOINT COMPARTMENTS
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.white } });
  addTitleBar(s, "Wrist Joint Compartments", "Three major non-communicating compartments");

  const comps = [
    { label: "Radiocarpal Joint", color: C.teal, points: [
        "Between distal radius and proximal carpal row (scaphoid, lunate, triquetrum)",
        "Separated from DRUJ by the TFCC",
        "Communicates with pisiform-triquetral joint in ~50%",
        "Key ligaments: radioscaphocapitate, long/short radiolunate, ulnocarpal",
      ]},
    { label: "Midcarpal Joint", color: C.accent, points: [
        "Between proximal and distal carpal rows",
        "Complex S-shaped articulation",
        "Receives contribution from scaphoid, lunate, triquetrum proximally",
        "Stabilised by intrinsic interosseous and extrinsic ligaments",
      ]},
    { label: "Distal Radioulnar Joint (DRUJ)", color: C.gold, points: [
        "Pivot joint between sigmoid notch of radius and ulnar head",
        "Allows forearm pronation/supination (70–80°)",
        "Stabilised by TFCC (primary stabiliser) and interosseous membrane",
        "Isolated DRUJ effusion on MRI → TFCC tear until proven otherwise",
      ]},
  ];

  comps.forEach((c, i) => {
    const y = 1.35 + i * 1.95;
    s.addShape(pres.ShapeType.rect, { x: 0.3, y, w: 12.7, h: 1.75, fill: { color: C.light }, line: { color: c.color, pt: 2 } });
    s.addShape(pres.ShapeType.rect, { x: 0.3, y, w: 3.0, h: 1.75, fill: { color: c.color } });
    s.addText(c.label, { x: 0.35, y: y + 0.55, w: 2.9, h: 0.65, fontSize: 13, bold: true, color: C.white, align: "center", fontFace: "Calibri" });
    const bullets = c.points.map((t, j) => ({ text: t, options: { bullet: true, breakLine: j < c.points.length - 1 } }));
    s.addText(bullets, { x: 3.5, y: y + 0.2, w: 9.2, h: 1.35, fontSize: 11.5, color: C.navy, fontFace: "Calibri", lineSpacingMultiple: 1.25 });
  });

  // Footer note
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 7.0, w: 12.7, h: 0.35, fill: { color: C.navy } });
  s.addText("Pisiform-Triquetral joint & common carpometacarpal (CMC) joint are additional compartments evaluated on MR arthrography", {
    x: 0.3, y: 7.0, w: 12.7, h: 0.35, fontSize: 10, color: C.gold, align: "center", fontFace: "Calibri"
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 5 – LIGAMENTOUS ANATOMY
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.white } });
  addTitleBar(s, "Ligamentous Anatomy of the Wrist", "Intrinsic & extrinsic ligaments – MRI correlation");

  // Intrinsic
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.3, w: 6.0, h: 2.85, fill: { color: C.light }, line: { color: C.teal, pt: 1.5 } });
  addSectionLabel(s, "INTRINSIC LIGAMENTS", 0.3, 1.3);
  addBullets(s, [
    "Scapholunate ligament (SLL) – C-shaped, dorsal band strongest",
    "Lunotriquetral ligament (LTL) – membranous > volar > dorsal",
    "Scaphotrapeziotrapezoid ligament (STT)",
    "Triquetrohamate, capitotrapezoid ligaments",
    "MRI: Low signal; best seen on coronal PD-fat-sat or MR arthrogram",
  ], 0.45, 1.72, 5.7, 2.1, 11.5);

  // Extrinsic
  s.addShape(pres.ShapeType.rect, { x: 7.0, y: 1.3, w: 6.0, h: 2.85, fill: { color: C.light }, line: { color: C.accent, pt: 1.5 } });
  addSectionLabel(s, "EXTRINSIC LIGAMENTS", 7.0, 1.3);
  addBullets(s, [
    "Volar (Palmar): Stronger & more numerous than dorsal",
    "  · Radioscaphocapitate (RSC) – most important volar stabiliser",
    "  · Long radiolunate (LRL), Short radiolunate (SRL)",
    "  · Ulnocarpal: ulnolunate, ulnotriquetral, ulnocapitate",
    "Dorsal: Radiotriquetral (DRC), dorsal intercarpal (DIC)",
  ], 7.15, 1.72, 5.7, 2.1, 11.5);

  // MRI tips box
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 4.3, w: 12.7, h: 2.9, fill: { color: C.navy }, line: { color: C.gold, pt: 2 } });
  s.addText("MRI Evaluation of Wrist Ligaments", { x: 0.5, y: 4.38, w: 12.3, h: 0.45, fontSize: 15, bold: true, color: C.gold });
  const mriTips = [
    "Best plane: CORONAL – shows SLL, LTL, TFCC en face",
    "Best sequences: PD fat-sat (high contrast for tears) | T2* GRE (thin slices, articular cartilage)",
    "MR arthrography: Gold standard – contrast extravasation through torn ligament into adjacent compartment",
    "SLL tear → contrast from radiocarpal → midcarpal joint | LTL tear → midcarpal → radiocarpal",
    "Slice thickness: ≤2 mm recommended; 3T preferred over 1.5T for intrinsic ligaments",
  ];
  mriTips.forEach((t, i) => {
    const parts = [
      { text: "▸ ", options: { bold: true, color: C.gold } },
      { text: t, options: { color: C.white } },
    ];
    s.addText(parts, { x: 0.5, y: 4.88 + i * 0.43, w: 12.3, h: 0.38, fontSize: 11.5, fontFace: "Calibri" });
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 6 – TFCC ANATOMY (with images)
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.white } });
  addTitleBar(s, "Triangular Fibrocartilage Complex (TFCC)", "Anatomy, components & MRI – Imaging Anatomy Vol. 3");

  // Image 1 – TFCC diagram (coronal section)
  addImg(s, "tfcc_diagram", 0.3, 1.3, 4.2, 3.0);
  addCaption(s, "Fig 17.34: TFCC coronal section. TFC proper originates from sigmoid notch, inserts on ulnar fovea via proximal & distal laminae. Meniscus homologue (MH) = part of distal lamina.", 0.3, 4.35, 4.2);

  // Image 2 – TFCC MRI coronal
  addImg(s, "tfcc_mri", 4.7, 1.3, 3.9, 3.0);
  addCaption(s, "Fig 17.35a-b: MRI coronal views – TFC (star), proximal lamina (arrowhead), distal lamina (thick arrow). Ligamentum subcruentum = high-signal region between laminae.", 4.7, 4.35, 3.9);

  // Image 3 – TFCC serial MRI
  addImg(s, "tfcc_serial_mri", 8.8, 1.3, 4.2, 3.0);
  addCaption(s, "Fig 17.35c-g: Serial coronal (dorsal→palmar) & axial MRI. vRUL & dRUL converge toward fovea. S=ulnar styloid; UCL=ulnar collateral ligament.", 8.8, 4.35, 4.2);

  // Components table
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 5.1, w: 12.7, h: 2.15, fill: { color: C.navy } });
  s.addText("TFCC Components", { x: 0.5, y: 5.18, w: 12.3, h: 0.38, fontSize: 14, bold: true, color: C.gold });
  const comps2 = [
    ["TFC proper (articular disk)", "Biconcave fibrocartilage; radial origin (sigmoid notch) → ulnar insertion (fovea + styloid)"],
    ["Dorsal & Volar radioulnar ligaments", "Primary DRUJ stabilisers; converge at fovea (deep fibers) and styloid (superficial)"],
    ["Meniscus homologue (UMH)", "Dense fibrous tissue; connects TFC → UCL → ECU sheath"],
    ["Ulnar collateral ligament (UCL)", "Reinforces ulnar aspect; 3 components: styloid, radioulnar, collateral"],
    ["ECU subsheath", "6th extensor compartment; integral part of TFCC stability"],
  ];
  comps2.forEach(([name, desc], i) => {
    s.addText([
      { text: name + ": ", options: { bold: true, color: C.gold } },
      { text: desc, options: { color: C.white } },
    ], { x: 0.5, y: 5.6 + i * 0.33, w: 12.3, h: 0.3, fontSize: 10.5, fontFace: "Calibri" });
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 7 – TENDONS ON MRI
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.white } });
  addTitleBar(s, "Tendons & Tendon Sheaths – MRI Anatomy", "Flexor & extensor compartments at the wrist");

  // Extensor compartments
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.3, w: 5.9, h: 5.9, fill: { color: C.light }, line: { color: C.teal, pt: 1.5 } });
  addSectionLabel(s, "EXTENSOR COMPARTMENTS (6)", 0.3, 1.3);
  const exts = [
    ["1st", "APL + EPB", "De Quervain's tenosynovitis site"],
    ["2nd", "ECRL + ECRB", "Intersection syndrome (2nd/1st)"],
    ["3rd", "EPL", "Passes around Lister's tubercle"],
    ["4th", "EDC + EIP", "Largest compartment"],
    ["5th", "EDM (EDQ)", "Over DRUJ"],
    ["6th", "ECU", "Integral part of TFCC"],
  ];
  s.addText("Compartment  |  Tendon(s)  |  Clinical note", {
    x: 0.4, y: 1.78, w: 5.7, h: 0.35, fontSize: 10, bold: true, color: C.teal, fontFace: "Calibri"
  });
  exts.forEach(([c, t, n], i) => {
    const bg = i % 2 === 0 ? C.white : "#D6EAF8";
    s.addShape(pres.ShapeType.rect, { x: 0.35, y: 2.13 + i * 0.72, w: 5.8, h: 0.68, fill: { color: bg } });
    s.addText([
      { text: c, options: { bold: true, color: C.teal } },
      { text: "  " + t, options: { color: C.navy } },
    ], { x: 0.42, y: 2.2 + i * 0.72, w: 2.5, h: 0.5, fontSize: 11, fontFace: "Calibri" });
    s.addText(n, { x: 2.95, y: 2.2 + i * 0.72, w: 3.1, h: 0.5, fontSize: 10, color: C.gray, italic: true, fontFace: "Calibri" });
  });

  // Flexor compartments
  s.addShape(pres.ShapeType.rect, { x: 6.5, y: 1.3, w: 6.5, h: 5.9, fill: { color: C.light }, line: { color: C.accent, pt: 1.5 } });
  addSectionLabel(s, "FLEXOR TENDONS & CARPAL TUNNEL", 6.5, 1.3);
  s.addText("Contents of the carpal tunnel (deep to flexor retinaculum):", {
    x: 6.65, y: 1.78, w: 6.2, h: 0.38, fontSize: 11, bold: true, color: C.accent, fontFace: "Calibri"
  });
  addBullets(s, [
    "4 tendons of FDS (flexor digitorum superficialis)",
    "4 tendons of FDP (flexor digitorum profundus)",
    "1 tendon of FPL (flexor pollicis longus)",
    "Median nerve (most superficial & radial)",
    "Occasionally: persistent median artery",
  ], 6.65, 2.2, 6.2, 2.1, 12);

  s.addText("Guyon's Canal (Ulnar tunnel):", {
    x: 6.65, y: 4.4, w: 6.2, h: 0.38, fontSize: 11, bold: true, color: C.teal
  });
  addBullets(s, [
    "Bounded by pisiform (medial) & hook of hamate (lateral)",
    "Contains: ulnar nerve + ulnar artery",
    "Ulnar nerve divides into superficial (sensory) and deep (motor) branches",
    "Zone I: proximal to bifurcation | Zone II: deep motor | Zone III: superficial",
  ], 6.65, 4.82, 6.2, 1.8, 11.5);
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 8 – NEUROVASCULAR ANATOMY (with images)
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.white } });
  addTitleBar(s, "Neurovascular Anatomy – MRI", "Persistent median artery, Guyon's canal & palmar arches");

  // Image – Persistent median artery
  addImg(s, "median_artery", 0.3, 1.3, 4.5, 2.8);
  addCaption(s, "Fig 4.32: Persistent median artery (arrows) – axial MRI series showing the artery running with the median nerve in the carpal tunnel. Seen in ~10% of individuals; can compress median nerve.", 0.3, 4.15, 4.5);

  // Image – Guyon's canal axial
  addImg(s, "ulnar_tunnel_ax", 5.1, 1.3, 4.0, 2.8);
  addCaption(s, "Fig 17.53: Axial MRI series of the ulnar tunnel (Guyon's canal). Trifurcation of ulnar nerve shown. Deep branch (motor) passes through pisohamate hiatus. ABDM=abductor digiti minimi; FCU; H=hamate hook; P=pisiform.", 5.1, 4.15, 4.0);

  // Image – Guyon's canal sagittal
  addImg(s, "ulnar_tunnel_sag", 9.3, 1.3, 3.7, 2.8);
  addCaption(s, "Fig 17.53 (cont.): Sagittal MRI views – pisohamate hiatus and deep branch of ulnar nerve entering deep palmar space. PHL=pisohamate ligament.", 9.3, 4.15, 3.7);

  // Summary box
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 5.15, w: 12.7, h: 2.1, fill: { color: C.navy } });
  s.addText("Key Neurovascular Points on MRI", { x: 0.5, y: 5.22, w: 12.3, h: 0.4, fontSize: 14, bold: true, color: C.gold });
  const nv = [
    "Radial artery crosses scaphoid in anatomical snuff box → anastomoses with deep palmar arch → critical supply to scaphoid proximal pole",
    "Persistent median artery: present in ~10%; associated with carpal tunnel syndrome; hypervascular variant can cause symptoms",
    "Guyon's canal: Zone I lesions affect motor + sensory; Zone II = pure motor (hypothenar wasting); Zone III = pure sensory",
    "MRI: Normal nerve = intermediate T1/T2 signal; compressed nerve shows T2 hyperintensity, swelling, loss of fascicular pattern",
  ];
  nv.forEach((t, i) => {
    s.addText([
      { text: "▸ ", options: { bold: true, color: C.gold } },
      { text: t, options: { color: C.white } },
    ], { x: 0.5, y: 5.67 + i * 0.37, w: 12.3, h: 0.33, fontSize: 10.5, fontFace: "Calibri" });
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 9 – MRI PROTOCOLS
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.white } });
  addTitleBar(s, "MRI Protocols & Sequences for the Wrist", "Recommended sequences, planes & indications");

  const seqs = [
    { seq: "T1 Coronal", use: "Bone anatomy, AVN (low signal marrow), ligament morphology", tip: "Fat is bright; bone marrow is bright in adults" },
    { seq: "PD Fat-Sat Coronal", use: "Gold standard for TFCC, SLL, LTL tears; bone marrow oedema", tip: "Most sensitive sequence for intrinsic ligament pathology" },
    { seq: "T2 / PD Axial", use: "Carpal tunnel contents, nerve, tendons, synovitis", tip: "Fluid is bright; tenosynovitis easily identified" },
    { seq: "STIR Coronal", use: "Occult scaphoid fractures, bone marrow oedema, AVN", tip: "Highly sensitive; fluid = bright; fat suppressed" },
    { seq: "T2* GRE (3D)", use: "Thin-slice articular cartilage, intrinsic ligaments", tip: "Sub-mm slices; reformats in any plane" },
    { seq: "MR Arthrography", use: "Gold standard for partial/full ligament tears; TFCC grading", tip: "Gadolinium injected into radiocarpal joint; 3-compartment study best" },
  ];

  seqs.forEach((r, i) => {
    const y = 1.35 + i * 1.0;
    const col = i % 3 === 0 ? C.teal : i % 3 === 1 ? C.accent : C.navy;
    s.addShape(pres.ShapeType.rect, { x: 0.3, y, w: 12.7, h: 0.88, fill: { color: C.light }, line: { color: col, pt: 1 } });
    s.addShape(pres.ShapeType.rect, { x: 0.3, y, w: 2.8, h: 0.88, fill: { color: col } });
    s.addText(r.seq, { x: 0.35, y: y + 0.18, w: 2.7, h: 0.55, fontSize: 12, bold: true, color: C.white, align: "center", fontFace: "Calibri" });
    s.addText(r.use, { x: 3.3, y: y + 0.07, w: 5.7, h: 0.74, fontSize: 11.5, color: C.navy, fontFace: "Calibri", valign: "middle" });
    s.addShape(pres.ShapeType.rect, { x: 9.2, y: y + 0.07, w: 3.6, h: 0.74, fill: { color: col }, line: { color: col } });
    s.addText(r.tip, { x: 9.25, y: y + 0.07, w: 3.55, h: 0.74, fontSize: 10, color: C.white, fontFace: "Calibri", italic: true, valign: "middle" });
  });

  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 7.1, w: 12.7, h: 0.3, fill: { color: C.gold } });
  s.addText("Coil: Dedicated wrist coil / extremity coil preferred | Field strength: 3T recommended | Patient position: Superman or side-lying ('superman position')", {
    x: 0.3, y: 7.1, w: 12.7, h: 0.3, fontSize: 9.5, color: C.navy, align: "center", bold: true
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 10 – PATHOLOGY: TFCC TEARS
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.white } });
  addTitleBar(s, "Pathology: TFCC Tears – Palmer Classification", "MRI features, clinical correlation");

  // Palmer class table
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.3, w: 6.2, h: 5.9, fill: { color: C.light }, line: { color: C.teal, pt: 1.5 } });
  addSectionLabel(s, "PALMER CLASSIFICATION", 0.3, 1.3);

  const palmer = [
    ["Class I – TRAUMATIC", C.red, [
      "IA: Central perforation (most common) – avascular zone",
      "IB: Ulnar avulsion ± ulnar styloid fracture",
      "IC: Distal avulsion (ulnocarpal ligament avulsion)",
      "ID: Radial avulsion from sigmoid notch",
    ]],
    ["Class II – DEGENERATIVE", C.teal, [
      "IIA: TFCC wear (chondromalacia)",
      "IIB: Chondromalacia + lunate/ulna changes",
      "IIC: TFCC perforation",
      "IID: Perforation + LTL tear",
      "IIE: Perforation + LTL + SLL tear (SLAC wrist)",
    ]],
  ];

  let yOff = 1.75;
  palmer.forEach(([title, col, items]) => {
    s.addShape(pres.ShapeType.rect, { x: 0.35, y: yOff, w: 6.1, h: 0.42, fill: { color: col } });
    s.addText(title, { x: 0.38, y: yOff + 0.06, w: 6.1, h: 0.3, fontSize: 12, bold: true, color: C.white });
    yOff += 0.5;
    items.forEach(item => {
      s.addText("  · " + item, { x: 0.4, y: yOff, w: 5.9, h: 0.36, fontSize: 10.5, color: C.navy, fontFace: "Calibri" });
      yOff += 0.38;
    });
    yOff += 0.1;
  });

  // Right – MRI features
  s.addShape(pres.ShapeType.rect, { x: 6.8, y: 1.3, w: 6.2, h: 5.9, fill: { color: C.navy } });
  addSectionLabel(s, "MRI FEATURES", 6.8, 1.3);

  s.addText("Direct Signs of TFCC Tear on MRI:", { x: 7.0, y: 1.78, w: 5.8, h: 0.42, fontSize: 12, bold: true, color: C.gold });
  const direct = [
    "Focal discontinuity / perforation in low-signal TFC",
    "Fluid signal extending through the TFCC (T2 hyperintensity)",
    "Loss of the normal biconcave shape of the disk",
    "Gadolinium extravasation on MR arthrography (gold standard)",
    "Central perforations: T2 bright gap in the avascular central zone",
    "Peripheral tears: T2 signal at ulnar insertion → foveal tear",
  ];
  direct.forEach((t, i) => {
    s.addText([
      { text: "▸ ", options: { color: C.gold, bold: true } },
      { text: t, options: { color: C.white } },
    ], { x: 7.0, y: 2.25 + i * 0.42, w: 5.8, h: 0.38, fontSize: 11, fontFace: "Calibri" });
  });

  s.addText("Indirect Signs:", { x: 7.0, y: 4.85, w: 5.8, h: 0.38, fontSize: 12, bold: true, color: C.gold });
  const indirect = [
    "DRUJ joint effusion (isolated → high suspicion for TFCC tear)",
    "Ulnocarpal joint effusion",
    "Bone marrow oedema at ulnar head / lunate – ulnocarpal impaction",
  ];
  indirect.forEach((t, i) => {
    s.addText("  · " + t, { x: 7.0, y: 5.28 + i * 0.38, w: 5.8, h: 0.34, fontSize: 10.5, color: C.light, fontFace: "Calibri" });
  });

  s.addShape(pres.ShapeType.rect, { x: 6.8, y: 6.78, w: 6.2, h: 0.42, fill: { color: C.red } });
  s.addText("Ulnar positive variance → increased load on ulnar side → predisposes to Class II tears", {
    x: 6.85, y: 6.78, w: 6.1, h: 0.42, fontSize: 10, color: C.white, bold: true, fontFace: "Calibri"
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 11 – PATHOLOGY: LIGAMENT INJURIES (SLL / LTL / DISI / VISI)
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.white } });
  addTitleBar(s, "Pathology: Ligament Injuries – SLL, LTL & Carpal Instability", "DISI and VISI patterns – MRI & plain radiograph features");

  // SLL block
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.3, w: 6.1, h: 2.8, fill: { color: C.light }, line: { color: C.red, pt: 2 } });
  addSectionLabel(s, "SLL TEAR (Scapholunate)", 0.3, 1.3);
  addBullets(s, [
    "Mechanism: Fall on outstretched hand (FOOSH) with wrist extended",
    "MRI: T2 hyperintensity / discontinuity in dorsal band of SLL",
    "Coronal MR arthrography: Contrast leak radiocarpal → midcarpal",
    "Radiograph: Scapholunate gap >3 mm ('Terry Thomas sign')",
    "Scaphoid ring sign: Foreshortened scaphoid on PA view",
    "Results in DISI pattern if secondary stabilisers fail",
  ], 0.45, 1.75, 5.8, 2.1, 11);

  // LTL block
  s.addShape(pres.ShapeType.rect, { x: 6.9, y: 1.3, w: 6.1, h: 2.8, fill: { color: C.light }, line: { color: C.teal, pt: 2 } });
  addSectionLabel(s, "LTL TEAR (Lunotriquetral)", 6.9, 1.3);
  addBullets(s, [
    "Mechanism: FOOSH with wrist in radial deviation or direct ulnar blow",
    "MRI: Disruption of LTL, especially membranous & volar portions",
    "MR arthrography: Contrast leak midcarpal → radiocarpal (reverse of SLL)",
    "Results in VISI pattern if secondary stabilisers involved",
    "Volar intercalated = lunate flexion, triquetrum extends",
    "Less common than SLL tear; often associated with TFCC injury",
  ], 7.05, 1.75, 5.8, 2.1, 11);

  // DISI / VISI diagram text
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 4.28, w: 12.7, h: 3.0, fill: { color: C.navy } });
  s.addText("Carpal Instability Patterns", { x: 0.5, y: 4.36, w: 12.3, h: 0.45, fontSize: 15, bold: true, color: C.gold });

  // DISI
  s.addShape(pres.ShapeType.rect, { x: 0.5, y: 4.85, w: 5.8, h: 2.2, fill: { color: C.teal } });
  s.addText("DISI – Dorsal Intercalated Segmental Instability", { x: 0.6, y: 4.92, w: 5.6, h: 0.42, fontSize: 12, bold: true, color: C.gold });
  s.addText("Cause: SLL tear (scaphoid flexes; lunate extends dorsally)\nRadiograph: Scapholunate angle >60° (normal 30–60°); lunate tilts dorsal\nMRI lateral view: Lunate dorsal tilt; scaphoid palmar flexion\nProgresses to SLAC (Scapholunate Advanced Collapse) wrist", {
    x: 0.6, y: 5.38, w: 5.6, h: 1.62, fontSize: 10.5, color: C.white, fontFace: "Calibri"
  });

  // VISI
  s.addShape(pres.ShapeType.rect, { x: 7.0, y: 4.85, w: 5.8, h: 2.2, fill: { color: C.accent } });
  s.addText("VISI – Volar Intercalated Segmental Instability", { x: 7.1, y: 4.92, w: 5.6, h: 0.42, fontSize: 12, bold: true, color: C.gold });
  s.addText("Cause: LTL tear (lunate flexes with scaphoid; triquetrum extends)\nRadiograph: Scapholunate angle <30°; capitolunate angle reversed\nMRI: Lunate volar tilt on lateral projection\nLess common, less damaging than DISI pattern", {
    x: 7.1, y: 5.38, w: 5.6, h: 1.62, fontSize: 10.5, color: C.white, fontFace: "Calibri"
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 12 – PATHOLOGY: SCAPHOID FRACTURES (with images)
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.white } });
  addTitleBar(s, "Pathology: Scaphoid Fractures & AVN", "Imaging strategy, MRI findings – Grainger & Allison's Diagnostic Radiology");

  // Image – Scaphoid XR / radiograph series
  addImg(s, "scaphoid_xr", 0.3, 1.3, 4.0, 2.7);
  addCaption(s, "Fig 45.41: Scaphoid series – lateral, PA & both obliques. Forehand oblique elongates the scaphoid and reveals distal pole fracture. Standard 4-view series recommended.", 0.3, 4.05, 4.0);

  // Image – Blood supply diagram
  addImg(s, "scaphoid_supply", 4.55, 1.3, 4.0, 2.7);
  addCaption(s, "Fig 45.42: Blood supply & union rates by fracture location. Distal supply only → proximal pole is watershed zone. More proximal fracture = higher AVN risk.", 4.55, 4.05, 4.0);

  // Image – AVN MRI
  addImg(s, "scaphoid_avn_mri", 8.8, 1.3, 4.2, 2.7);
  addCaption(s, "Fig 45.43: MRI of scaphoid non-union and AVN. Persistent fracture line at waist; low signal in proximal pole on T1 (marrow necrosis) – pathognomonic for AVN.", 8.8, 4.05, 4.2);

  // Key points
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 5.0, w: 12.7, h: 2.3, fill: { color: C.navy } });
  s.addText("Scaphoid Imaging Strategy & MRI Role", { x: 0.5, y: 5.08, w: 12.3, h: 0.42, fontSize: 14, bold: true, color: C.gold });
  const scipts = [
    "60% of all carpal fractures; mechanism = FOOSH; clinical: anatomical snuff box tenderness",
    "Initial plain films may be NEGATIVE in 20–30% of true fractures → immobilise + re-image at 10–14 days",
    "MRI: Most sensitive & specific (>90%) for occult scaphoid fractures – shows bone marrow oedema on STIR within hours",
    "AVN: T1 low signal proximal pole (marrow necrosis); T2 variable; gadolinium non-enhancement confirms avascular zone",
    "CT: Best for fracture geometry, displacement assessment & surgical planning; inferior sensitivity to MRI for occult fractures",
    "Non-union: Persistent fracture line + sclerosis at margins; may develop humpback deformity → SNAC wrist progression",
  ];
  scipts.forEach((t, i) => {
    s.addText([
      { text: "▸ ", options: { bold: true, color: C.gold } },
      { text: t, options: { color: C.white } },
    ], { x: 0.5, y: 5.55 + i * 0.28, w: 12.3, h: 0.25, fontSize: 10, fontFace: "Calibri" });
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 13 – PATHOLOGY: CARPAL INSTABILITY (SLAC / SNAC)
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.white } });
  addTitleBar(s, "Pathology: Carpal Instability – SLAC & SNAC Wrist", "End-stage carpal collapse patterns on MRI and radiograph");

  // SLAC
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.3, w: 6.1, h: 5.9, fill: { color: C.light }, line: { color: C.red, pt: 2 } });
  s.addText("SLAC – Scapholunate Advanced Collapse", { x: 0.4, y: 1.38, w: 5.9, h: 0.52, fontSize: 13, bold: true, color: C.red });
  s.addText("Cause: Chronic SLL tear → abnormal kinematics → progressive arthritis", {
    x: 0.4, y: 1.95, w: 5.9, h: 0.42, fontSize: 11, color: C.gray, italic: true, fontFace: "Calibri"
  });
  const slac = [
    ["Stage I", "Radial styloid–scaphoid arthritis (tip of radial styloid)"],
    ["Stage II", "Radioscaphoid joint arthritis (entire scaphoid fossa)"],
    ["Stage III", "Capitolunate arthritis; capitate migrates proximally"],
    ["Stage IV", "Radiolunate arthritis (late; relatively preserved initially)"],
  ];
  slac.forEach(([st, desc], i) => {
    s.addShape(pres.ShapeType.rect, { x: 0.4, y: 2.48 + i * 0.88, w: 5.8, h: 0.78, fill: { color: i % 2 === 0 ? C.white : "#FADBD8" } });
    s.addText(st, { x: 0.5, y: 2.56 + i * 0.88, w: 1.3, h: 0.6, fontSize: 12, bold: true, color: C.red, fontFace: "Calibri" });
    s.addText(desc, { x: 1.85, y: 2.56 + i * 0.88, w: 4.2, h: 0.6, fontSize: 11, color: C.navy, fontFace: "Calibri" });
  });
  s.addText("MRI: Joint space narrowing + cartilage loss in above pattern;\nbone marrow oedema at articular margins; subchondral cysts;\nscaphoid flexion (DISI pattern) confirmed on sagittal T1.", {
    x: 0.4, y: 6.08, w: 5.9, h: 0.92, fontSize: 10.5, color: C.gray, fontFace: "Calibri", italic: true
  });

  // SNAC
  s.addShape(pres.ShapeType.rect, { x: 6.9, y: 1.3, w: 6.1, h: 5.9, fill: { color: C.light }, line: { color: C.teal, pt: 2 } });
  s.addText("SNAC – Scaphoid Non-union Advanced Collapse", { x: 7.0, y: 1.38, w: 5.9, h: 0.52, fontSize: 13, bold: true, color: C.teal });
  s.addText("Cause: Scaphoid non-union → humpback deformity → DISI → arthritis", {
    x: 7.0, y: 1.95, w: 5.9, h: 0.42, fontSize: 11, color: C.gray, italic: true, fontFace: "Calibri"
  });
  const snac = [
    ["Stage I", "Radial styloid–scaphoid distal fragment arthritis"],
    ["Stage II", "Radioscaphoid joint arthritis (proximal pole involvement)"],
    ["Stage III", "Capitolunate arthritis + midcarpal involvement"],
  ];
  snac.forEach(([st, desc], i) => {
    s.addShape(pres.ShapeType.rect, { x: 7.0, y: 2.48 + i * 0.88, w: 5.8, h: 0.78, fill: { color: i % 2 === 0 ? C.white : "#D5F5E3" } });
    s.addText(st, { x: 7.1, y: 2.56 + i * 0.88, w: 1.3, h: 0.6, fontSize: 12, bold: true, color: C.teal });
    s.addText(desc, { x: 8.45, y: 2.56 + i * 0.88, w: 4.2, h: 0.6, fontSize: 11, color: C.navy, fontFace: "Calibri" });
  });

  s.addShape(pres.ShapeType.rect, { x: 7.0, y: 5.16, w: 5.8, h: 1.8, fill: { color: C.navy } });
  s.addText("SNAC vs SLAC on Imaging", { x: 7.1, y: 5.22, w: 5.6, h: 0.4, fontSize: 12, bold: true, color: C.gold });
  const compare = [
    "SNAC: Scaphoid fracture non-union visible; humpback deformity; predominantly radial-sided collapse",
    "SLAC: No fracture; SLL insufficiency; more generalised collapse; radiolunate preserved until Stage IV",
    "Both: DISI pattern; capitate proximal migration; subchondral sclerosis/cysts; end-stage: pan-carpal OA",
    "MRI superior to CT for cartilage loss quantification and ligament status",
  ];
  compare.forEach((t, i) => {
    s.addText([
      { text: "• ", options: { color: C.gold, bold: true } },
      { text: t, options: { color: C.white } },
    ], { x: 7.1, y: 5.66 + i * 0.3, w: 5.6, h: 0.27, fontSize: 10, fontFace: "Calibri" });
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 14 – PATHOLOGY: CARPAL TUNNEL SYNDROME
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.white } });
  addTitleBar(s, "Pathology: Carpal Tunnel Syndrome", "MRI findings, space-occupying lesions & Guyon's canal");

  // Left – CTS
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.3, w: 6.1, h: 5.9, fill: { color: C.light }, line: { color: C.accent, pt: 1.5 } });
  addSectionLabel(s, "CARPAL TUNNEL SYNDROME", 0.3, 1.3);
  addBullets(s, [
    "Commonest nerve compression syndrome; female:male ~3:1",
    "Causes: idiopathic (most common), pregnancy, hypothyroidism, RA,\n  diabetes, ganglion, lipoma, tenosynovitis, post-fracture deformity",
  ], 0.45, 1.75, 5.8, 1.0, 11);

  s.addText("MRI Features:", { x: 0.45, y: 2.85, w: 5.8, h: 0.38, fontSize: 12, bold: true, color: C.accent });
  const cts = [
    "T2 hyperintensity of median nerve (oedema/demyelination)",
    "Nerve swelling proximal to carpal tunnel (pisiform level)",
    "Flattening of the nerve at level of hamate hook",
    "Bowing of flexor retinaculum (palmar displacement >4 mm)",
    "Increased cross-sectional area of median nerve (>10–15 mm²)",
    "Space-occupying lesion: ganglion, lipoma, anomalous muscle, persistent median artery, thrombosed vessel",
    "Gadolinium: nerve enhancement in severe/chronic cases",
  ];
  cts.forEach((t, i) => {
    s.addText("  · " + t, { x: 0.45, y: 3.28 + i * 0.43, w: 5.8, h: 0.38, fontSize: 10.5, color: C.navy, fontFace: "Calibri" });
  });

  // Right – Guyon's canal + other pathologies
  s.addShape(pres.ShapeType.rect, { x: 6.7, y: 1.3, w: 6.3, h: 5.9, fill: { color: C.navy } });
  addSectionLabel(s, "OTHER WRIST PATHOLOGIES", 6.7, 1.3);

  const others = [
    { title: "Guyon's Canal Syndrome", color: C.gold, points: [
        "Ulnar nerve compression at wrist",
        "Causes: ganglion (most common), hamate hook fracture, ulnar artery aneurysm/thrombosis, repetitive trauma (cyclists)",
        "MRI: T2 bright nerve; look for mass lesion; ulnar artery pathology",
      ]},
    { title: "De Quervain's Tenosynovitis", color: "#E74C3C", points: [
        "1st extensor compartment (APL + EPB) tenosynovitis",
        "MRI: Tendon sheath fluid, peritendinous T2 signal, thickened retinaculum",
        "Positive Finkelstein test clinically",
      ]},
    { title: "Ganglion Cyst", color: C.accent, points: [
        "Most common wrist mass; dorsal > volar",
        "MRI: T1 hypointense, T2 hyperintense, well-defined; follows joint/tendon sheath",
        "Dorsal scapholunate ganglion: adjacent to SLL tear",
      ]},
    { title: "Kienbock's Disease (Lunate AVN)", color: C.green, points: [
        "Avascular necrosis of lunate; associated with ulnar negative variance",
        "MRI: T1 low, T2 variable signal in lunate marrow; gadolinium non-enhancement",
        "Lichtman staging on MRI; Stage IIIB: collapse + fixed scaphoid rotation",
      ]},
  ];

  let yOff2 = 1.75;
  others.forEach(({ title, color, points }) => {
    s.addShape(pres.ShapeType.rect, { x: 6.8, y: yOff2, w: 6.1, h: 0.36, fill: { color } });
    s.addText(title, { x: 6.85, y: yOff2 + 0.04, w: 6.0, h: 0.28, fontSize: 11, bold: true, color: C.white, fontFace: "Calibri" });
    yOff2 += 0.42;
    points.forEach(p => {
      s.addText("  · " + p, { x: 6.85, y: yOff2, w: 6.0, h: 0.32, fontSize: 10, color: C.light, fontFace: "Calibri" });
      yOff2 += 0.34;
    });
    yOff2 += 0.1;
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 15 – PALMAR ARCHES (with images)
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.white } });
  addTitleBar(s, "Vascular Anatomy – Palmar Arches & Variants", "CT angiography and MR angiography – Imaging Anatomy Vol. 3");

  addImg(s, "palmar_arch", 0.3, 1.3, 4.2, 3.5);
  addCaption(s, "Fig 4.33: Complete superficial palmar arch (CT angiography). Radial artery → princeps pollicis + radialis indicis; ulnar superficial palmar branch completes the arch. Deep palmar arch formed by radial artery.", 0.3, 4.88, 4.2);

  addImg(s, "incomplete_arch", 4.75, 1.3, 4.0, 3.5);
  addCaption(s, "Fig 4.34: Incomplete superficial palmar arch with ulnar dominance. Radial artery terminates in princeps pollicis; radialis indicis supplied by ulnar branches. Multiple distal digital artery occlusions (arrows) – chronic autoimmune vasculitis.", 4.75, 4.88, 4.0);

  // Key points box
  s.addShape(pres.ShapeType.rect, { x: 9.0, y: 1.3, w: 4.0, h: 5.9, fill: { color: C.navy } });
  s.addText("Palmar Arch Key Points", { x: 9.1, y: 1.38, w: 3.8, h: 0.42, fontSize: 13, bold: true, color: C.gold });
  const archPts = [
    "Superficial palmar arch: ~80% complete (ulnar dominant)",
    "Deep palmar arch: radial artery dominant (passes through 1st dorsal interosseous)",
    "Rich anastomosis means single-vessel occlusion rarely causes hand ischaemia",
    "Dorsal carpal arch: radial artery in 80%",
    "Clinical: Allen's test assesses arch patency before radial artery cannulation",
    "MRI/MRA: Gadolinium MRA replaces conventional angiography for arch anatomy",
    "Scaphoid blood supply: enters dorsoradial ridge; retrograde → proximal pole; explains AVN after waist fractures",
  ];
  archPts.forEach((t, i) => {
    s.addText([
      { text: "▸ ", options: { color: C.gold, bold: true } },
      { text: t, options: { color: C.white } },
    ], { x: 9.1, y: 1.85 + i * 0.65, w: 3.8, h: 0.58, fontSize: 10.5, fontFace: "Calibri" });
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 16 – SUMMARY / KEY TEACHING POINTS
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 13.3, h: 7.5, fill: { color: C.darkbg } });
  s.addShape(pres.ShapeType.rect, { x: 0, y: 1.05, w: 13.3, h: 0.06, fill: { color: C.gold } });
  s.addText("KEY TEACHING POINTS", { x: 0.4, y: 0.18, w: 12.5, h: 0.82, fontSize: 30, bold: true, color: C.white, fontFace: "Calibri", charSpacing: 4 });

  const boxes = [
    { label: "TFCC", color: C.teal, items: [
        "TFC proper: biconcave disk, avascular central zone",
        "Palmer Class I (traumatic) vs II (degenerative)",
        "Coronal PD fat-sat is the primary sequence",
        "Foveal tears: peripheral, repairable, good outcome",
      ]},
    { label: "LIGAMENTS", color: C.accent, items: [
        "SLL > LTL: most clinically relevant intrinsic ligaments",
        "SLL tear → DISI; LTL tear → VISI",
        "MR arthrography: gold standard for partial tears",
        "SLAC wrist: end-stage of SLL insufficiency",
      ]},
    { label: "SCAPHOID", color: C.gold, items: [
        "MRI most sensitive for occult fracture (STIR sequence)",
        "AVN: T1 low signal proximal pole, non-enhancing",
        "SNAC wrist mirrors SLAC in progression",
        "Waist fractures: highest risk for AVN (~30%)",
      ]},
    { label: "PROTOCOLS", color: C.red, items: [
        "3T + dedicated coil: optimal for ligament imaging",
        "Coronal plane: SLL, LTL, TFCC",
        "Axial plane: tendons, nerves, carpal tunnel",
        "MR arthrography: compartment communication = tear",
      ]},
  ];

  boxes.forEach((b, i) => {
    const col = i < 2 ? i : i;
    const x = 0.35 + (i % 2) * 6.45;
    const y = 1.3 + Math.floor(i / 2) * 3.0;
    s.addShape(pres.ShapeType.rect, { x, y, w: 6.1, h: 2.7, fill: { color: b.color + "22" }, line: { color: b.color, pt: 2 } });
    s.addShape(pres.ShapeType.rect, { x, y, w: 6.1, h: 0.46, fill: { color: b.color } });
    s.addText(b.label, { x: x + 0.1, y: y + 0.06, w: 5.9, h: 0.34, fontSize: 14, bold: true, color: C.white, fontFace: "Calibri" });
    b.items.forEach((item, j) => {
      s.addText([
        { text: "✓ ", options: { color: b.color, bold: true } },
        { text: item, options: { color: C.white } },
      ], { x: x + 0.15, y: y + 0.55 + j * 0.51, w: 5.8, h: 0.46, fontSize: 11, fontFace: "Calibri" });
    });
  });

  s.addText("Sources: Imaging Anatomy – Bones, Joints, Vessels & Nerves, Thieme (9781626239845)  |  Grainger & Allison's Diagnostic Radiology (9780323760751)", {
    x: 0.4, y: 7.18, w: 12.5, h: 0.28, fontSize: 9, color: C.gray, italic: true, align: "center"
  });
}

// ── Write the file ───────────────────────────────────────────────
pres.writeFile({ fileName: "/home/daytona/workspace/wrist-mri-ppt/Wrist_MRI_Radiology_Teaching.pptx" })
  .then(() => console.log("DONE: Wrist_MRI_Radiology_Teaching.pptx written successfully"))
  .catch(e => { console.error("Write error:", e); process.exit(1); });
Running Command

cd /home/daytona/workspace/wrist-mri-ppt && node build.js 2>&1

Editing File

~/wrist-mri-ppt/build.js

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/wrist-mri-ppt/build.js'
Running Command

cd /home/daytona/workspace/wrist-mri-ppt && node build.js 2>&1

Your presentation is ready for download:

Wrist MRI Radiology Teaching

Presentation · PPTX


What's inside (16 slides, 11 textbook images embedded)

SlideTopic
1Title slide – dark radiology theme
2Contents overview – 12-topic visual index
3Osseous anatomy – 8 carpal bones, mnemonic, distal radius/ulna
4Joint compartments – Radiocarpal, midcarpal, DRUJ
5Ligamentous anatomy – Intrinsic (SLL, LTL) & extrinsic; MRI evaluation tips
6TFCC anatomy – 3 textbook MRI images (Fig 17.34/17.35) + component table
7Tendons – 6 extensor compartments + carpal tunnel contents + Guyon's canal zones
8Neurovascular anatomy – 3 images: persistent median artery MRI, Guyon's canal axial + sagittal series
9MRI protocols – T1, PD fat-sat, STIR, T2* GRE, MR arthrography with indications
10Pathology: TFCC tears – Palmer classification I & II; direct/indirect MRI signs
11Pathology: SLL / LTL tears – DISI vs VISI patterns, arthrography findings
12Pathology: Scaphoid fractures & AVN – 3 images (XR series, blood supply diagram, AVN MRI)
13Pathology: SLAC & SNAC wrist – staged collapse with imaging differences
14Pathology: CTS, De Quervain's, Ganglion, Kienbock's – MRI features for each
15Vascular anatomy – 2 images (complete/incomplete palmar arch CT angiography)
16Summary – Key teaching points across TFCC, ligaments, scaphoid, protocols
Sources used: Imaging Anatomy Vol. 3 – Bones, Joints, Vessels & Nerves (Thieme) and Grainger & Allison's Diagnostic Radiology.

your file is not opening in key note

Running Command

ls -lh /home/daytona/workspace/wrist-mri-ppt/ && ls -lh /home/daytona/workspace/attachments/4ced92e4-e8a9-418c-b4a6-8e8734c14a0e/

Reading File
Reading File
Running Command

cd /home/daytona/workspace/wrist-mri-ppt && python3 -m markitdown /home/daytona/workspace/attachments/4ced92e4-e8a9-418c-b4a6-8e8734c14a0e/slidesaver.app_flhwmi.pptx 2>&1 | head -60

Running Command

cp /home/daytona/workspace/attachments/4ced92e4-e8a9-418c-b4a6-8e8734c14a0e/slidesaver.app_flhwmi.pptx /home/daytona/workspace/wrist-mri-ppt/template.pptx && python3 /home/daytona/skills/pptx/scripts/office/unpack.py /home/daytona/workspace/wrist-mri-ppt/template.pptx /home/daytona/workspace/wrist-mri-ppt/unpacked/ 2>&1

Running Command

cd /home/daytona/workspace/wrist-mri-ppt && unzip -o template.pptx -d template_unpacked/ > /dev/null 2>&1 && echo "done" && ls template_unpacked/

Running Command

mkdir -p /home/daytona/workspace/wrist-mri-ppt/imgs && curl -s -o /home/daytona/workspace/wrist-mri-ppt/imgs/tfcc_diagram.png "https://cdn.orris.care/cdss_images/74c5c3d44a775cd359b10c7da5df2cf5fd5beadc7195fa5a40d46a6e3c19a6b2.png" && curl -s -o /home/daytona/workspace/wrist-mri-ppt/imgs/tfcc_mri.png "https://cdn.orris.care/cdss_images/728fdddb16dba69fd80ff6107ee9866bff0251439ff1095c3e7f9d2b54175535.png" && curl -s -o /home/daytona/workspace/wrist-mri-ppt/imgs/tfcc_serial.png "https://cdn.orris.care/cdss_images/6a86bc75f1de7ee4d138bd37c4cf7be5170f5ca41118bb340b41b07050470e4d.png" && curl -s -o /home/daytona/workspace/wrist-mri-ppt/imgs/ulnar_ax.png "https://cdn.orris.care/cdss_images/b68c6069612407d66eea841f6bacf764578226eb4e0249ec7624786ae094973f.png" && curl -s -o /home/daytona/workspace/wrist-mri-ppt/imgs/ulnar_sag.png "https://cdn.orris.care/cdss_images/63e3c56e7ad03e0abe54c88d451ac7db7e401c6b489742db9745464ca64e4aeb.png" && echo "batch1 done"

Running Command

curl -s -o /home/daytona/workspace/wrist-mri-ppt/imgs/median_artery.png "https://cdn.orris.care/cdss_images/131d19e092e7b60fe0a1ec05d9b5727d6bdac8facd4a39640cdc677d0f21c149.png" && curl -s -o /home/daytona/workspace/wrist-mri-ppt/imgs/palmar_arch.png "https://cdn.orris.care/cdss_images/63077a68f55385c8adad2a992c2e3c423123cd9863424b428fbb1b30f04e010a.png" && curl -s -o /home/daytona/workspace/wrist-mri-ppt/imgs/incomplete_arch.png "https://cdn.orris.care/cdss_images/5d40a4268c4fa6ee44701a7d99cbb3a7f16976a16e8c05e2333dc41aa48e5d30.png" && curl -s -o /home/daytona/workspace/wrist-mri-ppt/imgs/scaphoid_xr.png "https://cdn.orris.care/cdss_images/186232014c447155208a58861d61bc15b9d9d745054f653028bbdaa8f0e6230c.png" && curl -s -o /home/daytona/workspace/wrist-mri-ppt/imgs/scaphoid_avn.png "https://cdn.orris.care/cdss_images/f2a5604bd7ed13f4cfcf96589c9e838f09f09c4371d2cf7070c7c8d3ff093e93.png" && curl -s -o /home/daytona/workspace/wrist-mri-ppt/imgs/scaphoid_supply.png "https://cdn.orris.care/cdss_images/820515d7b8940d00c4f23b4125929d9dfd8433a76841294886ab84472966089e.png" && echo "batch2 done" && ls -lh /home/daytona/workspace/wrist-mri-ppt/imgs/

Running Command

cd /home/daytona/workspace/wrist-mri-ppt/imgs && python3 -c " from PIL import Image import os MAX_W = 1400 for fname in os.listdir('.'): if not fname.endswith('.png'): continue img = Image.open(fname) w, h = img.size if w > MAX_W: ratio = MAX_W / w img = img.resize((MAX_W, int(h * ratio)), Image.LANCZOS) img.save(fname, optimize=True) print(f'{fname}: {w}x{h} -> {img.size}') " 2>&1

Writing File

~/wrist-mri-ppt/build2.js

const pptxgen = require("pptxgenjs");
const path = require("path");

const pres = new pptxgen();
pres.layout = "LAYOUT_WIDE";
pres.title = "Wrist Joint Anatomy & MRI Radiology Teaching";
pres.author = "Radiology Teaching Series";

// ── Colour Palette ──────────────────────────────────────────────
const C = {
  navy:   "0D1B2A",
  teal:   "1B4F72",
  accent: "2E86AB",
  gold:   "F0A500",
  white:  "FFFFFF",
  light:  "E8F4F8",
  gray:   "5D6D7E",
  darkbg: "0A1628",
  red:    "C0392B",
  green:  "1A8754",
  dark2:  "1A2E40",
};

// Image file paths (local, already resized)
const IMGS = {
  tfcc_diagram:  path.resolve(__dirname, "imgs/tfcc_diagram.png"),
  tfcc_mri:      path.resolve(__dirname, "imgs/tfcc_mri.png"),
  tfcc_serial:   path.resolve(__dirname, "imgs/tfcc_serial.png"),
  ulnar_ax:      path.resolve(__dirname, "imgs/ulnar_ax.png"),
  ulnar_sag:     path.resolve(__dirname, "imgs/ulnar_sag.png"),
  median_artery: path.resolve(__dirname, "imgs/median_artery.png"),
  palmar_arch:   path.resolve(__dirname, "imgs/palmar_arch.png"),
  incomp_arch:   path.resolve(__dirname, "imgs/incomplete_arch.png"),
  scaphoid_xr:   path.resolve(__dirname, "imgs/scaphoid_xr.png"),
  scaphoid_avn:  path.resolve(__dirname, "imgs/scaphoid_avn.png"),
  scaphoid_sup:  path.resolve(__dirname, "imgs/scaphoid_supply.png"),
};

// ── Slide helpers ────────────────────────────────────────────────
function bar(s, title, sub) {
  s.addShape(pres.ShapeType.rect, { x:0, y:0, w:13.3, h:1.1, fill:{color:C.navy} });
  s.addText(title, { x:0.3, y:0.08, w:10, h:0.6, fontSize:22, bold:true, color:C.white, fontFace:"Calibri", margin:0 });
  if (sub) s.addText(sub, { x:0.3, y:0.68, w:11, h:0.38, fontSize:13, color:C.gold, fontFace:"Calibri", italic:true, margin:0 });
  s.addShape(pres.ShapeType.rect, { x:0, y:1.1, w:13.3, h:0.05, fill:{color:C.gold} });
}

function tag(s, label, x, y, col) {
  const bg = col || C.accent;
  s.addShape(pres.ShapeType.rect, { x, y, w:2.8, h:0.32, fill:{color:bg} });
  s.addText(label, { x, y:y+0.04, w:2.8, h:0.32, fontSize:10, bold:true, color:C.white, align:"center", fontFace:"Calibri", margin:0 });
}

function img(s, key, x, y, w, h) {
  s.addImage({ path: IMGS[key], x, y, w, h });
}

function cap(s, text, x, y, w) {
  s.addText(text, { x, y, w, h:0.55, fontSize:8.5, color:C.gray, italic:true, fontFace:"Calibri", wrap:true });
}

function bullets(s, items, x, y, w, h, sz) {
  const parts = items.map((t,i) => ({ text:t, options:{ bullet:{ code:"25CF" }, breakLine: i < items.length-1 } }));
  s.addText(parts, { x, y, w, h, fontSize:sz||13, color:C.navy, fontFace:"Calibri", lineSpacingMultiple:1.3 });
}

function row(s, label, desc, x, y, w, bg) {
  s.addShape(pres.ShapeType.rect, { x, y, w, h:0.68, fill:{color: bg||C.white} });
  s.addText([{text:label+"  ", options:{bold:true,color:C.teal}},{text:desc,options:{color:C.navy}}],
    { x:x+0.1, y:y+0.1, w:w-0.2, h:0.5, fontSize:11, fontFace:"Calibri" });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 1 – TITLE
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect, {x:0,y:0,w:13.3,h:7.5,fill:{color:C.darkbg}});
  s.addShape(pres.ShapeType.rect, {x:0,y:2.8,w:13.3,h:0.08,fill:{color:C.gold}});
  s.addShape(pres.ShapeType.rect, {x:0,y:2.88,w:13.3,h:2.2,fill:{color:C.teal}});
  s.addText("WRIST JOINT", {x:0.6,y:0.4,w:12,h:1.1,fontSize:56,bold:true,color:C.white,fontFace:"Calibri",charSpacing:5});
  s.addText("ANATOMY & MRI RADIOLOGY", {x:0.6,y:1.5,w:12,h:0.9,fontSize:34,bold:true,color:C.gold,fontFace:"Calibri"});
  s.addText("A Comprehensive Teaching Atlas", {x:0.6,y:2.97,w:12,h:0.52,fontSize:20,color:C.white,fontFace:"Calibri",italic:true});
  s.addText("Normal Anatomy  ·  Imaging Sequences  ·  TFCC  ·  Ligaments  ·  Pathologies",
    {x:0.6,y:3.5,w:12,h:0.6,fontSize:14,color:C.light,fontFace:"Calibri"});
  s.addText("Source: Imaging Anatomy – Bones, Joints, Vessels & Nerves (Thieme)  |  Grainger & Allison's Diagnostic Radiology",
    {x:0.6,y:6.9,w:12,h:0.38,fontSize:10,color:C.gray,italic:true,fontFace:"Calibri"});
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 2 – CONTENTS
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect,{x:0,y:0,w:13.3,h:7.5,fill:{color:C.light}});
  bar(s,"Contents","What this presentation covers");

  const topics = [
    ["01","Osseous Anatomy","Carpal bones, distal radius & ulna"],
    ["02","Joint Compartments","Radiocarpal, midcarpal, DRUJ"],
    ["03","Ligamentous Anatomy","Intrinsic & extrinsic – MRI correlation"],
    ["04","TFCC Anatomy","Components & MRI sequences"],
    ["05","Tendons & Sheaths","Flexor & extensor compartments"],
    ["06","Neurovascular Anatomy","Median/ulnar nerves, Guyon's canal"],
    ["07","MRI Protocols","T1, PD fat-sat, STIR, MR arthrography"],
    ["08","Pathology – TFCC Tears","Palmer classification & MRI features"],
    ["09","Pathology – Ligament Injuries","SLL/LTL tears, DISI/VISI"],
    ["10","Pathology – Scaphoid & Carpal Fractures","Occult fractures, AVN, non-union"],
    ["11","Pathology – Carpal Instability","SLAC, SNAC wrist"],
    ["12","Pathology – CTS & Other","Carpal tunnel, De Quervain's, Kienbock's"],
  ];

  topics.forEach(([num,title,sub],i) => {
    const col = i < 6 ? 0 : 1;
    const r   = i % 6;
    const x   = col===0 ? 0.3 : 6.9;
    const y   = 1.35 + r*0.98;
    s.addShape(pres.ShapeType.rect,{x,y,w:6.2,h:0.82,fill:{color:C.white},line:{color:C.accent,pt:1}});
    s.addShape(pres.ShapeType.rect,{x,y,w:0.52,h:0.82,fill:{color:col===0?C.teal:C.accent}});
    s.addText(num,{x:x+0.01,y:y+0.2,w:0.52,h:0.4,fontSize:14,bold:true,color:C.white,align:"center",margin:0});
    s.addText(title,{x:x+0.62,y:y+0.07,w:5.4,h:0.38,fontSize:12,bold:true,color:C.navy,fontFace:"Calibri",margin:0});
    s.addText(sub,{x:x+0.62,y:y+0.44,w:5.4,h:0.3,fontSize:10,color:C.gray,fontFace:"Calibri",italic:true,margin:0});
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 3 – OSSEOUS ANATOMY
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect,{x:0,y:0,w:13.3,h:7.5,fill:{color:C.white}});
  bar(s,"Osseous Anatomy of the Wrist","Eight carpal bones arranged in two rows");

  tag(s,"PROXIMAL ROW",0.3,1.3,C.teal);
  bullets(s,[
    "Scaphoid (navicular) – largest carpal bone, bridges both rows",
    "Lunate – articulates with radius; key to carpal kinematics",
    "Triquetrum – pyramidal; articulates with TFCC inferiorly",
    "Pisiform – sesamoid bone within FCU tendon",
  ],0.3,1.72,5.5,1.9,12);

  tag(s,"DISTAL ROW",0.3,3.75,C.accent);
  bullets(s,[
    "Trapezium – articulates with 1st metacarpal (saddle joint)",
    "Trapezoid – smallest carpal bone; very stable",
    "Capitate – largest carpal; keystone of the arch; axis of rotation",
    "Hamate – hook (hamulus) forms ulnar wall of carpal tunnel",
  ],0.3,4.17,5.5,1.9,12);

  tag(s,"DISTAL RADIUS & ULNA",0.3,6.2,C.navy);
  s.addText("Radial styloid · scaphoid/lunate facets · sigmoid notch  |  Ulnar head · ulnar styloid",
    {x:0.3,y:6.57,w:5.5,h:0.55,fontSize:10.5,color:C.gray,italic:true,fontFace:"Calibri"});

  // Mnemonic
  s.addShape(pres.ShapeType.rect,{x:6.1,y:1.3,w:6.9,h:5.9,fill:{color:C.navy},line:{color:C.gold,pt:2}});
  s.addText("Memory Aid",{x:6.25,y:1.42,w:6.6,h:0.42,fontSize:14,bold:true,color:C.gold});
  s.addText('"Some Lovers Try Positions That They Cannot Handle"',
    {x:6.25,y:1.9,w:6.6,h:0.6,fontSize:14,bold:true,color:C.white,italic:true});
  s.addText("Scaphoid · Lunate · Triquetrum · Pisiform\nTrapezium · Trapezoid · Capitate · Hamate",
    {x:6.25,y:2.58,w:6.6,h:0.82,fontSize:12,color:C.light,fontFace:"Calibri"});
  s.addText("(Proximal row → Distal row, lateral to medial)",
    {x:6.25,y:3.45,w:6.6,h:0.38,fontSize:11,color:C.gold,italic:true});

  // Anatomy facts table
  const facts = [
    ["Scaphoid","~60% of carpal fractures; bridges both rows; retrograde blood supply"],
    ["Lunate","Most commonly dislocated carpal; 3 types (I–III)"],
    ["Triquetrum","2nd most fractured carpal; dorsal chip fracture on lateral XR"],
    ["Pisiform","Sesamoid in FCU; pisiform-triquetral OA common"],
    ["Capitate","Largest carpal; first involved in perilunate dislocation series"],
    ["Hamate","Hook fractures in golfers/racquet sports; CT best for detection"],
  ];
  facts.forEach(([name,fact],i) => {
    s.addShape(pres.ShapeType.rect,{x:6.25,y:4.05+i*0.56,w:6.6,h:0.52,fill:{color:i%2===0?"1B4F72":"2E86AB"}});
    s.addText([
      {text:name+"  ",options:{bold:true,color:C.gold}},
      {text:fact,options:{color:C.white}},
    ],{x:6.35,y:4.1+i*0.56,w:6.45,h:0.42,fontSize:10.5,fontFace:"Calibri"});
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 4 – JOINT COMPARTMENTS
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect,{x:0,y:0,w:13.3,h:7.5,fill:{color:C.white}});
  bar(s,"Wrist Joint Compartments","Three major non-communicating compartments");

  const comps = [
    {label:"Radiocarpal Joint",color:C.teal,pts:[
      "Between distal radius and proximal carpal row (scaphoid, lunate, triquetrum)",
      "Separated from DRUJ by the TFCC (primary separator)",
      "Communicates with pisiform-triquetral joint in ~50% of individuals",
      "Key ligaments: radioscaphocapitate (RSC), long/short radiolunate, ulnocarpal",
    ]},
    {label:"Midcarpal Joint",color:C.accent,pts:[
      "S-shaped articulation between proximal and distal carpal rows",
      "Motion: mainly radial/ulnar deviation (>radiocarpal contribution)",
      "Stabilised by intrinsic interosseous and extrinsic ligaments",
      "Does NOT normally communicate with radiocarpal or DRUJ",
    ]},
    {label:"Distal Radioulnar Joint (DRUJ)",color:C.gold,pts:[
      "Pivot joint between sigmoid notch of radius and ulnar head",
      "Allows forearm pronation/supination (~150° total arc)",
      "Primary stabiliser: TFCC (dorsal & volar radioulnar ligaments)",
      "Isolated DRUJ effusion on MRI → TFCC tear until proven otherwise",
    ]},
  ];

  comps.forEach((c,i) => {
    const y = 1.35 + i*1.95;
    s.addShape(pres.ShapeType.rect,{x:0.3,y,w:12.7,h:1.75,fill:{color:C.light},line:{color:c.color,pt:2}});
    s.addShape(pres.ShapeType.rect,{x:0.3,y,w:2.9,h:1.75,fill:{color:c.color}});
    s.addText(c.label,{x:0.33,y:y+0.52,w:2.82,h:0.65,fontSize:13,bold:true,color:C.white,align:"center",fontFace:"Calibri"});
    const bp = c.pts.map((t,j)=>({text:t,options:{bullet:true,breakLine:j<c.pts.length-1}}));
    s.addText(bp,{x:3.4,y:y+0.18,w:9.3,h:1.38,fontSize:11.5,color:C.navy,fontFace:"Calibri",lineSpacingMultiple:1.25});
  });

  s.addShape(pres.ShapeType.rect,{x:0.3,y:7.1,w:12.7,h:0.3,fill:{color:C.navy}});
  s.addText("Additional compartments: Pisiform-Triquetral joint · Common CMC joint · 2nd–5th CMC joints – evaluated on 3-compartment MR arthrography",
    {x:0.3,y:7.1,w:12.7,h:0.3,fontSize:9.5,color:C.gold,align:"center",fontFace:"Calibri"});
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 5 – LIGAMENTOUS ANATOMY
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect,{x:0,y:0,w:13.3,h:7.5,fill:{color:C.white}});
  bar(s,"Ligamentous Anatomy of the Wrist","Intrinsic & extrinsic ligaments – MRI correlation");

  s.addShape(pres.ShapeType.rect,{x:0.3,y:1.3,w:5.9,h:2.9,fill:{color:C.light},line:{color:C.teal,pt:1.5}});
  tag(s,"INTRINSIC LIGAMENTS",0.3,1.3,C.teal);
  bullets(s,[
    "Scapholunate ligament (SLL) – C-shaped; dorsal band strongest",
    "Lunotriquetral ligament (LTL) – membranous > volar > dorsal",
    "Scaphotrapeziotrapezoid ligament (STT)",
    "Triquetrohamate & capitotrapezoid ligaments",
    "MRI: Low signal; best on coronal PD fat-sat or MR arthrogram",
  ],0.45,1.72,5.7,2.2,11.5);

  s.addShape(pres.ShapeType.rect,{x:7.1,y:1.3,w:5.9,h:2.9,fill:{color:C.light},line:{color:C.accent,pt:1.5}});
  tag(s,"EXTRINSIC LIGAMENTS",7.1,1.3,C.accent);
  bullets(s,[
    "Volar (Palmar) – stronger & more numerous than dorsal:",
    "  · Radioscaphocapitate (RSC) – most important volar stabiliser",
    "  · Long radiolunate (LRL) & Short radiolunate (SRL)",
    "  · Ulnocarpal: ulnolunate, ulnotriquetral, ulnocapitate",
    "Dorsal: Radiotriquetral (DRC) & dorsal intercarpal (DIC)",
  ],7.25,1.72,5.7,2.2,11.5);

  s.addShape(pres.ShapeType.rect,{x:0.3,y:4.38,w:12.7,h:2.88,fill:{color:C.navy},line:{color:C.gold,pt:2}});
  s.addText("MRI Evaluation of Wrist Ligaments",{x:0.5,y:4.46,w:12.3,h:0.44,fontSize:15,bold:true,color:C.gold});
  const tips = [
    "Best plane: CORONAL – shows SLL, LTL, TFCC en face",
    "Best sequences: PD fat-sat (high contrast for tears)  |  T2* GRE thin slices (articular cartilage)",
    "MR arthrography: Gold standard – gadolinium extravasation through torn ligament into adjacent compartment",
    "SLL tear → contrast from radiocarpal into midcarpal  |  LTL tear → midcarpal into radiocarpal (reverse direction)",
    "Slice thickness ≤2 mm; 3T preferred over 1.5T for intrinsic ligament detail",
  ];
  tips.forEach((t,i) => {
    s.addText([
      {text:"▸ ",options:{bold:true,color:C.gold}},
      {text:t,options:{color:C.white}},
    ],{x:0.5,y:4.96+i*0.44,w:12.3,h:0.38,fontSize:11.5,fontFace:"Calibri"});
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 6 – TFCC ANATOMY  (3 textbook images)
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect,{x:0,y:0,w:13.3,h:7.5,fill:{color:C.white}});
  bar(s,"Triangular Fibrocartilage Complex (TFCC)","Anatomy, components & MRI  –  Imaging Anatomy Vol. 3 (Thieme)");

  img(s,"tfcc_diagram",   0.3,  1.3, 4.1, 3.0);
  cap(s,"Fig 17.34: TFCC coronal section. TFC proper originates from sigmoid notch, inserts on ulnar fovea via proximal & distal laminae. Meniscus homologue (MH) = fibrocartilaginous part of distal lamina.", 0.3,4.35,4.1);

  img(s,"tfcc_mri",       4.6,  1.3, 3.9, 3.0);
  cap(s,"Fig 17.35a–b: MRI coronal views – TFC (star), proximal lamina (arrowhead), distal lamina (thick arrow). Ligamentum subcruentum = high-signal region between laminae.", 4.6,4.35,3.9);

  img(s,"tfcc_serial",    8.7,  1.3, 4.3, 3.0);
  cap(s,"Fig 17.35c–g: Serial coronal (dorsal→palmar) & axial MRI. vRUL & dRUL converge toward fovea. S=ulnar styloid; UCL=ulnar collateral ligament; ECU=extensor carpi ulnaris.", 8.7,4.35,4.3);

  s.addShape(pres.ShapeType.rect,{x:0.3,y:5.18,w:12.7,h:2.1,fill:{color:C.navy}});
  s.addText("TFCC Components",{x:0.5,y:5.26,w:12.3,h:0.38,fontSize:14,bold:true,color:C.gold});
  const comps = [
    ["TFC proper","Biconcave fibrocartilage disk; radial origin (sigmoid notch) → ulnar insertion (fovea + styloid)"],
    ["Dorsal & Volar radioulnar ligaments","Primary DRUJ stabilisers; deep fibres insert into fovea; superficial into styloid"],
    ["Meniscus homologue (UMH)","Dense fibrous tissue; connects TFC proper → UCL → ECU sheath"],
    ["Ulnar collateral ligament (UCL)","Reinforces ulnar aspect; styloid, radioulnar & collateral components"],
    ["ECU subsheath","6th extensor compartment; integral to TFCC complex stability"],
  ];
  comps.forEach(([n,d],i) => {
    s.addText([
      {text:n+": ",options:{bold:true,color:C.gold}},
      {text:d,options:{color:C.white}},
    ],{x:0.5,y:5.68+i*0.31,w:12.3,h:0.28,fontSize:10.5,fontFace:"Calibri"});
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 7 – TENDONS
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect,{x:0,y:0,w:13.3,h:7.5,fill:{color:C.white}});
  bar(s,"Tendons & Tendon Sheaths – MRI Anatomy","Flexor & extensor compartments at the wrist");

  s.addShape(pres.ShapeType.rect,{x:0.3,y:1.3,w:5.9,h:5.95,fill:{color:C.light},line:{color:C.teal,pt:1.5}});
  tag(s,"EXTENSOR COMPARTMENTS (6)",0.3,1.3,C.teal);
  s.addText("Compartment  |  Tendon(s)  |  Clinical note",
    {x:0.42,y:1.78,w:5.7,h:0.35,fontSize:10,bold:true,color:C.teal,fontFace:"Calibri"});
  const exts = [
    ["1","APL + EPB","De Quervain's tenosynovitis"],
    ["2","ECRL + ECRB","Intersection syndrome"],
    ["3","EPL","Passes around Lister's tubercle"],
    ["4","EDC + EIP","Largest compartment"],
    ["5","EDM (EDQ)","Over DRUJ"],
    ["6","ECU","Integral part of TFCC"],
  ];
  exts.forEach(([c,t,n],i) => {
    const bg = i%2===0 ? C.white : "D6EAF8";
    s.addShape(pres.ShapeType.rect,{x:0.37,y:2.18+i*0.72,w:5.78,h:0.68,fill:{color:bg}});
    s.addText([
      {text:c+"  ",options:{bold:true,color:C.teal}},
      {text:t,options:{color:C.navy}},
    ],{x:0.44,y:2.25+i*0.72,w:2.5,h:0.5,fontSize:11,fontFace:"Calibri"});
    s.addText(n,{x:2.98,y:2.25+i*0.72,w:3.1,h:0.5,fontSize:10,color:C.gray,italic:true,fontFace:"Calibri"});
  });

  s.addShape(pres.ShapeType.rect,{x:6.5,y:1.3,w:6.5,h:5.95,fill:{color:C.light},line:{color:C.accent,pt:1.5}});
  tag(s,"FLEXOR TENDONS & CARPAL TUNNEL",6.5,1.3,C.accent);
  s.addText("Contents of the carpal tunnel (deep to flexor retinaculum):",
    {x:6.65,y:1.78,w:6.2,h:0.38,fontSize:11,bold:true,color:C.accent,fontFace:"Calibri"});
  bullets(s,[
    "4 × FDS tendons (superficial – 2 rows)",
    "4 × FDP tendons (deep)",
    "1 × FPL tendon (most lateral)",
    "Median nerve (most superficial & radial position)",
    "Occasionally: persistent median artery",
  ],6.65,2.22,6.2,2.0,12);

  s.addText("Guyon's Canal (Ulnar Tunnel):",
    {x:6.65,y:4.4,w:6.2,h:0.38,fontSize:11,bold:true,color:C.teal,fontFace:"Calibri"});
  bullets(s,[
    "Bounded by pisiform (medial) & hook of hamate (lateral)",
    "Contents: ulnar nerve + ulnar artery",
    "Nerve divides into superficial (sensory) & deep (motor) branches",
    "Zone I: proximal to bifurcation – both motor & sensory",
    "Zone II: deep motor branch (hypothenar wasting if compressed)",
    "Zone III: superficial sensory branch only",
  ],6.65,4.82,6.2,2.2,11.5);
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 8 – NEUROVASCULAR  (3 textbook images)
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect,{x:0,y:0,w:13.3,h:7.5,fill:{color:C.white}});
  bar(s,"Neurovascular Anatomy – MRI","Persistent median artery, Guyon's canal, palmar arches  –  Imaging Anatomy Vol. 3 (Thieme)");

  img(s,"median_artery",  0.3, 1.3, 4.3, 2.9);
  cap(s,"Fig 4.32: Persistent median artery (arrows) – axial MRI series of the forearm/wrist. Artery runs alongside median nerve within carpal tunnel. Present in ~10%; may compress median nerve → CTS.", 0.3,4.28,4.3);

  img(s,"ulnar_ax",       4.8, 1.3, 4.0, 2.9);
  cap(s,"Fig 17.53: Serial axial MRI of the ulnar tunnel (Guyon's canal). Trifurcation of ulnar nerve shown distally. Deep (motor) branch passes through pisohamate hiatus. P=pisiform; H=hamate hook; FCU; ABDM.", 4.8,4.28,4.0);

  img(s,"ulnar_sag",      9.1, 1.3, 3.9, 2.9);
  cap(s,"Fig 17.53 (cont.): Sagittal MRI of Guyon's canal. Deep branch of ulnar nerve & artery entering pisohamate hiatus on course to deep palmar space. PHL=pisohamate ligament.", 9.1,4.28,3.9);

  s.addShape(pres.ShapeType.rect,{x:0.3,y:5.28,w:12.7,h:2.0,fill:{color:C.navy}});
  s.addText("Key Neurovascular Points on MRI",{x:0.5,y:5.36,w:12.3,h:0.4,fontSize:14,bold:true,color:C.gold});
  [
    "Radial artery crosses scaphoid in anatomical snuff box → anastomoses with deep palmar arch → critical retrograde supply to scaphoid proximal pole",
    "Persistent median artery (~10%): runs with median nerve in carpal tunnel; can contribute to or cause CTS; hypervascular variants symptomatic",
    "Guyon's canal Zones: I = motor+sensory | II = pure motor (deep branch) | III = pure sensory (superficial branch)",
    "Compressed nerve on MRI: T2 hyperintensity, swelling proximal to compression, loss of normal fascicular pattern",
  ].forEach((t,i) => {
    s.addText([
      {text:"▸ ",options:{bold:true,color:C.gold}},
      {text:t,options:{color:C.white}},
    ],{x:0.5,y:5.8+i*0.35,w:12.3,h:0.31,fontSize:10.5,fontFace:"Calibri"});
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 9 – MRI PROTOCOLS
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect,{x:0,y:0,w:13.3,h:7.5,fill:{color:C.white}});
  bar(s,"MRI Protocols & Sequences for the Wrist","Recommended sequences, planes & indications");

  const seqs = [
    {seq:"T1 Coronal",         use:"Bone anatomy, AVN (low signal marrow), ligament morphology, anatomy",                   tip:"Fat is bright; bone marrow bright in adults"},
    {seq:"PD Fat-Sat Coronal",  use:"Gold standard for TFCC, SLL, LTL tears; bone marrow oedema; fluid-sensitive",           tip:"Most sensitive for intrinsic ligament tears"},
    {seq:"T2 / PD Axial",      use:"Carpal tunnel contents, nerve compression, tendons, tenosynovitis",                     tip:"Fluid bright; tenosynovitis easily identified"},
    {seq:"STIR Coronal",        use:"Occult scaphoid fractures, bone marrow oedema, AVN screening",                          tip:"Highly sensitive; fat suppressed; fluid = bright"},
    {seq:"T2* GRE (3D)",       use:"Thin-slice articular cartilage, intrinsic ligaments, sub-mm reformats",                  tip:"Sub-mm slices; any plane reconstruction"},
    {seq:"MR Arthrography",     use:"Gold standard for partial/full ligament tears; TFCC Palmer grading; compartment leaks",  tip:"Gad into radiocarpal; 3-compartment study optimal"},
  ];

  seqs.forEach((r,i) => {
    const y = 1.35 + i*1.0;
    const cols = [C.teal, C.accent, C.navy, "1A6B3A", "7D3C98", C.red];
    const c = cols[i];
    s.addShape(pres.ShapeType.rect,{x:0.3,y,w:12.7,h:0.88,fill:{color:C.light},line:{color:c,pt:1}});
    s.addShape(pres.ShapeType.rect,{x:0.3,y,w:2.75,h:0.88,fill:{color:c}});
    s.addText(r.seq,{x:0.33,y:y+0.17,w:2.7,h:0.55,fontSize:12,bold:true,color:C.white,align:"center",fontFace:"Calibri"});
    s.addText(r.use,{x:3.25,y:y+0.08,w:5.75,h:0.74,fontSize:11.5,color:C.navy,fontFace:"Calibri",valign:"middle"});
    s.addShape(pres.ShapeType.rect,{x:9.15,y:y+0.07,w:3.7,h:0.74,fill:{color:c}});
    s.addText(r.tip,{x:9.18,y:y+0.07,w:3.65,h:0.74,fontSize:10,color:C.white,fontFace:"Calibri",italic:true,valign:"middle"});
  });

  s.addShape(pres.ShapeType.rect,{x:0.3,y:7.12,w:12.7,h:0.3,fill:{color:C.gold}});
  s.addText("Coil: dedicated wrist/extremity coil  |  Field strength: 3T recommended  |  Position: 'Superman' (arm overhead) or side-lying",
    {x:0.3,y:7.12,w:12.7,h:0.3,fontSize:9.5,color:C.navy,align:"center",bold:true});
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 10 – PATHOLOGY: TFCC TEARS
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect,{x:0,y:0,w:13.3,h:7.5,fill:{color:C.white}});
  bar(s,"Pathology: TFCC Tears – Palmer Classification","MRI features & clinical correlation");

  s.addShape(pres.ShapeType.rect,{x:0.3,y:1.3,w:6.2,h:5.9,fill:{color:C.light},line:{color:C.teal,pt:1.5}});
  tag(s,"PALMER CLASSIFICATION",0.3,1.3,C.teal);

  const groups = [
    {title:"Class I – TRAUMATIC",color:C.red,items:[
      "IA: Central perforation – avascular zone (most common)",
      "IB: Ulnar avulsion ± ulnar styloid fracture (peripheral; repairable)",
      "IC: Distal avulsion – ulnocarpal ligament injury",
      "ID: Radial avulsion – from sigmoid notch",
    ]},
    {title:"Class II – DEGENERATIVE",color:C.teal,items:[
      "IIA: TFCC wear (chondromalacia of lunate/ulna)",
      "IIB: Chondromalacia + lunate/ulna cartilage changes",
      "IIC: TFCC perforation (central)",
      "IID: Perforation + LTL tear",
      "IIE: Perforation + LTL + SLL tears → SLAC wrist",
    ]},
  ];

  let yo = 1.72;
  groups.forEach(({title,color,items}) => {
    s.addShape(pres.ShapeType.rect,{x:0.35,y:yo,w:6.1,h:0.4,fill:{color}});
    s.addText(title,{x:0.38,y:yo+0.06,w:6.05,h:0.28,fontSize:11.5,bold:true,color:C.white});
    yo += 0.48;
    items.forEach(it => {
      s.addText("  · "+it,{x:0.4,y:yo,w:5.9,h:0.34,fontSize:10.5,color:C.navy,fontFace:"Calibri"});
      yo += 0.36;
    });
    yo += 0.12;
  });

  s.addShape(pres.ShapeType.rect,{x:6.8,y:1.3,w:6.2,h:5.9,fill:{color:C.navy}});
  tag(s,"MRI FEATURES",6.8,1.3,C.red);

  s.addText("Direct Signs of TFCC Tear:",{x:7.0,y:1.75,w:5.8,h:0.38,fontSize:12,bold:true,color:C.gold});
  [
    "Focal discontinuity / perforation in low-signal TFC disk",
    "Fluid signal (T2 hyperintensity) extending through the TFCC",
    "Loss of normal biconcave shape of the articular disk",
    "Gadolinium extravasation on MR arthrography (gold standard)",
    "Central perforations: T2 bright gap in avascular central zone",
    "Peripheral (foveal) tears: T2 signal at ulnar insertion; proximal lamina irregularity",
  ].forEach((t,i) => {
    s.addText([
      {text:"▸ ",options:{color:C.gold,bold:true}},
      {text:t,options:{color:C.white}},
    ],{x:7.0,y:2.18+i*0.4,w:5.8,h:0.36,fontSize:11,fontFace:"Calibri"});
  });

  s.addText("Indirect Signs:",{x:7.0,y:4.65,w:5.8,h:0.38,fontSize:12,bold:true,color:C.gold});
  [
    "DRUJ effusion (isolated → high suspicion for TFCC tear)",
    "Ulnocarpal joint effusion",
    "Bone marrow oedema – ulnar head / lunate (ulnocarpal impaction)",
  ].forEach((t,i) => {
    s.addText("  · "+t,{x:7.0,y:5.08+i*0.36,w:5.8,h:0.32,fontSize:10.5,color:C.light,fontFace:"Calibri"});
  });

  s.addShape(pres.ShapeType.rect,{x:6.8,y:6.28,w:6.2,h:0.75,fill:{color:C.red}});
  s.addText("Ulnar positive variance → increased ulnocarpal load → predisposes to Class II degenerative tears. Measure on neutral PA wrist radiograph.",
    {x:6.9,y:6.34,w:6.0,h:0.62,fontSize:10.5,color:C.white,bold:true,fontFace:"Calibri",wrap:true});
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 11 – PATHOLOGY: LIGAMENT INJURIES
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect,{x:0,y:0,w:13.3,h:7.5,fill:{color:C.white}});
  bar(s,"Pathology: Ligament Injuries – SLL & LTL","DISI and VISI instability patterns on MRI & radiograph");

  s.addShape(pres.ShapeType.rect,{x:0.3,y:1.3,w:6.1,h:2.85,fill:{color:C.light},line:{color:C.red,pt:2}});
  tag(s,"SLL TEAR (Scapholunate)",0.3,1.3,C.red);
  bullets(s,[
    "Mechanism: FOOSH with wrist hyperextended & radially deviated",
    "MRI: T2 bright discontinuity in dorsal band (strongest portion) of SLL",
    "Coronal PD fat-sat: irregular/absent low-signal ligament band",
    "MR arthrography: contrast from radiocarpal → midcarpal joint",
    "Radiograph: scapholunate gap >3 mm ('Terry Thomas sign')",
    "Scaphoid ring sign: foreshortened scaphoid on PA view",
  ],0.45,1.72,5.8,2.1,11);

  s.addShape(pres.ShapeType.rect,{x:7.0,y:1.3,w:6.1,h:2.85,fill:{color:C.light},line:{color:C.teal,pt:2}});
  tag(s,"LTL TEAR (Lunotriquetral)",7.0,1.3,C.teal);
  bullets(s,[
    "Mechanism: FOOSH with wrist in radial deviation or direct ulnar blow",
    "MRI: Disruption of membranous & volar portions of LTL",
    "MR arthrography: contrast from midcarpal → radiocarpal (reverse of SLL)",
    "Often associated with TFCC injury (combined ulnar-sided pathology)",
    "Leads to VISI pattern when secondary stabilisers also fail",
    "Less common than SLL tear; frequently under-diagnosed",
  ],7.15,1.72,5.8,2.1,11);

  s.addShape(pres.ShapeType.rect,{x:0.3,y:4.3,w:12.7,h:3.0,fill:{color:C.navy}});
  s.addText("Carpal Instability Patterns",{x:0.5,y:4.38,w:12.3,h:0.44,fontSize:15,bold:true,color:C.gold});

  s.addShape(pres.ShapeType.rect,{x:0.5,y:4.88,w:5.8,h:2.22,fill:{color:C.teal}});
  s.addText("DISI – Dorsal Intercalated Segmental Instability",{x:0.6,y:4.95,w:5.6,h:0.42,fontSize:12,bold:true,color:C.gold});
  s.addText("Cause: SLL tear → scaphoid flexes; lunate extends dorsally\nXR: Scapholunate angle >60° (normal 30–60°); lunate dorsal tilt\nMRI lateral: lunate dorsal angulation; scaphoid palmar flexion\nProgresses to SLAC (Scapholunate Advanced Collapse) wrist",
    {x:0.6,y:5.4,w:5.6,h:1.62,fontSize:10.5,color:C.white,fontFace:"Calibri"});

  s.addShape(pres.ShapeType.rect,{x:7.0,y:4.88,w:5.8,h:2.22,fill:{color:C.accent}});
  s.addText("VISI – Volar Intercalated Segmental Instability",{x:7.1,y:4.95,w:5.6,h:0.42,fontSize:12,bold:true,color:C.gold});
  s.addText("Cause: LTL tear → lunate flexes with scaphoid; triquetrum extends\nXR: Scapholunate angle <30°; capitolunate angle reversed\nMRI: Lunate volar tilt on lateral projection\nLess common; less destructive progression than DISI",
    {x:7.1,y:5.4,w:5.6,h:1.62,fontSize:10.5,color:C.white,fontFace:"Calibri"});
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 12 – PATHOLOGY: SCAPHOID  (3 images)
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect,{x:0,y:0,w:13.3,h:7.5,fill:{color:C.white}});
  bar(s,"Pathology: Scaphoid Fractures & AVN","Imaging strategy, MRI findings  –  Grainger & Allison's Diagnostic Radiology");

  img(s,"scaphoid_xr",  0.3,  1.3, 4.0, 2.8);
  cap(s,"Fig 45.41: Scaphoid series – lateral, PA & both obliques. Forehand oblique elongates the scaphoid and reveals distal pole fracture. Standard 4-view series at initial presentation.", 0.3,4.18,4.0);

  img(s,"scaphoid_sup", 4.55, 1.3, 4.0, 2.8);
  cap(s,"Fig 45.42: Blood supply & union rates by fracture location. Vessels enter distally → retrograde supply to proximal pole. More proximal the fracture = higher risk of AVN and non-union.", 4.55,4.18,4.0);

  img(s,"scaphoid_avn", 8.8,  1.3, 4.2, 2.8);
  cap(s,"Fig 45.43: MRI of scaphoid non-union and AVN. Persistent fracture line at waist; T1 low signal in proximal pole (marrow necrosis) – pathognomonic for avascular necrosis.", 8.8,4.18,4.2);

  s.addShape(pres.ShapeType.rect,{x:0.3,y:5.15,w:12.7,h:2.15,fill:{color:C.navy}});
  s.addText("Scaphoid Imaging Strategy & MRI Role",{x:0.5,y:5.23,w:12.3,h:0.42,fontSize:14,bold:true,color:C.gold});
  [
    "60% of all carpal fractures | Mechanism: FOOSH | Clinical: anatomical snuff box tenderness + pain on scaphoid compression",
    "Initial plain films NEGATIVE in 20–30% of true fractures → immobilise & re-image at 10–14 days OR proceed to MRI",
    "MRI (STIR): Most sensitive/specific (>90%) for occult fractures – marrow oedema visible within hours of injury",
    "AVN: T1 low signal proximal pole; T2 variable; gadolinium non-enhancement confirms avascular zone",
    "CT: Best for fracture geometry, displacement & surgical planning; inferior sensitivity to MRI for occult/hairline fractures",
    "Non-union: persistent fracture line + sclerosis; humpback deformity → SNAC wrist progression",
  ].forEach((t,i) => {
    s.addText([
      {text:"▸ ",options:{bold:true,color:C.gold}},
      {text:t,options:{color:C.white}},
    ],{x:0.5,y:5.7+i*0.27,w:12.3,h:0.24,fontSize:10,fontFace:"Calibri"});
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 13 – PATHOLOGY: SLAC & SNAC
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect,{x:0,y:0,w:13.3,h:7.5,fill:{color:C.white}});
  bar(s,"Pathology: Carpal Instability – SLAC & SNAC Wrist","End-stage carpal collapse patterns on MRI and radiograph");

  s.addShape(pres.ShapeType.rect,{x:0.3,y:1.3,w:6.1,h:5.95,fill:{color:C.light},line:{color:C.red,pt:2}});
  s.addText("SLAC – Scapholunate Advanced Collapse",{x:0.42,y:1.38,w:5.9,h:0.5,fontSize:13,bold:true,color:C.red});
  s.addText("Chronic SLL tear → abnormal kinematics → progressive arthritis",
    {x:0.42,y:1.92,w:5.9,h:0.36,fontSize:10.5,color:C.gray,italic:true,fontFace:"Calibri"});
  const slac = [
    ["Stage I","Radial styloid–distal scaphoid arthritis (tip of styloid)"],
    ["Stage II","Radioscaphoid arthritis (entire scaphoid fossa involved)"],
    ["Stage III","Capitolunate arthritis; capitate migrates proximally"],
    ["Stage IV","Radiolunate arthritis (relatively preserved until late stage)"],
  ];
  slac.forEach(([st,d],i) => {
    s.addShape(pres.ShapeType.rect,{x:0.42,y:2.38+i*0.88,w:5.78,h:0.78,fill:{color:i%2===0?C.white:"FADBD8"}});
    s.addText(st,{x:0.5,y:2.46+i*0.88,w:1.3,h:0.6,fontSize:12,bold:true,color:C.red,fontFace:"Calibri"});
    s.addText(d,{x:1.85,y:2.46+i*0.88,w:4.2,h:0.6,fontSize:11,color:C.navy,fontFace:"Calibri"});
  });
  s.addText("MRI: Joint space narrowing + cartilage loss in above sequence;\nbone marrow oedema at articular margins; subchondral cysts;\nscaphoid flexion (DISI pattern) on sagittal T1.",
    {x:0.42,y:6.0,w:5.8,h:1.0,fontSize:10.5,color:C.gray,fontFace:"Calibri",italic:true});

  s.addShape(pres.ShapeType.rect,{x:7.0,y:1.3,w:6.1,h:5.95,fill:{color:C.light},line:{color:C.teal,pt:2}});
  s.addText("SNAC – Scaphoid Non-union Advanced Collapse",{x:7.1,y:1.38,w:5.9,h:0.5,fontSize:13,bold:true,color:C.teal});
  s.addText("Scaphoid non-union → humpback deformity → DISI pattern → arthritis",
    {x:7.1,y:1.92,w:5.9,h:0.36,fontSize:10.5,color:C.gray,italic:true,fontFace:"Calibri"});
  const snac = [
    ["Stage I","Radial styloid–distal scaphoid fragment arthritis"],
    ["Stage II","Radioscaphoid arthritis (proximal fragment/fossa)"],
    ["Stage III","Capitolunate arthritis + midcarpal involvement"],
  ];
  snac.forEach(([st,d],i) => {
    s.addShape(pres.ShapeType.rect,{x:7.1,y:2.38+i*0.88,w:5.78,h:0.78,fill:{color:i%2===0?C.white:"D5F5E3"}});
    s.addText(st,{x:7.18,y:2.46+i*0.88,w:1.3,h:0.6,fontSize:12,bold:true,color:C.teal});
    s.addText(d,{x:8.52,y:2.46+i*0.88,w:4.2,h:0.6,fontSize:11,color:C.navy,fontFace:"Calibri"});
  });

  s.addShape(pres.ShapeType.rect,{x:7.1,y:5.08,w:5.78,h:2.0,fill:{color:C.navy}});
  s.addText("SNAC vs SLAC – Imaging Differences",{x:7.18,y:5.15,w:5.6,h:0.4,fontSize:12,bold:true,color:C.gold});
  [
    "SNAC: Scaphoid fracture non-union visible; humpback deformity; radial-sided predominance",
    "SLAC: No fracture; SLL insufficiency; more generalised; radiolunate preserved until Stage IV",
    "Both: DISI; capitate proximal migration; subchondral sclerosis & cysts",
    "MRI superior to CT for cartilage loss quantification & ligament status assessment",
  ].forEach((t,i) => {
    s.addText([
      {text:"• ",options:{color:C.gold,bold:true}},
      {text:t,options:{color:C.white}},
    ],{x:7.18,y:5.58+i*0.35,w:5.6,h:0.3,fontSize:10,fontFace:"Calibri"});
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 14 – PATHOLOGY: CTS & OTHER
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect,{x:0,y:0,w:13.3,h:7.5,fill:{color:C.white}});
  bar(s,"Pathology: CTS, De Quervain's, Ganglion & Kienbock's","MRI features of common wrist pathologies");

  s.addShape(pres.ShapeType.rect,{x:0.3,y:1.3,w:6.1,h:5.95,fill:{color:C.light},line:{color:C.accent,pt:1.5}});
  tag(s,"CARPAL TUNNEL SYNDROME (CTS)",0.3,1.3,C.accent);
  s.addText("Most common nerve compression syndrome – female:male ~3:1",
    {x:0.45,y:1.75,w:5.8,h:0.36,fontSize:11,color:C.navy,bold:true});
  bullets(s,[
    "Causes: idiopathic (most common), pregnancy, hypothyroidism, RA, DM, amyloid, fracture deformity, tenosynovitis, space-occupying lesion",
  ],0.45,2.15,5.8,0.75,11);
  s.addText("MRI Features:",{x:0.45,y:2.95,w:5.8,h:0.35,fontSize:11.5,bold:true,color:C.accent});
  [
    "T2 hyperintensity of median nerve (oedema/demyelination)",
    "Nerve swelling proximal to tunnel (at pisiform level)",
    "Flattening of nerve at hamate hook level",
    "Bowing of flexor retinaculum (palmar >4 mm displacement)",
    "Increased cross-sectional area (>10–15 mm² at pisiform)",
    "Space-occupying lesion: ganglion, lipoma, anomalous muscle, persistent median artery, thrombosed vessel",
    "Gadolinium enhancement in severe/chronic cases",
  ].forEach((t,i) => {
    s.addText("  · "+t,{x:0.45,y:3.35+i*0.42,w:5.8,h:0.38,fontSize:10.5,color:C.navy,fontFace:"Calibri"});
  });

  s.addShape(pres.ShapeType.rect,{x:6.7,y:1.3,w:6.3,h:5.95,fill:{color:C.navy}});
  tag(s,"OTHER WRIST PATHOLOGIES",6.7,1.3,C.gold);

  const others = [
    {title:"Guyon's Canal Syndrome",col:C.gold,pts:[
      "Ulnar nerve compression at wrist | causes: ganglion (commonest), hamate hook fracture, ulnar artery aneurysm/thrombosis, cyclist's palsy",
      "MRI: T2 bright nerve swelling; identify mass or vascular lesion; zone of compression determines motor vs sensory deficit",
    ]},
    {title:"De Quervain's Tenosynovitis",col:"E74C3C",pts:[
      "1st extensor compartment (APL + EPB) stenosing tenosynovitis | positive Finkelstein test",
      "MRI: peritendinous T2/PD hyperintensity; tendon sheath fluid; retinaculum thickening; inter-compartment septum variant",
    ]},
    {title:"Ganglion Cyst",col:C.accent,pts:[
      "Commonest wrist mass; dorsal > volar | adjacent to SLL (dorsal) or RSC ligament (volar)",
      "MRI: T1 low, T2 very bright, well-defined margin, follows joint/tendon sheath | dorsal ganglion adjacent to SLL → look for ligament tear",
    ]},
    {title:"Kienbock's Disease (Lunate AVN)",col:C.green,pts:[
      "Avascular necrosis of lunate; associated with ulnar negative variance (increased stress on lunate)",
      "MRI: T1 diffuse low signal in lunate; T2 variable; gadolinium non-enhancement confirms avascular zone | Lichtman staging on MRI (Stage IIIB: collapse + fixed scaphoid rotation)",
    ]},
  ];

  let yo2 = 1.7;
  others.forEach(({title,col,pts}) => {
    s.addShape(pres.ShapeType.rect,{x:6.82,y:yo2,w:6.06,h:0.34,fill:{color:col}});
    s.addText(title,{x:6.87,y:yo2+0.04,w:5.96,h:0.26,fontSize:11,bold:true,color:C.white,fontFace:"Calibri"});
    yo2 += 0.4;
    pts.forEach(p => {
      s.addText("  · "+p,{x:6.87,y:yo2,w:5.96,h:0.52,fontSize:10,color:C.light,fontFace:"Calibri",wrap:true});
      yo2 += 0.56;
    });
    yo2 += 0.05;
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 15 – PALMAR ARCHES  (2 images)
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect,{x:0,y:0,w:13.3,h:7.5,fill:{color:C.white}});
  bar(s,"Vascular Anatomy – Palmar Arches & Variants","CT angiography and MR angiography  –  Imaging Anatomy Vol. 3 (Thieme)");

  img(s,"palmar_arch",  0.3,  1.3, 4.3, 3.6);
  cap(s,"Fig 4.33: Complete superficial palmar arch (CT angiography). Radial artery → princeps pollicis + radialis indicis; superficial palmar branch of ulnar artery completes the arch. Deep palmar arch formed by radial artery deep to flexor tendons.", 0.3,4.98,4.3);

  img(s,"incomp_arch",  4.85, 1.3, 4.1, 3.6);
  cap(s,"Fig 4.34: Incomplete superficial palmar arch with ulnar dominance. Radial artery terminates in princeps pollicis. Multiple distal digital artery occlusions (arrows) due to chronic autoimmune vasculitis; distal reconstitution via collaterals.", 4.85,4.98,4.1);

  s.addShape(pres.ShapeType.rect,{x:9.2,y:1.3,w:3.8,h:5.9,fill:{color:C.navy}});
  s.addText("Key Points",{x:9.3,y:1.38,w:3.6,h:0.4,fontSize:13,bold:true,color:C.gold});
  [
    "Superficial palmar arch: ~80% complete (ulnar dominant)",
    "Deep palmar arch: radial artery dominant",
    "Rich anastomosis: single vessel occlusion rarely causes ischaemia",
    "Dorsal carpal arch: radial artery in 80%",
    "Allen's test: assess arch patency before radial artery cannulation",
    "Scaphoid blood supply: enters dorsoradial ridge → retrograde to proximal pole → explains AVN after waist fractures",
    "MRA replaces conventional angiography for arch anatomy assessment",
    "Hypothenar hammer syndrome: repetitive trauma to ulnar artery at hamate hook → thrombosis/aneurysm",
  ].forEach((t,i) => {
    s.addText([
      {text:"▸ ",options:{color:C.gold,bold:true}},
      {text:t,options:{color:C.white}},
    ],{x:9.3,y:1.85+i*0.61,w:3.6,h:0.55,fontSize:10,fontFace:"Calibri"});
  });
}

// ════════════════════════════════════════════════════════════════
//  SLIDE 16 – SUMMARY
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  s.addShape(pres.ShapeType.rect,{x:0,y:0,w:13.3,h:7.5,fill:{color:C.darkbg}});
  s.addShape(pres.ShapeType.rect,{x:0,y:1.05,w:13.3,h:0.06,fill:{color:C.gold}});
  s.addText("KEY TEACHING POINTS",{x:0.4,y:0.18,w:12.5,h:0.82,fontSize:30,bold:true,color:C.white,fontFace:"Calibri",charSpacing:4});

  const boxes = [
    {label:"TFCC",color:C.teal,items:[
      "TFC proper: biconcave disk; avascular central zone",
      "Palmer I (traumatic) vs II (degenerative)",
      "Coronal PD fat-sat: primary MRI sequence",
      "Foveal tears (IB): peripheral, repairable",
    ]},
    {label:"LIGAMENTS",color:C.accent,items:[
      "SLL > LTL: most clinically significant",
      "SLL tear → DISI | LTL tear → VISI",
      "MR arthrography: gold standard for tears",
      "SLAC wrist: end-stage SLL insufficiency",
    ]},
    {label:"SCAPHOID",color:C.gold,items:[
      "MRI (STIR): most sensitive for occult fracture",
      "AVN: T1 low signal, gadolinium non-enhancing",
      "SNAC mirrors SLAC in staged progression",
      "Waist fractures: ~30% risk of AVN",
    ]},
    {label:"PROTOCOLS",color:C.red,items:[
      "3T + dedicated coil: optimal imaging",
      "Coronal: SLL, LTL, TFCC evaluation",
      "Axial: tendons, nerves, carpal tunnel",
      "MR arthrography: compartment leak = tear",
    ]},
  ];

  boxes.forEach(({label,color,items},i) => {
    const x = 0.35 + (i%2)*6.45;
    const y = 1.3 + Math.floor(i/2)*3.0;
    s.addShape(pres.ShapeType.rect,{x,y,w:6.1,h:2.7,fill:{color:C.dark2},line:{color,pt:2}});
    s.addShape(pres.ShapeType.rect,{x,y,w:6.1,h:0.46,fill:{color}});
    s.addText(label,{x:x+0.1,y:y+0.06,w:5.9,h:0.34,fontSize:14,bold:true,color:C.white,fontFace:"Calibri"});
    items.forEach((item,j) => {
      s.addText([
        {text:"✓ ",options:{color,bold:true}},
        {text:item,options:{color:C.white}},
      ],{x:x+0.15,y:y+0.55+j*0.51,w:5.8,h:0.46,fontSize:11,fontFace:"Calibri"});
    });
  });

  s.addText("Sources: Imaging Anatomy – Bones, Joints, Vessels & Nerves, Thieme (9781626239845)  |  Grainger & Allison's Diagnostic Radiology (9780323760751)",
    {x:0.4,y:7.22,w:12.5,h:0.24,fontSize:9,color:C.gray,italic:true,align:"center"});
}

// ── Write ────────────────────────────────────────────────────────
pres.writeFile({ fileName: "/home/daytona/workspace/wrist-mri-ppt/Wrist_MRI_Radiology_Teaching_v2.pptx" })
  .then(() => console.log("DONE: Wrist_MRI_Radiology_Teaching_v2.pptx"))
  .catch(e => { console.error(e); process.exit(1); });
Running Command

cd /home/daytona/workspace/wrist-mri-ppt && node build2.js 2>&1

Running Command

ls -lh /home/daytona/workspace/wrist-mri-ppt/Wrist_MRI_Radiology_Teaching_v2.pptx

Down from 32 MB to 13 MB using local file paths instead of base64 embedding. This should open cleanly in Keynote.

Wrist MRI Radiology Teaching v2

Presentation · PPTX

What changed to fix the Keynote issue:
  • Images are now embedded as proper file references (not base64 strings) - this is what Keynote expects
  • All 11 images were resized to max 1400px wide before embedding, reducing file size further
  • Zero warnings during build - clean PPTX structure
The file is otherwise identical in content - all 16 slides, all 11 textbook images from Imaging Anatomy Vol. 3 and Grainger & Allison's, full pathology coverage.
This is a shared conversation. Sign in to Orris to start your own chat.