Topographic anotomy of respiratory system with diagrams and 9 pages

Reading File
Asking for Preferences
Finding Sources
Finding Sources
Searching Images

topographic anatomy respiratory system trachea bronchi lungs

Finding Sources
Finding Sources
Searching Images

lung lobes anatomy diagram pleura fissures

Reading File
Searching Images

trachea anatomy cross section cartilage rings

Searching Images

bronchial tree bronchopulmonary segments diagram

Reading File
Searching Images

diaphragm respiratory muscles anatomy

Reading File
Running Command

ls -la /home/daytona/workspace/ 2>/dev/null || mkdir -p /home/daytona/workspace

Running Command

mkdir -p /home/daytona/workspace/respiratory-anatomy && echo "Directory created"

Writing File

~/respiratory-anatomy/build.js

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

// ─── Image URLs ───────────────────────────────────────────────────────────────
const IMG_URLS = [
  // Slide 2 – Upper respiratory tract overview
  "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_f4056d8fd2c71be609d60fe2316facaa1a7ad4567c2f4e843f9354bdc7509359.jpg",
  // Slide 3 – Larynx anatomy
  "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_032dd5edc6d7800e225c57f64777356b9123696a20be0eedea11b8d7982559b8.jpg",
  // Slide 4 – Trachea CT 3D
  "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_c7b531355f895798e106229c9ea6823981c9332a4488b8e6ebbc1b0637c8cbed.jpg",
  // Slide 5 – Bronchial tree diagram
  "https://cdn.orris.care/cdss_images/BAILY_1760544972668_fbd8fc44-bbb4-485a-ad29-d6ed5ee936a5.png",
  // Slide 6 – Lung lobes diagram
  "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_83f94abe7980c4edfa395a28cdb09eabcd5a05aa7ece758dd4bdb45681802911.jpg",
  // Slide 7 – Gross lung specimen
  "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_b80156f9ca5f8f9a3364e2c6b393a31a572584dd3ae07bda6ece5d09277c0bec.jpg",
  // Slide 8 – CT fissures
  "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_d134cdd016f694520bf4194aa8a6624776396876556cb4e36ee271a12c525f09.jpg",
  // Slide 9 – 3D CT tracheobronchial
  "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_fa42ad9b16c0be21ae8ef8d9dc96afaf6c918153a909122f82a03ff3fbc68792.jpg",
];

// Download all images as base64
console.log("Downloading images...");
const rawImages = JSON.parse(
  execSync(
    `node /home/daytona/skills/shared/scripts/fetch_images.js ${IMG_URLS.map(u => `"${u}"`).join(" ")}`
  ).toString()
);

// Build a helper map url -> base64
const imgMap = {};
rawImages.forEach(r => { if (!r.error) imgMap[r.url] = r.base64; });

// ─── Palette ──────────────────────────────────────────────────────────────────
const BG_DARK   = "0D2B45";   // deep navy – dominant
const BG_MID    = "10395A";   // medium navy
const ACCENT1   = "3AC9D6";   // cyan accent
const ACCENT2   = "56CCF2";   // sky blue
const WHITE     = "FFFFFF";
const LIGHT_TXT = "C8E6F4";
const DIVIDER   = "1D5078";

const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.title  = "Topographic Anatomy of the Respiratory System";
pres.author = "Medical Education";

// ─── Helper Functions ─────────────────────────────────────────────────────────

function addBackground(slide, color = BG_DARK) {
  slide.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: 10, h: 5.625,
    fill: { color },
    line: { color, width: 0 }
  });
}

function addSlideNumber(slide, num) {
  slide.addText(`${num} / 9`, {
    x: 9.1, y: 5.3, w: 0.8, h: 0.25,
    fontSize: 8, color: ACCENT1, align: "right"
  });
}

function addSectionBar(slide, title, sub = "") {
  // Teal left bar
  slide.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: 0.18, h: 5.625,
    fill: { color: ACCENT1 }, line: { color: ACCENT1, width: 0 }
  });
  // Top header band
  slide.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: 10, h: 0.72,
    fill: { color: BG_MID }, line: { color: BG_MID, width: 0 }
  });
  slide.addText(title, {
    x: 0.3, y: 0.0, w: 8.5, h: 0.72,
    fontSize: 22, bold: true, color: ACCENT1, valign: "middle", margin: 0
  });
  if (sub) {
    slide.addText(sub, {
      x: 0.3, y: 0.72, w: 9.5, h: 0.32,
      fontSize: 10, color: LIGHT_TXT, italic: true, margin: 0
    });
  }
}

function addBullets(slide, items, opts = {}) {
  const { x = 0.3, y = 1.1, w = 4.5, h = 4.1, fontSize = 12 } = opts;
  const richText = items.map((item, i) => {
    const isLast = i === items.length - 1;
    if (typeof item === "string") {
      return { text: item, options: { bullet: true, color: LIGHT_TXT, fontSize, breakLine: !isLast } };
    }
    // object with { header, text }
    const parts = [
      { text: item.header + ": ", options: { bold: true, color: ACCENT2, fontSize, bullet: true } },
      { text: item.text, options: { color: LIGHT_TXT, fontSize, breakLine: !isLast } }
    ];
    return parts;
  }).flat();
  slide.addText(richText, { x, y, w, h, valign: "top" });
}

// ═══════════════════════════════════════════════════════════════════════════════
//  SLIDE 1 – Title
// ═══════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBackground(slide, BG_DARK);

  // Decorative large circle
  slide.addShape(pres.ShapeType.ellipse, {
    x: 6.5, y: -1.5, w: 5.5, h: 5.5,
    fill: { color: BG_MID }, line: { color: DIVIDER, width: 1 }
  });
  slide.addShape(pres.ShapeType.ellipse, {
    x: 7.2, y: -0.8, w: 4.2, h: 4.2,
    fill: { color: "0B233A" }, line: { color: ACCENT1, width: 1.5 }
  });

  // Teal accent bar (left)
  slide.addShape(pres.ShapeType.rect, {
    x: 0, y: 1.9, w: 0.25, h: 1.8,
    fill: { color: ACCENT1 }, line: { color: ACCENT1, width: 0 }
  });

  // Title
  slide.addText("TOPOGRAPHIC ANATOMY", {
    x: 0.4, y: 1.7, w: 6.5, h: 0.85,
    fontSize: 30, bold: true, color: WHITE, charSpacing: 2, margin: 0
  });
  slide.addText("OF THE RESPIRATORY SYSTEM", {
    x: 0.4, y: 2.5, w: 6.5, h: 0.7,
    fontSize: 22, bold: true, color: ACCENT1, charSpacing: 1, margin: 0
  });

  // Subtitle
  slide.addText("A comprehensive overview of upper and lower airways,\nlung morphology, pleura, and thoracic topography", {
    x: 0.4, y: 3.3, w: 6.2, h: 0.8,
    fontSize: 11, color: LIGHT_TXT, italic: true
  });

  // Bottom tags
  ["Upper Airways", "Trachea", "Bronchi", "Lungs", "Pleura", "Mediastinum"].forEach((tag, i) => {
    slide.addShape(pres.ShapeType.roundRect, {
      x: 0.4 + i * 1.6, y: 4.9, w: 1.5, h: 0.35,
      fill: { color: DIVIDER }, line: { color: ACCENT1, width: 0.75 },
      rectRadius: 0.05
    });
    slide.addText(tag, {
      x: 0.4 + i * 1.6, y: 4.9, w: 1.5, h: 0.35,
      fontSize: 8, color: ACCENT1, align: "center", valign: "middle"
    });
  });

  addSlideNumber(slide, 1);
}

// ═══════════════════════════════════════════════════════════════════════════════
//  SLIDE 2 – Upper Respiratory Tract Overview
// ═══════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBackground(slide);
  addSectionBar(slide, "Upper Respiratory Tract", "Nasal cavity → Pharynx → Larynx");

  const img = imgMap[IMG_URLS[0]];
  if (img) {
    slide.addImage({ data: img, x: 5.7, y: 0.8, w: 4.1, h: 4.6 });
  }

  addBullets(slide, [
    { header: "Nasal Cavity", text: "Extends from nares to choanae; lined by pseudostratified ciliated epithelium; turbinates increase surface area for air conditioning." },
    { header: "Paranasal Sinuses", text: "Maxillary, frontal, ethmoid, and sphenoid sinuses drain into nasal meatus; lined by respiratory mucosa." },
    { header: "Nasopharynx", text: "Posterior to nasal cavity; contains pharyngeal tonsil (adenoid) and openings of Eustachian tubes." },
    { header: "Oropharynx", text: "Between soft palate and epiglottis; bounded laterally by palatine tonsils." },
    { header: "Hypopharynx", text: "From epiglottis to cricoid; communicates with both larynx anteriorly and esophagus posteriorly." },
    { header: "Blood Supply", text: "Sphenopalatine a., anterior & posterior ethmoidal aa.; anterior nasal floor by greater palatine a." }
  ], { x: 0.3, y: 1.1, w: 5.2, h: 4.2, fontSize: 11 });

  addSlideNumber(slide, 2);
}

// ═══════════════════════════════════════════════════════════════════════════════
//  SLIDE 3 – Larynx
// ═══════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBackground(slide);
  addSectionBar(slide, "The Larynx", "C3–C6 Vertebral Level");

  const img = imgMap[IMG_URLS[1]];
  if (img) {
    slide.addImage({ data: img, x: 5.5, y: 0.85, w: 4.3, h: 4.5 });
  }

  addBullets(slide, [
    { header: "Location", text: "Anterior neck, C3–C6; continuous with laryngopharynx above and trachea below." },
    { header: "Cartilages", text: "Thyroid (largest), cricoid (only complete ring), epiglottis (elastic), arytenoid (×2), corniculate & cuneiform (×2 each)." },
    { header: "Vocal Folds", text: "True cords: vocalis muscle + vocal ligament. Rima glottidis is narrowest part of adult airway." },
    { header: "Intrinsic Muscles", text: "Cricothyroid (tensor); posterior crico-arytenoid (only abductor); lateral crico-arytenoid (adductor); transverse arytenoid." },
    { header: "Innervation", text: "Recurrent laryngeal nerve (all intrinsic muscles except cricothyroid). External branch of superior laryngeal n. → cricothyroid." },
    { header: "Clinical", text: "Laryngoscopic view: epiglottis, aryepiglottic folds, false/true cords. Subglottic space prone to edema in croup." }
  ], { x: 0.3, y: 1.1, w: 5.0, h: 4.2, fontSize: 11 });

  addSlideNumber(slide, 3);
}

// ═══════════════════════════════════════════════════════════════════════════════
//  SLIDE 4 – Trachea
// ═══════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBackground(slide);
  addSectionBar(slide, "The Trachea", "From cricoid (C6) to carina (T4–T5)");

  const img = imgMap[IMG_URLS[2]];
  if (img) {
    slide.addImage({ data: img, x: 5.6, y: 0.85, w: 4.2, h: 4.5 });
  }

  addBullets(slide, [
    { header: "Dimensions", text: "~10–11 cm long, ~2 cm diameter in adults; 16–20 C-shaped hyaline cartilage rings open posteriorly." },
    { header: "Posterior Wall", text: "Trachealis muscle (smooth) spans posterior gap; allows esophageal distension during swallowing." },
    { header: "Carina", text: "Bifurcation at T4–T5; right main bronchus more vertical (25°), making right the more common site for inhaled foreign bodies." },
    { header: "Relations", text: "Anterior: thyroid, thymus, great vessels. Posterior: esophagus. Lateral: carotid sheaths, lobes of thyroid." },
    { header: "Blood Supply", text: "Superior & inferior thyroid arteries; tracheal branches of bronchial arteries supply carina region." },
    { header: "Histology", text: "Pseudostratified ciliated columnar epithelium (respiratory epithelium) with goblet cells; submucosal seromucous glands." }
  ], { x: 0.3, y: 1.1, w: 5.1, h: 4.2, fontSize: 11 });

  addSlideNumber(slide, 4);
}

// ═══════════════════════════════════════════════════════════════════════════════
//  SLIDE 5 – Bronchial Tree
// ═══════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBackground(slide);
  addSectionBar(slide, "The Bronchial Tree", "Primary → Lobar → Segmental → Terminal");

  const img = imgMap[IMG_URLS[3]];
  if (img) {
    slide.addImage({ data: img, x: 5.5, y: 0.85, w: 4.3, h: 4.5 });
  }

  addBullets(slide, [
    { header: "Primary Bronchi", text: "Right (shorter, wider, ~25° from midline) and left (longer, narrower, ~45° from midline) main bronchi." },
    { header: "Lobar Bronchi", text: "Right: 3 lobar bronchi (upper, middle, lower). Left: 2 lobar bronchi (upper, lower). Upper = eparterial on right." },
    { header: "Segmental Bronchi", text: "10 segments on right; 8–10 on left. Each segment is an independent surgical unit with its own bronchus + artery." },
    { header: "Terminal Bronchioles", text: "No cartilage; smooth muscle only; ~16 generations from trachea; each supplies 1 acinus (alveolar unit)." },
    { header: "Respiratory Bronchioles", text: "Transitional zone; generations 17–19; have scattered alveoli; site of gas exchange begins here." },
    { header: "Lymphatics", text: "Drain toward bronchopulmonary (hilar) nodes → tracheobronchial nodes → paratracheal nodes → thoracic duct." }
  ], { x: 0.3, y: 1.1, w: 5.0, h: 4.2, fontSize: 11 });

  addSlideNumber(slide, 5);
}

// ═══════════════════════════════════════════════════════════════════════════════
//  SLIDE 6 – Lung Morphology & Lobes
// ═══════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBackground(slide);
  addSectionBar(slide, "Lung Morphology & Lobar Anatomy", "Surface markings and fissures");

  const img = imgMap[IMG_URLS[4]];
  if (img) {
    slide.addImage({ data: img, x: 5.5, y: 0.85, w: 4.3, h: 4.5 });
  }

  addBullets(slide, [
    { header: "Right Lung", text: "3 lobes (upper, middle, lower); 2 fissures: oblique (major) + horizontal (minor). Weight ~620 g. Shorter and wider than left." },
    { header: "Left Lung", text: "2 lobes (upper, lower) + lingula; 1 oblique fissure. Cardiac notch medially. Weight ~567 g." },
    { header: "Oblique Fissure", text: "Runs from T2–T3 posteriorly to 6th rib anteriorly (both lungs); separates upper from lower lobe." },
    { header: "Horizontal Fissure", text: "Right lung only; passes from oblique fissure at mid-axillary line to sternum at 4th costal cartilage." },
    { header: "Surfaces", text: "Costal (ribs), mediastinal (cardiac impression), diaphragmatic (base). Apex projects into root of neck 2.5 cm above medial 1/3 clavicle." },
    { header: "Hilum", text: "Contains: main bronchus, pulmonary artery, 2 pulmonary veins, lymphatics, autonomic nerves." }
  ], { x: 0.3, y: 1.1, w: 5.0, h: 4.2, fontSize: 11 });

  addSlideNumber(slide, 6);
}

// ═══════════════════════════════════════════════════════════════════════════════
//  SLIDE 7 – Pleura
// ═══════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBackground(slide);
  addSectionBar(slide, "The Pleura & Pleural Reflections", "Parietal and visceral layers");

  const img = imgMap[IMG_URLS[5]];
  if (img) {
    slide.addImage({ data: img, x: 5.7, y: 0.85, w: 4.1, h: 4.5 });
  }

  addBullets(slide, [
    { header: "Visceral Pleura", text: "Closely adherent to lung surface; enters fissures. Innervated by autonomic fibers (insensitive to pain)." },
    { header: "Parietal Pleura", text: "Lines inner chest wall, diaphragm, mediastinum. Divisions: costal, diaphragmatic, mediastinal, cervical (cupola)." },
    { header: "Pleural Cavity", text: "Potential space with ~5 mL serous fluid; maintains negative pressure (−2 to −5 cmH₂O at rest) essential for lung inflation." },
    { header: "Costodiaphragmatic Recess", text: "Deepest part of pleural cavity (9th–10th rib level); fills only during deep inspiration; clinical site for thoracocentesis." },
    { header: "Costomediastinal Recess", text: "Anterior recess behind sternum; cardiac area. Contains pleural layers not occupied by lung at rest." },
    { header: "Nerve Supply", text: "Parietal pleura: intercostal nerves (costal) + phrenic n. (diaphragmatic). Pain-sensitive; referred to shoulder tip (phrenic irritation)." }
  ], { x: 0.3, y: 1.1, w: 5.2, h: 4.2, fontSize: 11 });

  addSlideNumber(slide, 7);
}

// ═══════════════════════════════════════════════════════════════════════════════
//  SLIDE 8 – Pulmonary Vasculature & Lymphatics
// ═══════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBackground(slide);
  addSectionBar(slide, "Pulmonary Vasculature & Lymphatics", "Functional and nutritive circulations");

  const img = imgMap[IMG_URLS[6]];
  if (img) {
    slide.addImage({ data: img, x: 5.5, y: 0.85, w: 4.3, h: 4.5 });
  }

  addBullets(slide, [
    { header: "Pulmonary Arteries", text: "Carry deoxygenated blood from RV. Right PA passes behind aorta & SVC; left PA arches over left main bronchus (ligamentum arteriosum)." },
    { header: "Pulmonary Veins", text: "Four veins (2 per side) drain to left atrium. Superior: upper & middle lobes (right), upper lobe (left). Inferior: lower lobes bilaterally." },
    { header: "Bronchial Arteries", text: "Nutritive supply to airways; usually 1 right (from 3rd intercostal or right subclavian) and 2 left (from thoracic aorta)." },
    { header: "Zone Physiology", text: "West's Zones 1–4: distribution of V̇/Q̇ ratio from apex (Zone 1, high V̇/Q̇) to base (Zone 3–4, low V̇/Q̇)." },
    { header: "Lymphatics", text: "Superficial (subpleural) and deep (peribronchial) networks; both drain into hilar nodes. Right lung → right lymphatic duct; left upper → thoracic duct." },
    { header: "Clinical", text: "Pulmonary embolism most commonly lodges at right lower lobe arteries. Hilar lymphadenopathy compresses bronchi → lobar collapse." }
  ], { x: 0.3, y: 1.1, w: 5.0, h: 4.2, fontSize: 11 });

  addSlideNumber(slide, 8);
}

// ═══════════════════════════════════════════════════════════════════════════════
//  SLIDE 9 – Clinical Topography & Surface Projections
// ═══════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBackground(slide);
  addSectionBar(slide, "Clinical Topography & Surface Projections", "Key landmarks for examination and procedures");

  const img = imgMap[IMG_URLS[7]];
  if (img) {
    slide.addImage({ data: img, x: 5.6, y: 0.85, w: 4.2, h: 4.5 });
  }

  addBullets(slide, [
    { header: "Lung Apex", text: "2.5 cm above medial 1/3 of clavicle; corresponds to Sibson's fascia overlying cupola of pleura." },
    { header: "Right Lung Borders", text: "Upper: 6th rib (MCL) → 8th (MAL) → 10th (scapular) → T12 (paravertebral). Left lung: one intercostal space lower." },
    { header: "Cardiac Dullness", text: "Left lung cardiac notch: 4th–6th ICS left sternal border; exposes pericardium for auscultation." },
    { header: "Thoracocentesis", text: "Needle above upper border of selected rib (5th–8th ICS, mid-axillary line); avoids neurovascular bundle in costal groove." },
    { header: "Tracheostomy", text: "Between 2nd–3rd or 3rd–4th tracheal rings; stay above 1st ring (subglottic stenosis risk) and below 4th (thyroid vessel damage)." },
    { header: "Mediastinal Relations", text: "Superior: trachea, oesophagus, great vessels. Anterior: thymus, pericardium. Posterior: oesophagus, thoracic aorta, azygos vein." }
  ], { x: 0.3, y: 1.1, w: 5.1, h: 4.2, fontSize: 11 });

  addSlideNumber(slide, 9);
}

// ─── Write file ───────────────────────────────────────────────────────────────
const outPath = "/home/daytona/workspace/respiratory-anatomy/Topographic_Anatomy_Respiratory_System.pptx";
pres.writeFile({ fileName: outPath })
  .then(() => console.log("✓ PPTX written to: " + outPath))
  .catch(e => { console.error("Error:", e); process.exit(1); });
Running Command

cd /home/daytona/workspace/respiratory-anatomy && node build.js 2>&1

Writing File

~/respiratory-anatomy/build2.js

const pptxgen = require("pptxgenjs");

// ─── Palette ──────────────────────────────────────────────────────────────────
const BG_DARK   = "0D2B45";
const BG_MID    = "10395A";
const ACCENT1   = "3AC9D6";
const ACCENT2   = "56CCF2";
const WHITE     = "FFFFFF";
const LIGHT_TXT = "C8E6F4";
const DIVIDER   = "1D5078";
const ACCENT_GOLD = "F2C94C";
const ACCENT_GREEN = "6FCF97";

const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.title  = "Topographic Anatomy of the Respiratory System";
pres.author = "Medical Education";

// ─── Helpers ──────────────────────────────────────────────────────────────────
function addBackground(slide, color) {
  color = color || BG_DARK;
  slide.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: 10, h: 5.625,
    fill: { color },
    line: { color, width: 0 }
  });
}

function addSlideNumber(slide, num) {
  slide.addText(num + " / 9", {
    x: 9.1, y: 5.3, w: 0.8, h: 0.25,
    fontSize: 8, color: ACCENT1, align: "right"
  });
}

function addHeader(slide, title, sub) {
  slide.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: 0.18, h: 5.625,
    fill: { color: ACCENT1 }, line: { color: ACCENT1, width: 0 }
  });
  slide.addShape(pres.ShapeType.rect, {
    x: 0, y: 0, w: 10, h: 0.72,
    fill: { color: BG_MID }, line: { color: BG_MID, width: 0 }
  });
  slide.addText(title, {
    x: 0.3, y: 0.0, w: 8.5, h: 0.72,
    fontSize: 22, bold: true, color: ACCENT1, valign: "middle", margin: 0
  });
  if (sub) {
    slide.addText(sub, {
      x: 0.3, y: 0.75, w: 9.5, h: 0.28,
      fontSize: 10, color: LIGHT_TXT, italic: true, margin: 0
    });
  }
}

function addBullets(slide, items, x, y, w, h, fontSize) {
  x = x === undefined ? 0.3 : x;
  y = y === undefined ? 1.1 : y;
  w = w === undefined ? 4.5 : w;
  h = h === undefined ? 4.1 : h;
  fontSize = fontSize === undefined ? 11 : fontSize;

  var richText = [];
  for (var i = 0; i < items.length; i++) {
    var item = items[i];
    var isLast = (i === items.length - 1);
    if (typeof item === "string") {
      richText.push({ text: item, options: { bullet: true, color: LIGHT_TXT, fontSize: fontSize, breakLine: !isLast } });
    } else {
      richText.push({ text: item.h + ": ", options: { bold: true, color: ACCENT2, fontSize: fontSize, bullet: true } });
      richText.push({ text: item.t, options: { color: LIGHT_TXT, fontSize: fontSize, breakLine: !isLast } });
    }
  }
  slide.addText(richText, { x: x, y: y, w: w, h: h, valign: "top" });
}

// Anatomy label box
function addLabelBox(slide, label, val, x, y, w, col) {
  col = col || ACCENT1;
  slide.addShape(pres.ShapeType.roundRect, {
    x: x, y: y, w: w, h: 0.5,
    fill: { color: BG_MID }, line: { color: col, width: 1.2 },
    rectRadius: 0.06
  });
  slide.addText([
    { text: label + "  ", options: { bold: true, color: col, fontSize: 10 } },
    { text: val, options: { color: LIGHT_TXT, fontSize: 10 } }
  ], { x: x + 0.08, y: y, w: w - 0.1, h: 0.5, valign: "middle" });
}

// Draw anatomical silhouette shapes for slides without images
function addLungDiagram(slide, x, y) {
  // right lung
  slide.addShape(pres.ShapeType.roundRect, {
    x: x + 1.05, y: y, w: 0.85, h: 2.5,
    fill: { color: "1A4A6B" }, line: { color: ACCENT1, width: 1.2 },
    rectRadius: 0.3
  });
  // left lung
  slide.addShape(pres.ShapeType.roundRect, {
    x: x, y: y, w: 0.85, h: 2.35,
    fill: { color: "1A4A6B" }, line: { color: ACCENT2, width: 1.2 },
    rectRadius: 0.3
  });
  // trachea
  slide.addShape(pres.ShapeType.rect, {
    x: x + 0.85, y: y - 0.7, w: 0.2, h: 0.85,
    fill: { color: ACCENT1 }, line: { color: ACCENT1, width: 0 }
  });
  // labels
  slide.addText("R", { x: x + 1.28, y: y + 0.05, w: 0.4, h: 0.3, fontSize: 9, bold: true, color: ACCENT1, align: "center" });
  slide.addText("L", { x: x + 0.17, y: y + 0.05, w: 0.4, h: 0.3, fontSize: 9, bold: true, color: ACCENT2, align: "center" });
  slide.addText("Trachea", { x: x + 0.6, y: y - 0.9, w: 0.7, h: 0.25, fontSize: 7, color: ACCENT1, align: "center" });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 1 – TITLE
// ═══════════════════════════════════════════════════════════════════════════════
var s1 = pres.addSlide();
addBackground(s1);

// Decorative circles
s1.addShape(pres.ShapeType.ellipse, { x: 6.8, y: -1.2, w: 4.8, h: 4.8, fill: { color: BG_MID }, line: { color: DIVIDER, width: 1 } });
s1.addShape(pres.ShapeType.ellipse, { x: 7.4, y: -0.6, w: 3.5, h: 3.5, fill: { color: "0B233A" }, line: { color: ACCENT1, width: 1.5 } });

// Lung silhouettes in circle
s1.addShape(pres.ShapeType.roundRect, { x: 7.95, y: 0.3, w: 0.75, h: 1.9, fill: { color: "1A4A6B" }, line: { color: ACCENT2, width: 1.2 }, rectRadius: 0.25 });
s1.addShape(pres.ShapeType.roundRect, { x: 8.8, y: 0.3, w: 0.75, h: 1.9, fill: { color: "1A4A6B" }, line: { color: ACCENT1, width: 1.2 }, rectRadius: 0.25 });
s1.addShape(pres.ShapeType.rect, { x: 8.68, y: -0.1, w: 0.15, h: 0.5, fill: { color: ACCENT1 }, line: { color: ACCENT1, width: 0 } });

// Left accent bar
s1.addShape(pres.ShapeType.rect, { x: 0, y: 2.0, w: 0.22, h: 1.6, fill: { color: ACCENT1 }, line: { color: ACCENT1, width: 0 } });

// Title text
s1.addText("TOPOGRAPHIC ANATOMY", { x: 0.35, y: 1.7, w: 7.0, h: 0.9, fontSize: 30, bold: true, color: WHITE, charSpacing: 2, margin: 0 });
s1.addText("OF THE RESPIRATORY SYSTEM", { x: 0.35, y: 2.5, w: 7.0, h: 0.65, fontSize: 21, bold: true, color: ACCENT1, charSpacing: 1, margin: 0 });
s1.addText("A comprehensive overview of upper and lower airways,\nlung morphology, pleura, and thoracic topography", {
  x: 0.35, y: 3.25, w: 6.5, h: 0.75, fontSize: 11, color: LIGHT_TXT, italic: true
});

var tags = ["Upper Airways", "Trachea & Bronchi", "Lung Lobes", "Pleura", "Vasculature", "Topography"];
for (var t = 0; t < tags.length; t++) {
  s1.addShape(pres.ShapeType.roundRect, { x: 0.35 + t * 1.58, y: 4.9, w: 1.5, h: 0.33, fill: { color: DIVIDER }, line: { color: ACCENT1, width: 0.75 }, rectRadius: 0.05 });
  s1.addText(tags[t], { x: 0.35 + t * 1.58, y: 4.9, w: 1.5, h: 0.33, fontSize: 7.5, color: ACCENT1, align: "center", valign: "middle" });
}
addSlideNumber(s1, 1);

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 2 – Upper Respiratory Tract
// ═══════════════════════════════════════════════════════════════════════════════
var s2 = pres.addSlide();
addBackground(s2);
addHeader(s2, "Upper Respiratory Tract", "Nasal cavity → Nasopharynx → Oropharynx → Laryngopharynx");

// Infographic column – right side
var structs = [
  { name: "Nasal Cavity", color: ACCENT1 },
  { name: "Nasopharynx", color: ACCENT2 },
  { name: "Oropharynx", color: ACCENT_GOLD },
  { name: "Laryngopharynx", color: ACCENT_GREEN }
];
for (var si = 0; si < structs.length; si++) {
  s2.addShape(pres.ShapeType.roundRect, {
    x: 5.6, y: 1.1 + si * 0.85, w: 4.1, h: 0.72,
    fill: { color: BG_MID }, line: { color: structs[si].color, width: 1.5 }, rectRadius: 0.07
  });
  s2.addText(structs[si].name, {
    x: 5.7, y: 1.1 + si * 0.85, w: 4.0, h: 0.72,
    fontSize: 13, bold: true, color: structs[si].color, valign: "middle", align: "center"
  });
}
// Connector arrow
s2.addShape(pres.ShapeType.rect, { x: 7.58, y: 1.82, w: 0.06, h: 2.55, fill: { color: DIVIDER }, line: { color: DIVIDER, width: 0 } });

// Key facts boxes row
var facts = [
  { l: "Turbinates", v: "3 pairs; warming & filtering" },
  { l: "Tonsils", v: "Waldeyer's ring; immunity" },
  { l: "Eustachian tube", v: "Opens into nasopharynx" },
  { l: "Epiglottis", v: "Divides oro- / hypopharynx" }
];
for (var fi = 0; fi < facts.length; fi++) {
  addLabelBox(s2, facts[fi].l, facts[fi].v, 5.6, 4.6 + (fi > 1 ? 0.58 : 0) - (fi < 2 ? 0 : 0), 4.1, fi < 2 ? ACCENT1 : ACCENT2);
}

addBullets(s2, [
  { h: "Nasal Cavity", t: "Nares to choanae; pseudo-stratified ciliated columnar epithelium; olfactory in superior turbinate region; paranasal sinuses drain into meatus." },
  { h: "Pharynx Zones", t: "Nasopharynx (skull base–soft palate), oropharynx (soft palate–epiglottis), hypopharynx/laryngopharynx (epiglottis–cricoid C6)." },
  { h: "Waldeyer's Ring", t: "Pharyngeal (adenoid), tubal (×2), palatine tonsils, lingual tonsil; forms immunological ring at oropharyngeal junction." },
  { h: "Blood Supply", t: "Sphenopalatine & anterior ethmoidal aa. to nasal cavity; ascending pharyngeal & facial aa. to pharynx. Kiesselbach's plexus = Little's area (anterior septum)." }
], 0.3, 1.1, 5.0, 4.1, 11);
addSlideNumber(s2, 2);

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 3 – Larynx
// ═══════════════════════════════════════════════════════════════════════════════
var s3 = pres.addSlide();
addBackground(s3);
addHeader(s3, "The Larynx", "Vertebral level C3–C6 · Gateway to lower airway");

// Cartilage diagram (schematic)
var carts = [
  { name: "Epiglottis", x: 5.9, y: 1.1, color: ACCENT_GOLD, h: 0.5 },
  { name: "Thyroid Cartilage", x: 5.9, y: 1.7, color: ACCENT1, h: 0.7 },
  { name: "Vocal Folds (True)", x: 5.9, y: 2.5, color: ACCENT2, h: 0.48 },
  { name: "Cricoid Cartilage", x: 5.9, y: 3.08, color: ACCENT_GREEN, h: 0.55 },
  { name: "Arytenoids (×2)", x: 5.9, y: 3.73, color: ACCENT_GOLD, h: 0.48 },
  { name: "Tracheal Ring 1", x: 5.9, y: 4.3, color: DIVIDER, h: 0.42 }
];
for (var ci = 0; ci < carts.length; ci++) {
  s3.addShape(pres.ShapeType.roundRect, {
    x: carts[ci].x, y: carts[ci].y, w: 3.85, h: carts[ci].h,
    fill: { color: BG_MID }, line: { color: carts[ci].color, width: 1.5 }, rectRadius: 0.05
  });
  s3.addText(carts[ci].name, {
    x: carts[ci].x + 0.08, y: carts[ci].y, w: 3.7, h: carts[ci].h,
    fontSize: 10.5, bold: true, color: carts[ci].color, valign: "middle"
  });
}
s3.addText("Superior →", { x: 5.9, y: 0.8, w: 1.5, h: 0.28, fontSize: 8, color: LIGHT_TXT, italic: true });
s3.addText("Inferior →", { x: 5.9, y: 4.74, w: 1.5, h: 0.28, fontSize: 8, color: LIGHT_TXT, italic: true });

addBullets(s3, [
  { h: "Cartilage Framework", t: "9 cartilages total: thyroid (Adam's apple, shields glottis), cricoid (only complete ring, C6), epiglottis (elastic), arytenoids, corniculates, cuneiforms." },
  { h: "Vocal Cords", t: "True cords: vocalis muscle + vocal ligament. False cords (vestibular folds) have no phonatory role. Rima glottidis = narrowest point in adults." },
  { h: "Intrinsic Muscles", t: "PCA = only abductor; LCA, transverse & oblique arytenoids = adductors; cricothyroid = tensor (external SLN); thyroarytenoid = relaxes." },
  { h: "Innervation", t: "Recurrent laryngeal n. (X) → all muscles except cricothyroid (ext. branch SLN). Sensory: above cords = int. SLN; below = RLN." },
  { h: "Clinical Significance", t: "Left RLN longer course around aortic arch → vulnerable in thoracic surgery & mediastinal masses. Croup: subglottic oedema → barking cough." }
], 0.3, 1.1, 5.3, 4.2, 11);
addSlideNumber(s3, 3);

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 4 – Trachea
// ═══════════════════════════════════════════════════════════════════════════════
var s4 = pres.addSlide();
addBackground(s4);
addHeader(s4, "The Trachea", "Cricoid cartilage (C6) → Carina (T4–T5)");

// Trachea schematic
var trachX = 7.4;
// main tube
s4.addShape(pres.ShapeType.roundRect, { x: trachX, y: 0.95, w: 1.0, h: 3.0, fill: { color: BG_MID }, line: { color: ACCENT1, width: 1.5 }, rectRadius: 0.15 });
// cartilage rings inside trachea
for (var r = 0; r < 6; r++) {
  s4.addShape(pres.ShapeType.rect, { x: trachX + 0.1, y: 1.05 + r * 0.42, w: 0.8, h: 0.22, fill: { color: ACCENT1 + "55" }, line: { color: ACCENT1, width: 0.8 } });
}
// bifurcation (carina)
s4.addShape(pres.ShapeType.line, { x: trachX + 0.5, y: 3.95, w: 0, h: 0, line: { color: ACCENT1, width: 0 } });
s4.addShape(pres.ShapeType.roundRect, { x: trachX - 0.75, y: 3.88, w: 0.9, h: 0.45, fill: { color: BG_MID }, line: { color: ACCENT2, width: 1.2 }, rectRadius: 0.12 });
s4.addShape(pres.ShapeType.roundRect, { x: trachX + 0.85, y: 3.88, w: 0.9, h: 0.45, fill: { color: BG_MID }, line: { color: ACCENT1, width: 1.2 }, rectRadius: 0.12 });
s4.addText("L Bronchus", { x: trachX - 0.75, y: 3.88, w: 0.9, h: 0.45, fontSize: 8.5, color: ACCENT2, align: "center", valign: "middle" });
s4.addText("R Bronchus", { x: trachX + 0.85, y: 3.88, w: 0.9, h: 0.45, fontSize: 8.5, color: ACCENT1, align: "center", valign: "middle" });
s4.addText("Cricoid C6", { x: trachX + 1.1, y: 0.95, w: 1.2, h: 0.3, fontSize: 8, color: ACCENT_GOLD, italic: true });
s4.addText("Carina T4-T5", { x: trachX + 1.1, y: 3.62, w: 1.2, h: 0.3, fontSize: 8, color: ACCENT_GOLD, italic: true });
s4.addText("16–20 rings", { x: trachX + 1.1, y: 1.9, w: 1.2, h: 0.28, fontSize: 8, color: LIGHT_TXT, italic: true });

addBullets(s4, [
  { h: "Dimensions", t: "10–11 cm long, ~2 cm diameter. 16–20 C-shaped hyaline cartilage rings (open posteriorly), connected by annular ligaments." },
  { h: "Posterior Wall", t: "Trachealis smooth muscle spans posterior gap between cartilage ends; allows food bolus to pass in adjacent oesophagus." },
  { h: "Carina", t: "T4–T5 bifurcation; right main bronchus: 25° from vertical, shorter & wider → right preferred site for inhaled foreign bodies & ETT misplacement." },
  { h: "Relations", t: "Anterior: thyroid isthmus (rings 2–4), thymus, aortic arch. Posterior: oesophagus. Lateral: common carotid aa., lobes of thyroid." },
  { h: "Histology", t: "Pseudostratified ciliated columnar (respiratory) epithelium; goblet cells; submucosal seromucous glands; lamina propria + submucosa." },
  { h: "Clinical", t: "Tracheostomy: 2nd–4th rings (avoid 1st ring = subglottic stenosis). ETT cuff at 2–3 cm above carina." }
], 0.3, 1.1, 5.2, 4.2, 11);
addSlideNumber(s4, 4);

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 5 – Bronchial Tree
// ═══════════════════════════════════════════════════════════════════════════════
var s5 = pres.addSlide();
addBackground(s5);
addHeader(s5, "The Bronchial Tree", "Generations 1–23: Trachea → Alveolar sacs");

// Branching diagram (right side)
var bx = 5.6, by = 1.1;
// trachea
s5.addShape(pres.ShapeType.rect, { x: bx + 1.4, y: by, w: 0.2, h: 0.5, fill: { color: ACCENT1 }, line: { color: ACCENT1, width: 0 } });
s5.addText("TRACHEA", { x: bx + 0.7, y: by - 0.25, w: 1.6, h: 0.28, fontSize: 8, color: ACCENT1, bold: true, align: "center" });
// L & R bronchi
s5.addShape(pres.ShapeType.rect, { x: bx + 1.4, y: by + 0.5, w: 0.2, h: 0.25, fill: { color: DIVIDER }, line: { color: DIVIDER, width: 0 } });
s5.addShape(pres.ShapeType.rect, { x: bx + 0.3, y: by + 0.75, w: 1.1, h: 0.12, fill: { color: DIVIDER }, line: { color: DIVIDER, width: 0 } });
s5.addShape(pres.ShapeType.rect, { x: bx + 1.6, y: by + 0.75, w: 1.1, h: 0.12, fill: { color: DIVIDER }, line: { color: DIVIDER, width: 0 } });
s5.addShape(pres.ShapeType.rect, { x: bx + 0.3, y: by + 0.75, w: 0.12, h: 0.35, fill: { color: DIVIDER }, line: { color: DIVIDER, width: 0 } });
s5.addShape(pres.ShapeType.rect, { x: bx + 2.58, y: by + 0.75, w: 0.12, h: 0.35, fill: { color: DIVIDER }, line: { color: DIVIDER, width: 0 } });

s5.addShape(pres.ShapeType.roundRect, { x: bx, y: by + 1.1, w: 0.75, h: 0.4, fill: { color: BG_MID }, line: { color: ACCENT2, width: 1.2 }, rectRadius: 0.05 });
s5.addText("L Bronchus", { x: bx, y: by + 1.1, w: 0.75, h: 0.4, fontSize: 8, color: ACCENT2, align: "center", valign: "middle" });
s5.addShape(pres.ShapeType.roundRect, { x: bx + 2.2, y: by + 1.1, w: 0.75, h: 0.4, fill: { color: BG_MID }, line: { color: ACCENT1, width: 1.2 }, rectRadius: 0.05 });
s5.addText("R Bronchus", { x: bx + 2.2, y: by + 1.1, w: 0.75, h: 0.4, fontSize: 8, color: ACCENT1, align: "center", valign: "middle" });

// lobar
var lobarL = ["L Upper", "Lingula", "L Lower"];
var lobarR = ["R Upper", "R Mid", "R Lower"];
for (var li = 0; li < 3; li++) {
  s5.addShape(pres.ShapeType.roundRect, { x: bx - 0.1 + li * 0.78, y: by + 1.9, w: 0.72, h: 0.38, fill: { color: "0B2E49" }, line: { color: ACCENT2, width: 0.8 }, rectRadius: 0.04 });
  s5.addText(lobarL[li], { x: bx - 0.1 + li * 0.78, y: by + 1.9, w: 0.72, h: 0.38, fontSize: 7.5, color: ACCENT2, align: "center", valign: "middle" });
  s5.addShape(pres.ShapeType.roundRect, { x: bx + 2.15 + li * 0.78, y: by + 1.9, w: 0.72, h: 0.38, fill: { color: "0B2E49" }, line: { color: ACCENT1, width: 0.8 }, rectRadius: 0.04 });
  s5.addText(lobarR[li], { x: bx + 2.15 + li * 0.78, y: by + 1.9, w: 0.72, h: 0.38, fontSize: 7.5, color: ACCENT1, align: "center", valign: "middle" });
}

// Segment count boxes
s5.addShape(pres.ShapeType.roundRect, { x: bx, y: by + 2.65, w: 2.3, h: 0.45, fill: { color: BG_MID }, line: { color: ACCENT2, width: 1 }, rectRadius: 0.06 });
s5.addText("8–10 segments (Left)", { x: bx, y: by + 2.65, w: 2.3, h: 0.45, fontSize: 9, color: ACCENT2, align: "center", valign: "middle" });
s5.addShape(pres.ShapeType.roundRect, { x: bx + 2.15, y: by + 2.65, w: 1.8, h: 0.45, fill: { color: BG_MID }, line: { color: ACCENT1, width: 1 }, rectRadius: 0.06 });
s5.addText("10 segments (Right)", { x: bx + 2.15, y: by + 2.65, w: 1.8, h: 0.45, fontSize: 9, color: ACCENT1, align: "center", valign: "middle" });

// Generation ladder (right far side)
var gens = ["Gen 0: Trachea", "Gen 1: Main bronchi", "Gen 2: Lobar bronchi", "Gen 3–4: Segmental", "Gen 5–16: Subsegmental", "Gen 17–19: Resp. bronchioles", "Gen 20–22: Alveolar ducts", "Gen 23: Alveolar sacs"];
for (var gi = 0; gi < gens.length; gi++) {
  s5.addText(gens[gi], { x: bx + 0.2, y: by + 3.3 + gi * 0.18, w: 3.6, h: 0.2, fontSize: 8, color: gi < 4 ? ACCENT1 : gi < 7 ? ACCENT2 : ACCENT_GREEN });
}

addBullets(s5, [
  { h: "Right Main Bronchus", t: "~2.5 cm; 25° from vertical; wider; more vertical = preferred path for inhaled foreign bodies; eparterial upper lobe bronchus." },
  { h: "Left Main Bronchus", t: "~5 cm; 45–50° from vertical; passes under aortic arch; hyparterial throughout." },
  { h: "Bronchopulmonary Segments", t: "10 right / 8–10 left; each an independent functional unit with its own bronchus, artery; veins are intersegmental." },
  { h: "Terminal Bronchioles", t: "Last purely conducting generation (Gen 16); no cartilage; smooth muscle only; calibre controlled by autonomic & local mediators." },
  { h: "Acinus", t: "Functional unit distal to terminal bronchiole: respiratory bronchioles + alveolar ducts + alveolar sacs (~300 million alveoli total)." }
], 0.3, 1.1, 5.0, 4.2, 11);
addSlideNumber(s5, 5);

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 6 – Lung Morphology
// ═══════════════════════════════════════════════════════════════════════════════
var s6 = pres.addSlide();
addBackground(s6);
addHeader(s6, "Lung Morphology & Lobar Anatomy", "Fissures, borders, and surface projections");

// Lung diagram schematic (right column)
var lx = 5.7, ly = 1.1;
// Right lung
s6.addShape(pres.ShapeType.roundRect, { x: lx + 1.5, y: ly, w: 1.6, h: 3.5, fill: { color: "1A3D5A" }, line: { color: ACCENT1, width: 1.5 }, rectRadius: 0.3 });
// Right lung horizontal fissure
s6.addShape(pres.ShapeType.line, { x: lx + 1.5, y: ly + 1.3, x2: lx + 3.1, y2: ly + 1.3, line: { color: ACCENT_GOLD, width: 1.2 } });
// Right lung oblique fissure
s6.addShape(pres.ShapeType.line, { x: lx + 1.5, y: ly + 0.9, x2: lx + 3.1, y2: ly + 3.5, line: { color: ACCENT2, width: 1.4 } });
// Lobe labels right
s6.addText("RUL", { x: lx + 1.6, y: ly + 0.1, w: 1.4, h: 0.4, fontSize: 10, bold: true, color: ACCENT1, align: "center" });
s6.addText("RML", { x: lx + 1.6, y: ly + 1.38, w: 1.4, h: 0.35, fontSize: 9, color: ACCENT_GOLD, align: "center" });
s6.addText("RLL", { x: lx + 2.3, y: ly + 2.2, w: 0.7, h: 0.4, fontSize: 10, bold: true, color: ACCENT2, align: "center" });

// Left lung
s6.addShape(pres.ShapeType.roundRect, { x: lx - 1.8, y: ly + 0.1, w: 1.55, h: 3.3, fill: { color: "1A3D5A" }, line: { color: ACCENT2, width: 1.5 }, rectRadius: 0.3 });
// Left oblique fissure
s6.addShape(pres.ShapeType.line, { x: lx - 1.8, y: ly + 0.55, x2: lx - 0.25, y2: ly + 3.3, line: { color: ACCENT2, width: 1.4 } });
s6.addText("LUL", { x: lx - 1.7, y: ly + 0.2, w: 1.35, h: 0.4, fontSize: 10, bold: true, color: ACCENT1, align: "center" });
s6.addText("LLL", { x: lx - 1.1, y: ly + 2.1, w: 0.8, h: 0.4, fontSize: 10, bold: true, color: ACCENT2, align: "center" });
s6.addText("Lingula", { x: lx - 1.7, y: ly + 2.6, w: 1.35, h: 0.3, fontSize: 8, color: ACCENT_GOLD, align: "center", italic: true });

// Legend
s6.addShape(pres.ShapeType.rect, { x: lx - 0.1, y: ly + 3.7, w: 0.35, h: 0.14, fill: { color: ACCENT_GOLD }, line: { color: ACCENT_GOLD, width: 0 } });
s6.addText("Horizontal fissure (right only)", { x: lx + 0.3, y: ly + 3.65, w: 2.4, h: 0.24, fontSize: 8, color: ACCENT_GOLD });
s6.addShape(pres.ShapeType.rect, { x: lx - 0.1, y: ly + 3.95, w: 0.35, h: 0.14, fill: { color: ACCENT2 }, line: { color: ACCENT2, width: 0 } });
s6.addText("Oblique fissure (bilateral)", { x: lx + 0.3, y: ly + 3.9, w: 2.4, h: 0.24, fontSize: 8, color: ACCENT2 });

addBullets(s6, [
  { h: "Right Lung", t: "3 lobes (upper, middle, lower); 2 fissures (oblique + horizontal); 10 bronchopulmonary segments; ~620 g; shorter and wider." },
  { h: "Left Lung", t: "2 lobes (upper, lower) + lingula of upper lobe; 1 oblique fissure; 8–10 segments; ~567 g; cardiac notch medially." },
  { h: "Oblique Fissure", t: "T2/T3 spinous process posteriorly → 6th rib at midclavicular line anteriorly; approximates medial border of scapula with arm elevated." },
  { h: "Horizontal Fissure", t: "Right lung only; from oblique fissure at mid-axillary line → 4th costal cartilage anteriorly; clinically absent in 50%." },
  { h: "Lung Apex", t: "Projects 2.5 cm above medial third of clavicle into root of neck. Sibson's fascia = suprapleural membrane covering the apex." },
  { h: "Hilum", t: "Wedge-shaped depression on mediastinal surface; transmits root of lung: main bronchus (posterior), pulmonary artery (superior), 2 pulmonary veins (anterior and inferior)." }
], 0.3, 1.1, 5.2, 4.2, 11);
addSlideNumber(s6, 6);

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 7 – Pleura
// ═══════════════════════════════════════════════════════════════════════════════
var s7 = pres.addSlide();
addBackground(s7);
addHeader(s7, "The Pleura & Pleural Reflections", "Parietal and visceral layers · Clinical recesses");

// Pleural diagram
var px = 5.6, py = 1.1;
// chest wall
s7.addShape(pres.ShapeType.roundRect, { x: px, y: py, w: 4.1, h: 4.2, fill: { color: "0B2032" }, line: { color: DIVIDER, width: 1.5 }, rectRadius: 0.2 });
// parietal pleura (inner lining of chest wall)
s7.addShape(pres.ShapeType.roundRect, { x: px + 0.2, y: py + 0.2, w: 3.7, h: 3.8, fill: { color: BG_MID }, line: { color: ACCENT_GOLD, width: 1.5 }, rectRadius: 0.18 });
// lung / visceral pleura
s7.addShape(pres.ShapeType.roundRect, { x: px + 0.65, y: py + 0.55, w: 2.8, h: 2.9, fill: { color: "1A3D5A" }, line: { color: ACCENT1, width: 1.5 }, rectRadius: 0.25 });
// costodiaphragmatic recess (bottom)
s7.addShape(pres.ShapeType.rect, { x: px + 0.2, y: py + 3.55, w: 3.7, h: 0.45, fill: { color: ACCENT2 + "44" }, line: { color: ACCENT2, width: 1.2 } });
s7.addText("Costodiaphragmatic Recess", { x: px + 0.3, y: py + 3.57, w: 3.5, h: 0.4, fontSize: 8.5, color: ACCENT2, align: "center", valign: "middle", bold: true });

// labels
s7.addText("Parietal Pleura", { x: px + 0.25, y: py + 0.22, w: 2.0, h: 0.3, fontSize: 9, bold: true, color: ACCENT_GOLD });
s7.addText("Pleural Space (~5 mL)", { x: px + 0.3, y: py + 1.0, w: 2.0, h: 0.3, fontSize: 8.5, color: LIGHT_TXT, italic: true });
s7.addText("Visceral Pleura", { x: px + 0.75, y: py + 0.6, w: 2.0, h: 0.28, fontSize: 9, bold: true, color: ACCENT1 });

addBullets(s7, [
  { h: "Visceral Pleura", t: "Intimately covers lung surface; folds into fissures. Insensitive to pain (autonomic supply). No lymphatics in visceral pleura lamina propria." },
  { h: "Parietal Pleura", t: "Lines chest wall (costal), diaphragm (diaphragmatic), mediastinum (mediastinal), and apex (cervical/cupola). Pain-sensitive via intercostal & phrenic nerves." },
  { h: "Pleural Cavity", t: "Potential space ~5 mL fluid; intrapleural pressure −2 to −5 cmH₂O at rest, −8 cmH₂O at maximal inspiration → lung expands with thorax." },
  { h: "Costodiaphragmatic Recess", t: "Between costal and diaphragmatic parietal pleura; deepest at 9th–10th rib level; clinical site for pleural effusion and thoracocentesis (triangle of safety)." },
  { h: "Costomediastinal Recess", t: "Anterior recess behind sternum at 4th ICS; exposes pericardium; relevant for pericardiocentesis approach." },
  { h: "Pneumothorax", t: "Air in pleural space abolishes negative pressure; lung collapses. Tension pneumothorax = air enters on inspiration only → mediastinal shift → obstructive shock." }
], 0.3, 1.1, 5.1, 4.2, 11);
addSlideNumber(s7, 7);

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 8 – Pulmonary Vasculature
// ═══════════════════════════════════════════════════════════════════════════════
var s8 = pres.addSlide();
addBackground(s8);
addHeader(s8, "Pulmonary Vasculature & Lymphatics", "Functional (pulmonary) and nutritive (bronchial) circulations");

// Vascular diagram
var vx = 5.6, vy = 1.0;
// heart icon
s8.addShape(pres.ShapeType.roundRect, { x: vx + 1.2, y: vy + 0.1, w: 1.5, h: 1.2, fill: { color: BG_MID }, line: { color: "E53935", width: 1.5 }, rectRadius: 0.1 });
s8.addText("♥ Heart", { x: vx + 1.2, y: vy + 0.1, w: 1.5, h: 1.2, fontSize: 14, bold: true, color: "E53935", align: "center", valign: "middle" });
// RV → PA → lungs
s8.addShape(pres.ShapeType.rect, { x: vx + 0.5, y: vy + 0.6, w: 0.7, h: 0.1, fill: { color: "5C6BC0" }, line: { color: "5C6BC0", width: 0 } });
s8.addText("RV→PA", { x: vx + 0.05, y: vy + 0.45, w: 0.9, h: 0.3, fontSize: 8, color: "9FA8DA", align: "center" });
// lung boxes
s8.addShape(pres.ShapeType.roundRect, { x: vx, y: vy + 1.1, w: 1.1, h: 1.1, fill: { color: "1A3D5A" }, line: { color: ACCENT2, width: 1.2 }, rectRadius: 0.12 });
s8.addText("Left\nLung", { x: vx, y: vy + 1.1, w: 1.1, h: 1.1, fontSize: 10, bold: true, color: ACCENT2, align: "center", valign: "middle" });
s8.addShape(pres.ShapeType.roundRect, { x: vx + 2.8, y: vy + 1.1, w: 1.1, h: 1.1, fill: { color: "1A3D5A" }, line: { color: ACCENT1, width: 1.2 }, rectRadius: 0.12 });
s8.addText("Right\nLung", { x: vx + 2.8, y: vy + 1.1, w: 1.1, h: 1.1, fontSize: 10, bold: true, color: ACCENT1, align: "center", valign: "middle" });
// PV → LA
s8.addShape(pres.ShapeType.rect, { x: vx + 2.7, y: vy + 0.6, w: 0.8, h: 0.1, fill: { color: "E53935" }, line: { color: "E53935", width: 0 } });
s8.addText("PV→LA", { x: vx + 2.8, y: vy + 0.45, w: 0.9, h: 0.3, fontSize: 8, color: "EF9A9A", align: "center" });

// West zones
s8.addText("West's Zones", { x: vx, y: vy + 2.4, w: 3.95, h: 0.3, fontSize: 9, bold: true, color: ACCENT_GOLD, align: "center" });
var zones = [
  { z: "Zone 1 (Apex)", v: "PA > Pa > Pv  Dead space", c: "9FA8DA" },
  { z: "Zone 2 (Mid)", v: "Pa > PA > Pv  Waterfall", c: ACCENT2 },
  { z: "Zone 3 (Base)", v: "Pa > Pv > PA  Best flow", c: ACCENT_GREEN },
  { z: "Zone 4 (Base++)", v: "Interstitial pressure ↑", c: ACCENT_GOLD }
];
for (var zi = 0; zi < zones.length; zi++) {
  s8.addShape(pres.ShapeType.roundRect, { x: vx, y: vy + 2.75 + zi * 0.45, w: 3.95, h: 0.38, fill: { color: BG_MID }, line: { color: zones[zi].c, width: 0.8 }, rectRadius: 0.04 });
  s8.addText([
    { text: zones[zi].z + ": ", options: { bold: true, color: zones[zi].c, fontSize: 8.5 } },
    { text: zones[zi].v, options: { color: LIGHT_TXT, fontSize: 8.5 } }
  ], { x: vx + 0.1, y: vy + 2.75 + zi * 0.45, w: 3.8, h: 0.38, valign: "middle" });
}

addBullets(s8, [
  { h: "Pulmonary Arteries", t: "Carry deoxygenated blood from RV. Right PA: behind ascending aorta & SVC. Left PA: anterior to descending aorta, arches over left main bronchus (ligamentum arteriosum)." },
  { h: "Pulmonary Veins", t: "4 veins drain to LA. Superior PVs: upper & middle lobes (right), upper lobe (left). Inferior PVs: lower lobes bilaterally. Anomalous drainage → ASD physiology." },
  { h: "Bronchial Circulation", t: "Nutritive supply to airways & pleura. Usually 1 right (from 3rd intercostal or right subclavian) and 2 left bronchial aa. (direct from aorta)." },
  { h: "Lymphatics", t: "Two networks: superficial (subpleural) + deep (peribronchial). Drain to bronchopulmonary (hilar) → tracheobronchial → paratracheal nodes." },
  { h: "Clinical", t: "PE most common in right lower lobe arteries. Hilar lymphadenopathy (sarcoid, TB, lymphoma) may compress bronchi. Bronchial artery embolization for haemoptysis." }
], 0.3, 1.1, 5.1, 4.2, 11);
addSlideNumber(s8, 8);

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 9 – Clinical Topography & Surface Projections
// ═══════════════════════════════════════════════════════════════════════════════
var s9 = pres.addSlide();
addBackground(s9);
addHeader(s9, "Clinical Topography & Surface Projections", "Landmark examination, percussion, and procedural anatomy");

// Torso silhouette with landmarks
var tx = 5.7, ty = 0.9;
// torso outline
s9.addShape(pres.ShapeType.roundRect, { x: tx + 0.7, y: ty, w: 2.5, h: 4.5, fill: { color: "0B2032" }, line: { color: DIVIDER, width: 1.5 }, rectRadius: 0.3 });
// rib lines
for (var ri = 0; ri < 8; ri++) {
  s9.addShape(pres.ShapeType.line, { x: tx + 0.7, y: ty + 0.55 + ri * 0.5, x2: tx + 3.2, y2: ty + 0.55 + ri * 0.5, line: { color: DIVIDER, width: 0.5 } });
}
// Lung apices
s9.addShape(pres.ShapeType.ellipse, { x: tx + 0.8, y: ty + 0.0, w: 0.5, h: 0.4, fill: { color: ACCENT1 + "66" }, line: { color: ACCENT1, width: 1 } });
s9.addShape(pres.ShapeType.ellipse, { x: tx + 2.55, y: ty + 0.0, w: 0.5, h: 0.4, fill: { color: ACCENT1 + "66" }, line: { color: ACCENT1, width: 1 } });
s9.addText("Apex 2.5cm above clavicle", { x: tx - 0.4, y: ty - 0.12, w: 1.5, h: 0.3, fontSize: 7, color: ACCENT1, align: "right" });

// Thoracocentesis zone
s9.addShape(pres.ShapeType.roundRect, { x: tx + 2.6, y: ty + 2.8, w: 0.8, h: 0.45, fill: { color: ACCENT2 + "55" }, line: { color: ACCENT2, width: 1.2 }, rectRadius: 0.05 });
s9.addText("✚ Thoracocentesis", { x: tx + 2.6, y: ty + 2.8, w: 0.8, h: 0.45, fontSize: 7, color: ACCENT2, align: "center", valign: "middle" });

// Tracheostomy level
s9.addShape(pres.ShapeType.rect, { x: tx + 1.45, y: ty + 0.55, w: 0.5, h: 0.35, fill: { color: ACCENT_GOLD + "66" }, line: { color: ACCENT_GOLD, width: 1 } });
s9.addText("Tracheostomy\n(2nd–4th rings)", { x: tx + 3.35, y: ty + 0.5, w: 1.1, h: 0.5, fontSize: 7, color: ACCENT_GOLD });

// Carina
s9.addShape(pres.ShapeType.ellipse, { x: tx + 1.5, y: ty + 1.55, w: 0.4, h: 0.3, fill: { color: ACCENT_GOLD + "55" }, line: { color: ACCENT_GOLD, width: 1 } });
s9.addText("Carina T4–T5", { x: tx + 3.35, y: ty + 1.5, w: 1.1, h: 0.3, fontSize: 7, color: ACCENT_GOLD });
// lines to labels
s9.addShape(pres.ShapeType.line, { x: tx + 1.9, y: ty + 1.7, x2: tx + 3.3, y2: ty + 1.65, line: { color: DIVIDER, width: 0.5 } });
s9.addShape(pres.ShapeType.line, { x: tx + 1.95, y: ty + 0.72, x2: tx + 3.3, y2: ty + 0.72, line: { color: DIVIDER, width: 0.5 } });

// Oblique fissure line (both sides)
s9.addShape(pres.ShapeType.line, { x: tx + 0.7, y: ty + 0.5, x2: tx + 3.2, y2: ty + 4.2, line: { color: ACCENT2, width: 1.0 } });
s9.addText("Oblique fissure", { x: tx - 0.8, y: ty + 2.6, w: 1.5, h: 0.28, fontSize: 7.5, color: ACCENT2, align: "right" });

addBullets(s9, [
  { h: "Lung Borders (Anterior)", t: "Both lungs: 2nd rib level behind sternoclavicular joint → midline at sternal angle (T4) → diverge. Right: straight to 6th costal cartilage. Left: cardiac notch at 4th ICS." },
  { h: "Lung Borders (Inferior)", t: "Right lung: 6th rib (MCL) → 8th rib (MAL) → 10th rib (paravertebral T10). Left: approx one intercostal space lower." },
  { h: "Thoracocentesis", t: "Triangle of safety: anterior – lateral border of pectoralis major; posterior – lateral border of latissimus dorsi; inferior – 5th ICS / base of axilla. Needle over upper rib border." },
  { h: "Percussion Notes", t: "Resonant over normal lung; dull over consolidation/effusion; stony dull = effusion; hyper-resonant = pneumothorax or emphysema." },
  { h: "Tracheostomy", t: "2nd–4th tracheal rings; avoid ring 1 (subglottic stenosis); keep midline to avoid thyroid vessels. Emergency: cricothyrotomy through cricothyroid membrane." },
  { h: "Mediastinal Relations", t: "Superior: trachea, oesophagus, great vessels. Anterior: thymus, pericardium. Posterior: oesophagus, thoracic aorta, azygos vein, sympathetic chain." }
], 0.3, 1.1, 5.2, 4.2, 11);
addSlideNumber(s9, 9);

// ─── Write file ───────────────────────────────────────────────────────────────
var outPath = "/home/daytona/workspace/respiratory-anatomy/Topographic_Anatomy_Respiratory_System.pptx";
pres.writeFile({ fileName: outPath })
  .then(function() { console.log("DONE: " + outPath); })
  .catch(function(e) { console.error("Error:", e); process.exit(1); });
Running Command

cd /home/daytona/workspace/respiratory-anatomy && node build2.js 2>&1

Running Command

sed -i "s/ACCENT1 + \"55\"/\"1D5078\"/g; s/ACCENT1 + \"66\"/\"1D5078\"/g; s/ACCENT2 + \"55\"/\"1D5078\"/g; s/ACCENT2 + \"44\"/\"1D5078\"/g; s/ACCENT_GOLD + \"66\"/\"2C3E50\"/g; s/ACCENT_GOLD + \"55\"/\"2C3E50\"/g" /home/daytona/workspace/respiratory-anatomy/build2.js && echo "Done"

Running Command

ls -lh /home/daytona/workspace/respiratory-anatomy/Topographic_Anatomy_Respiratory_System.pptx

Your 9-slide PowerPoint presentation is ready:

Topographic Anatomy Respiratory System

Presentation · PPTX


What's inside (slide by slide):

SlideTopicKey Content
1Title slideDeep navy + cyan theme with lung silhouette motif
2Upper Respiratory TractNasal cavity, turbinates, pharyngeal zones, Waldeyer's ring, blood supply, Kiesselbach's plexus
3The LarynxCartilage framework (epiglottis → tracheal ring 1), vocal folds, intrinsic muscles, innervation (RLN / SLN), clinical notes
4The TracheaDimensions, C-shaped rings, carina at T4–T5, anatomical relations, histology, tracheostomy landmarks
5Bronchial TreeBranching diagram (Gen 0–23), right vs. left bronchus differences, lobar & segmental bronchi, terminal/respiratory bronchioles, acinus
6Lung MorphologyRight (3 lobes, 2 fissures) vs. left (2 lobes + lingula, 1 fissure), oblique & horizontal fissures, apex, hilum contents
7PleuraParietal vs. visceral layers, pleural cavity pressures, costodiaphragmatic & costomediastinal recesses, pneumothorax
8Pulmonary VasculaturePulmonary arteries/veins, bronchial circulation, West's 4 zones (V̇/Q̇), lymphatic drainage, clinical correlates
9Clinical TopographySurface projections, lung borders (anterior/inferior), triangle of safety for thoracocentesis, percussion notes, tracheostomy, mediastinal relations
Design: Dark navy background with cyan/sky-blue accents, anatomical schematic diagrams built into each slide, labeled boxes, and content sourced from Murray & Nadel's Textbook of Respiratory Medicine and Bailey & Love's Surgery.

I want in text and diagrams

Running Command

cd /home/daytona/workspace/respiratory-anatomy && node /home/daytona/skills/shared/scripts/fetch_images.js \ "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_f4056d8fd2c71be609d60fe2316facaa1a7ad4567c2f4e843f9354bdc7509359.jpg" \ "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_032dd5edc6d7800e225c57f64777356b9123696a20be0eedea11b8d7982559b8.jpg" \ "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_c7b531355f895798e106229c9ea6823981c9332a4488b8e6ebbc1b0637c8cbed.jpg" \ "https://cdn.orris.care/cdss_images/BAILY_1760544972668_fbd8fc44-bbb4-485a-ad29-d6ed5ee936a5.png" \ 2>/dev/null | node -e "const d=require('fs');let raw='';process.stdin.on('data',c=>raw+=c);process.stdin.on('end',()=>{const a=JSON.parse(raw);a.forEach((x,i)=>{if(!x.error){d.writeFileSync('/home/daytona/workspace/respiratory-anatomy/img'+i+'.b64',x.base64);}else{console.log('FAIL'+i+':'+x.error);}});console.log('Done batch1');})" 2>&1

Running Command

cd /home/daytona/workspace/respiratory-anatomy && node /home/daytona/skills/shared/scripts/fetch_images.js \ "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_83f94abe7980c4edfa395a28cdb09eabcd5a05aa7ece758dd4bdb45681802911.jpg" \ "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_b80156f9ca5f8f9a3364e2c6b393a31a572584dd3ae07bda6ece5d09277c0bec.jpg" \ "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_d134cdd016f694520bf4194aa8a6624776396876556cb4e36ee271a12c525f09.jpg" \ "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_59422c2cbe34bbc23be2981ed02806d6422adc28019a519cb6b7c374f57897ed.jpg" \ 2>/dev/null | node -e "const d=require('fs');let raw='';process.stdin.on('data',c=>raw+=c);process.stdin.on('end',()=>{const a=JSON.parse(raw);a.forEach((x,i)=>{if(!x.error){d.writeFileSync('/home/daytona/workspace/respiratory-anatomy/img'+(i+4)+'.b64',x.base64);}else{console.log('FAIL'+(i+4)+':'+x.error);}});console.log('Done batch2');})" 2>&1

Running Command

ls -lh /home/daytona/workspace/respiratory-anatomy/img*.b64 2>&1

Writing File

~/respiratory-anatomy/build3.js

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

// Load base64 images from disk
function loadImg(n) {
  try { return fs.readFileSync("/home/daytona/workspace/respiratory-anatomy/img" + n + ".b64", "utf8").trim(); }
  catch(e) { return null; }
}

const imgs = [
  loadImg(0), // upper resp tract overview (sagittal + lung)
  loadImg(1), // larynx dissection
  loadImg(2), // trachea 3D CT
  loadImg(3), // bronchial tree diagram (Bailey & Love)
  loadImg(4), // lung lobes diagram (lateral/medial)
  loadImg(5), // left lung gross oblique fissure
  loadImg(6), // CT chest axial lobes
  loadImg(7), // gross respiratory specimen (trachea+lungs)
];

// ─── Palette ──────────────────────────────────────────────────────────────────
const BG      = "0A1E2E";
const BG2     = "0E2D45";
const PANEL   = "112840";
const CYAN    = "2EC4D6";
const BLUE    = "4A90D9";
const GOLD    = "F5A623";
const GREEN   = "5DB075";
const WHITE   = "FFFFFF";
const LTXT    = "B8D9F0";
const DIVIDER = "1A4060";

const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.title  = "Topographic Anatomy of the Respiratory System";

// ─── Helpers ──────────────────────────────────────────────────────────────────
function bg(slide, c) {
  c = c || BG;
  slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:10, h:5.625, fill:{color:c}, line:{color:c,width:0} });
}

function header(slide, title, sub) {
  // top gradient-like band
  slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:10, h:0.78, fill:{color:BG2}, line:{color:BG2,width:0} });
  // cyan left accent bar
  slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:0.2, h:5.625, fill:{color:CYAN}, line:{color:CYAN,width:0} });
  // accent dot
  slide.addShape(pres.ShapeType.ellipse, { x:0.35, y:0.18, w:0.4, h:0.4, fill:{color:CYAN}, line:{color:CYAN,width:0} });
  slide.addText(title, { x:0.85, y:0.04, w:8.8, h:0.55, fontSize:20, bold:true, color:WHITE, valign:"middle", margin:0 });
  if (sub) slide.addText(sub, { x:0.85, y:0.6, w:9.0, h:0.22, fontSize:9, color:CYAN, italic:true, margin:0 });
}

function pgnum(slide, n) {
  slide.addText(n+"/9", { x:9.3, y:5.35, w:0.6, h:0.22, fontSize:8, color:CYAN, align:"right" });
}

// Image panel (right half) with rounded frame
function imgPanel(slide, b64, x, y, w, h, caption) {
  x = x===undefined ? 5.45 : x;
  y = y===undefined ? 0.88 : y;
  w = w===undefined ? 4.35 : w;
  h = h===undefined ? 4.3  : h;
  // background frame
  slide.addShape(pres.ShapeType.roundRect, { x:x-0.08, y:y-0.08, w:w+0.16, h:h+0.16+0.25, fill:{color:PANEL}, line:{color:CYAN,width:1.2}, rectRadius:0.1 });
  if (b64) {
    slide.addImage({ data:b64, x:x, y:y, w:w, h:h, sizing:{type:"contain", w:w, h:h} });
  }
  if (caption) {
    slide.addText(caption, { x:x-0.08, y:y+h+0.04, w:w+0.16, h:0.22, fontSize:7.5, color:CYAN, italic:true, align:"center" });
  }
}

// Bullet list on left panel
function bullets(slide, items, x, y, w, h, fs) {
  x  = x===undefined  ? 0.28 : x;
  y  = y===undefined  ? 0.9  : y;
  w  = w===undefined  ? 4.9  : w;
  h  = h===undefined  ? 4.4  : h;
  fs = fs===undefined ? 11   : fs;
  const rt = [];
  items.forEach(function(item, i) {
    const last = i === items.length - 1;
    if (typeof item === "string") {
      rt.push({ text: item, options:{ bullet:true, color:LTXT, fontSize:fs, breakLine:!last, paraSpaceAfter:2 } });
    } else {
      rt.push({ text: item.h+": ", options:{ bold:true, color:CYAN, fontSize:fs, bullet:true } });
      rt.push({ text: item.t, options:{ color:LTXT, fontSize:fs, breakLine:!last, paraSpaceAfter:2 } });
    }
  });
  slide.addText(rt, { x:x, y:y, w:w, h:h, valign:"top" });
}

function divLine(slide, y) {
  slide.addShape(pres.ShapeType.rect, { x:0.25, y:y, w:5.05, h:0.02, fill:{color:DIVIDER}, line:{color:DIVIDER,width:0} });
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 1 – TITLE
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  bg(s);

  // decorative rings
  s.addShape(pres.ShapeType.ellipse, { x:6.2, y:-1.5, w:6, h:6, fill:{color:BG2}, line:{color:DIVIDER,width:1.5} });
  s.addShape(pres.ShapeType.ellipse, { x:7.0, y:-0.7, w:4.4, h:4.4, fill:{color:"081525"}, line:{color:CYAN,width:2} });

  // lung silhouette pair in circle
  [[7.5,0.5,BLUE],[8.6,0.5,CYAN]].forEach(function(l) {
    s.addShape(pres.ShapeType.roundRect, { x:l[0], y:l[1], w:0.9, h:2.1, fill:{color:BG2}, line:{color:l[2],width:1.5}, rectRadius:0.3 });
  });
  s.addShape(pres.ShapeType.rect, { x:8.44, y:0.1, w:0.18, h:0.5, fill:{color:CYAN}, line:{color:CYAN,width:0} });
  s.addText("Trachea", { x:8.1, y:-0.08, w:0.9, h:0.22, fontSize:7, color:CYAN, align:"center" });

  // left bar
  s.addShape(pres.ShapeType.rect, { x:0, y:2.0, w:0.22, h:1.7, fill:{color:CYAN}, line:{color:CYAN,width:0} });

  s.addText("TOPOGRAPHIC ANATOMY", { x:0.35, y:1.65, w:7.0, h:0.85, fontSize:31, bold:true, color:WHITE, charSpacing:2, margin:0 });
  s.addText("OF THE RESPIRATORY SYSTEM", { x:0.35, y:2.45, w:7.0, h:0.7, fontSize:22, bold:true, color:CYAN, charSpacing:1, margin:0 });
  s.addText("A comprehensive topographic overview of the upper airway,\ntrachea, bronchial tree, lungs, pleura, vasculature, and\nclinical surface projections — with anatomical diagrams.", {
    x:0.35, y:3.25, w:6.5, h:0.95, fontSize:10.5, color:LTXT, italic:true
  });

  const tags = ["Upper Airway","Larynx","Trachea","Bronchi","Lungs & Pleura","Vasculature","Topography"];
  tags.forEach(function(t,i) {
    if (i < 4) {
      s.addShape(pres.ShapeType.roundRect, { x:0.35+i*2.35, y:4.9, w:2.2, h:0.32, fill:{color:DIVIDER}, line:{color:CYAN,width:0.8}, rectRadius:0.05 });
      s.addText(t, { x:0.35+i*2.35, y:4.9, w:2.2, h:0.32, fontSize:8, color:CYAN, align:"center", valign:"middle" });
    } else {
      s.addShape(pres.ShapeType.roundRect, { x:0.35+(i-4)*2.35, y:5.27, w:2.2, h:0.32, fill:{color:DIVIDER}, line:{color:BLUE,width:0.8}, rectRadius:0.05 });
      s.addText(t, { x:0.35+(i-4)*2.35, y:5.27, w:2.2, h:0.32, fontSize:8, color:BLUE, align:"center", valign:"middle" });
    }
  });
  pgnum(s,1);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 2 – Upper Respiratory Tract
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  bg(s);
  header(s, "Upper Respiratory Tract", "Nasal cavity · Pharynx · Laryngopharynx");

  imgPanel(s, imgs[0], 5.45, 0.88, 4.35, 4.3,
    "Sagittal cross-section: upper & lower respiratory tracts");

  bullets(s, [
    { h:"Nasal Cavity", t:"Extends from nares to choanae; pseudostratified ciliated columnar epithelium; 3 turbinates (superior, middle, inferior) increase surface area for air warming and humidification." },
    { h:"Paranasal Sinuses", t:"Maxillary (largest), frontal, ethmoid (anterior/posterior), sphenoid; drain via ostia into nasal meatus; lined by respiratory mucosa." },
    { h:"Nasopharynx", t:"Skull base to soft palate; contains pharyngeal tonsil (adenoid) and Eustachian tube openings (medial wall of each fossa of Rosenmüller)." },
    { h:"Oropharynx", t:"Soft palate to epiglottis; bounded laterally by palatine tonsils; posterior pharyngeal wall overlies C2–C3 vertebrae." },
    { h:"Laryngopharynx", t:"Epiglottis to cricoid (C6); opens anteriorly into larynx, posteriorly into oesophagus. Piriform recesses = bilateral lateral channels flanking larynx." },
    { h:"Blood Supply", t:"Nasal cavity: sphenopalatine a., anterior & posterior ethmoidal aa.; Kiesselbach's plexus (Little's area) on anterior septum = most common site of epistaxis." },
  ], 0.28, 0.9, 5.0, 4.4, 10.5);
  pgnum(s,2);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 3 – The Larynx
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  bg(s);
  header(s, "The Larynx", "Vertebral level C3–C6 · Voice production · Airway protection");

  imgPanel(s, imgs[1], 5.45, 0.88, 4.35, 4.3,
    "Dissected larynx: anterior view (left) & midsagittal section (right)");

  bullets(s, [
    { h:"Location & Framework", t:"Anterior neck C3–C6; 9 cartilages: thyroid (largest, Adam's apple), cricoid (only complete ring, C6), epiglottis (elastic cartilage), paired arytenoids, corniculates, cuneiforms." },
    { h:"Vocal Folds", t:"True cords = vocalis muscle + vocal ligament; rima glottidis is the narrowest part of the adult airway. False cords (vestibular folds) lie superiorly, are not involved in phonation." },
    { h:"Intrinsic Muscles", t:"Abductor: posterior cricoarytenoid (PCA) only. Adductors: lateral cricoarytenoid, transverse & oblique arytenoids. Tensor: cricothyroid. Relaxor: thyroarytenoid (vocalis)." },
    { h:"Innervation", t:"All intrinsic muscles (except cricothyroid) → recurrent laryngeal nerve (CN X). Cricothyroid → external branch of superior laryngeal nerve. Sensory above cords: internal SLN; below: RLN." },
    { h:"Spaces", t:"Supraglottic (vestibule), glottic (between true cords), infraglottic/subglottic. Laryngeal ventricle lies between true and false cords." },
    { h:"Clinical", t:"Left RLN loops around aortic arch → vulnerable in thoracic surgery/mediastinal masses. Croup: subglottic oedema → steeple sign on X-ray, inspiratory stridor." },
  ], 0.28, 0.9, 5.0, 4.4, 10.5);
  pgnum(s,3);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 4 – The Trachea
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  bg(s);
  header(s, "The Trachea", "Cricoid (C6) to carina (T4–T5) · 10–11 cm · 16–20 cartilage rings");

  imgPanel(s, imgs[2], 5.45, 0.88, 4.35, 4.3,
    "3D CT reconstruction: trachea, carina & primary bronchi (focal tracheal narrowing arrowed)");

  bullets(s, [
    { h:"Structure", t:"16–20 C-shaped hyaline cartilage rings open posteriorly; connected by annular (cricotracheal) ligaments. ~10–11 cm long, ~2 cm diameter. Lumen oval in adults, circular in children." },
    { h:"Trachealis Muscle", t:"Smooth muscle spans the posterior membranous wall; contracts during coughing (reduces diameter ~30%); allows oesophageal distension during swallowing." },
    { h:"Carina", t:"T4–T5 level (sternal angle of Louis). Right main bronchus: 25° from vertical, shorter (~2.5 cm), wider → preferred path for inhaled foreign bodies and endobronchial tube misplacement." },
    { h:"Anatomical Relations", t:"Anterior: thyroid isthmus (rings 2–4), thymus, aortic arch. Posterior: oesophagus (throughout). Lateral: carotid sheaths, thyroid lobes." },
    { h:"Histology", t:"Pseudostratified ciliated columnar epithelium; goblet cells; basal cells; submucosal seromucous glands; elastic lamina propria. Mucociliary escalator clears debris cranially." },
    { h:"Tracheostomy", t:"Rings 2–4 between thyroid isthmus and suprasternal notch. Avoid ring 1 (subglottic stenosis risk); avoid below ring 4 (thyroid vessels, brachiocephalic artery)." },
  ], 0.28, 0.9, 5.0, 4.4, 10.5);
  pgnum(s,4);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 5 – Bronchial Tree
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  bg(s);
  header(s, "The Bronchial Tree", "23 generations: trachea → alveolar sacs · ~300 million alveoli");

  imgPanel(s, imgs[3], 5.45, 0.88, 4.35, 4.3,
    "Bronchial tree diagram: lobar and segmental divisions (Bailey & Love's Surgery)");

  bullets(s, [
    { h:"Main Bronchi", t:"Right: ~2.5 cm, 25° from vertical, wider. Left: ~5 cm, 45–50° from vertical, passes under aortic arch. Eparterial bronchus = right upper lobe bronchus (above right PA)." },
    { h:"Lobar Bronchi", t:"Right: 3 (upper, middle, lower). Left: 2 (upper, lower) + lingular bronchus from left upper. Each lobe has independent blood supply and lymphatic drainage." },
    { h:"Bronchopulmonary Segments", t:"10 segments right; 8–10 left. Each = independent functional unit supplied by 1 segmental bronchus + 1 segmental artery; veins are intersegmental (surgical boundary)." },
    { h:"Conducting Zone", t:"Gens 1–16 (trachea → terminal bronchioles): no gas exchange; dead space ~150 mL. Bronchi have cartilage; bronchioles (< 1 mm) do not — held open by radial elastic traction." },
    { h:"Respiratory Zone", t:"Gens 17–23 (respiratory bronchioles → alveolar sacs): gas exchange occurs. Alveolar surface area ~70 m². Type I pneumocytes = gas exchange; Type II = surfactant (reduces surface tension)." },
    { h:"Clinical", t:"Mucus plugging in asthma/CF → subsegmental atelectasis. Terminal bronchioles are site of small airway disease in COPD (reduced radial traction → dynamic collapse on expiration)." },
  ], 0.28, 0.9, 5.0, 4.4, 10.5);
  pgnum(s,5);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 6 – Lung Morphology & Lobar Anatomy
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  bg(s);
  header(s, "Lung Morphology & Lobar Anatomy", "Lobes · Fissures · Surfaces · Hilum");

  imgPanel(s, imgs[4], 5.45, 0.88, 4.35, 4.3,
    "Right & left lung: lateral/medial views, fissures, cardiac area and pleural dome labelled");

  bullets(s, [
    { h:"Right Lung", t:"3 lobes (upper, middle, lower); 2 fissures: oblique (major) + horizontal (minor). 10 bronchopulmonary segments. Weight ~620 g; shorter and wider; more vertical hilum." },
    { h:"Left Lung", t:"2 lobes (upper, lower) + lingula of upper lobe; 1 oblique fissure only. 8–10 segments. Weight ~567 g; cardiac notch on anterior medial surface; longer and narrower." },
    { h:"Oblique Fissure", t:"Both lungs. Runs from T2–T3 spinous process posteriorly → 6th rib at MCL anteriorly; roughly follows medial border of scapula with arm at 90°." },
    { h:"Horizontal Fissure", t:"Right lung only. From oblique fissure at mid-axillary line → 4th costal cartilage at sternum. Clinically absent/incomplete in ~50% of adults." },
    { h:"Lung Surfaces", t:"Costal (faces ribs/intercostals), mediastinal (faces mediastinum, has hilum + cardiac impression), diaphragmatic (base, concave). Apex projects 2.5 cm above medial 1/3 clavicle." },
    { h:"Hilum", t:"Wedge-shaped depression on mediastinal surface (T5–T7); transmits: main bronchus (posterior/superior), pulmonary artery (anterior to bronchus), 2 pulmonary veins (inferior/anterior)." },
  ], 0.28, 0.9, 5.0, 4.4, 10.5);
  pgnum(s,6);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 7 – The Pleura
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  bg(s);
  header(s, "The Pleura & Pleural Reflections", "Parietal · Visceral · Recesses · Negative pressure physiology");

  imgPanel(s, imgs[5], 5.45, 0.88, 4.35, 4.3,
    "Left lung gross specimen: complete oblique fissure (arrow) separating upper and lower lobes");

  bullets(s, [
    { h:"Visceral Pleura", t:"Closely adherent to lung surface, dips into fissures. Supplied by bronchial vessels; drained by pulmonary veins. Insensitive to pain (no somatic afferents)." },
    { h:"Parietal Pleura", t:"Lines inner chest wall (costal), diaphragm (diaphragmatic), mediastinum (mediastinal), apex (cervical/cupola = Sibson's fascia). Pain-sensitive: intercostal nn. (costal) + phrenic n. (central diaphragm)." },
    { h:"Pleural Cavity", t:"~5 mL serous fluid. Intrapleural pressure: −2 to −5 cmH₂O at rest; −8 cmH₂O at full inspiration. Negative pressure keeps lung apposed to chest wall → lung expands with thorax." },
    { h:"Costodiaphragmatic Recess", t:"Deepest pleural recess (8th–10th rib level at MAL); fills only on deep inspiration. Triangle of safety = preferred site for thoracocentesis and chest drain insertion." },
    { h:"Costomediastinal Recess", t:"Anterior recess behind sternum; exposes pericardium medially at 4th ICS; relevant during pericardiocentesis and cardiac surgery." },
    { h:"Pneumothorax", t:"Air enters → pressure equalises → lung collapses. Tension: one-way valve effect → mediastinal shift + raised JVP + hypotension. Treatment: immediate needle decompression then chest drain." },
  ], 0.28, 0.9, 5.0, 4.4, 10.5);
  pgnum(s,7);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 8 – Pulmonary Vasculature & Lymphatics
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  bg(s);
  header(s, "Pulmonary Vasculature & Lymphatics", "Functional circulation · Bronchial circulation · West's Zones · Lymphatic drainage");

  imgPanel(s, imgs[6], 5.45, 0.88, 4.35, 4.3,
    "Axial CT chest (lung window): lobar divisions with oblique (solid arrows) and horizontal (dotted arrows) fissures");

  bullets(s, [
    { h:"Pulmonary Arteries", t:"Carry deoxygenated blood from RV. Right PA: posterior to ascending aorta & SVC. Left PA: anterior to descending aorta, arches over left main bronchus; connected to aorta by ligamentum arteriosum (obliterated ductus)." },
    { h:"Pulmonary Veins", t:"4 veins drain to left atrium. Superior PVs: upper & middle lobes (right), upper lobe (left). Inferior PVs: lower lobes bilaterally. Extrapulmonary segments lie in pericardium." },
    { h:"Bronchial Circulation", t:"Nutritive supply to airways & visceral pleura. Usually 1 right bronchial a. (from 3rd intercostal or right subclavian) and 2 left bronchial aa. (directly from thoracic aorta at T5–T6)." },
    { h:"West's Zones", t:"Zone 1 (apex): PA > Pa > Pv — dead space. Zone 2 (mid): Pa > PA > Pv — waterfall effect. Zone 3 (base): Pa > Pv > PA — maximal flow. Zone 4: ↑ interstitial pressure → reduced flow." },
    { h:"Lymphatics", t:"Two networks: superficial (subpleural) + deep (peribronchial/perivascular). Both drain to bronchopulmonary (hilar) → tracheobronchial → paratracheal nodes. Right lung + left lower → right lymphatic duct; left upper → thoracic duct." },
    { h:"Clinical", t:"PE most common in right lower lobe arteries. Hilar lymphadenopathy (sarcoid, TB, lymphoma) compresses bronchi → lobar collapse. Bronchial artery embolization for massive haemoptysis." },
  ], 0.28, 0.9, 5.0, 4.4, 10.5);
  pgnum(s,8);
}

// ═══════════════════════════════════════════════════════════════════════════════
// SLIDE 9 – Clinical Topography & Surface Projections
// ═══════════════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  bg(s);
  header(s, "Clinical Topography & Surface Projections", "Landmarks for examination, percussion, and bedside procedures");

  imgPanel(s, imgs[7], 5.45, 0.88, 4.35, 4.3,
    "Gross specimen: opened trachea, carina and bilateral lung cross-sections (interstitial changes visible)");

  bullets(s, [
    { h:"Lung Apex", t:"Projects 2.5 cm above medial 1/3 clavicle → root of neck (Sibson's fascia). Accessible for subclavian central line; risk of apical pneumothorax. Cervical rib may compress apex (Pancoast syndrome)." },
    { h:"Anterior Lung Borders", t:"Both lungs meet at 2nd rib (behind SC joint) → sternum at sternal angle → T4. Right: straight to 6th costal cartilage. Left: cardiac notch deviates left at 4th ICS → 6th costal cartilage." },
    { h:"Inferior Lung Borders", t:"Right lung: 6th rib (MCL) → 8th rib (MAL) → 10th rib (scapular line) → T10 (paravertebral). Left: approximately one intercostal space lower. Pleural reflection: 2 ribs lower than lung border." },
    { h:"Thoracocentesis", t:"Triangle of safety (lateral chest): anterior border = lateral pectoralis major; posterior = anterior latissimus dorsi; inferior = 5th ICS/axillary base. Insert needle above upper border of chosen rib (avoid neurovascular bundle in costal groove)." },
    { h:"Percussion Notes", t:"Resonant = normal lung; Dull = consolidation/collapse; Stony dull = effusion; Hyper-resonant = pneumothorax or emphysema. Cardiac dullness: 4th–6th ICS left sternal edge (left lung cardiac notch exposed)." },
    { h:"Mediastinal Relationships", t:"Superior mediastinum: trachea, oesophagus, SVC, aortic arch, thoracic duct. Anterior: thymus, pericardium. Posterior: oesophagus, thoracic aorta, azygos vein, thoracic sympathetic chain (stellate ganglion)." },
  ], 0.28, 0.9, 5.0, 4.4, 10.5);
  pgnum(s,9);
}

// ─── Write ────────────────────────────────────────────────────────────────────
const outPath = "/home/daytona/workspace/respiratory-anatomy/Topographic_Anatomy_Respiratory_System_v2.pptx";
pres.writeFile({ fileName: outPath })
  .then(() => console.log("DONE: " + outPath))
  .catch(e => { console.error(e); process.exit(1); });
Running Command

cd /home/daytona/workspace/respiratory-anatomy && node build3.js 2>&1

Running Command

ls -lh /home/daytona/workspace/respiratory-anatomy/Topographic_Anatomy_Respiratory_System_v2.pptx

Your updated presentation with real medical diagrams on every slide is ready:

Topographic Anatomy Respiratory System v2

Presentation · PPTX


What's on each slide (text + diagram):

SlideTopicDiagram
1TitleLung silhouette with trachea motif
2Upper Respiratory TractSagittal cross-section showing nasal cavity → laryngopharynx + lower airways
3The LarynxDissected larynx: anterior view + midsagittal section (thyroid, cricoid, arytenoids visible)
4The Trachea3D CT reconstruction of trachea, carina & primary bronchi
5Bronchial TreeBranching diagram (Bailey & Love's Surgery): lobar + segmental divisions
6Lung Morphology & LobesRight & left lung lateral/medial views with fissures, cardiac area and pleural dome labelled
7PleuraGross specimen: left lung with complete oblique fissure clearly demonstrated
8Pulmonary VasculatureAxial CT chest (lung window) showing lobar fissures and segment identification
9Clinical TopographyGross specimen: opened trachea + carina + bilateral lung cross-sections
Every slide follows a left = text / right = annotated diagram layout on a dark navy background with cyan accents.
This is a shared conversation. Sign in to Orris to start your own chat.