Make a flow chart of flaps in sigery with examples and used and pedicles of each flaps
ls -la /home/daytona/workspace/ 2>/dev/null || echo "workspace empty or missing"
mkdir -p /home/daytona/workspace/flaps-flowchart && echo "created"
~/flaps-flowchart/flaps_flowchart.py
#!/usr/bin/env python3
"""Generate a comprehensive surgical flaps flowchart using matplotlib."""
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from matplotlib.patches import FancyBboxPatch, FancyArrowPatch
import matplotlib.patheffects as pe
import numpy as np
# ── Colour palette ──────────────────────────────────────────────────────────
BG = "#0D1B2A" # near-black navy background
TITLE_BG = "#1A3A5C" # darker blue for title box
ROOT_BG = "#1E6091" # root node
LVL1_BG = "#2980B9" # level-1 branches
LVL2_BG = "#1ABC9C" # level-2 sub-branches
LVL3_BG = "#16A085" # leaf nodes
LEAF_BG = "#2C3E50" # dark leaf
ACC1 = "#E67E22" # orange accent (blood supply)
ACC2 = "#8E44AD" # purple accent (method of transfer)
ACC3 = "#C0392B" # red accent (composition)
ACC4 = "#27AE60" # green accent (contiguity)
MATHES = "#D35400" # Mathes-Nahai
TEXT_W = "white"
TEXT_D = "#ECF0F1"
ARROW_C = "#95A5A6"
fig_w, fig_h = 34, 46
fig, ax = plt.subplots(figsize=(fig_w, fig_h))
ax.set_xlim(0, fig_w)
ax.set_ylim(0, fig_h)
ax.set_aspect('equal')
ax.axis('off')
fig.patch.set_facecolor(BG)
ax.set_facecolor(BG)
# ── Helper functions ─────────────────────────────────────────────────────────
def box(x, y, w, h, color, text, fontsize=9, textcolor=TEXT_W,
radius=0.35, bold=False, wrap=True, alpha=1.0):
"""Draw a rounded rectangle with centred, wrapped text."""
rect = FancyBboxPatch((x - w/2, y - h/2), w, h,
boxstyle=f"round,pad=0.05,rounding_size={radius}",
facecolor=color, edgecolor="white",
linewidth=0.8, alpha=alpha, zorder=3)
ax.add_patch(rect)
weight = 'bold' if bold else 'normal'
ax.text(x, y, text, ha='center', va='center', fontsize=fontsize,
color=textcolor, fontweight=weight,
wrap=True, multialignment='center',
zorder=4,
bbox=dict(boxstyle='square,pad=0', fc='none', ec='none'))
def arrow(x1, y1, x2, y2, color=ARROW_C, lw=1.4):
"""Draw an arrow from (x1,y1) to (x2,y2)."""
ax.annotate('', xy=(x2, y2), xytext=(x1, y1),
arrowprops=dict(arrowstyle='->', color=color,
lw=lw, connectionstyle='arc3,rad=0.0'),
zorder=2)
def hline(x1, x2, y, color=ARROW_C, lw=1.2):
ax.plot([x1, x2], [y, y], color=color, lw=lw, zorder=2)
def vline(x, y1, y2, color=ARROW_C, lw=1.2):
ax.plot([x, x], [y1, y2], color=color, lw=lw, zorder=2)
# ═══════════════════════════════════════════════════════════════════
# TITLE
# ═══════════════════════════════════════════════════════════════════
box(17, 44.5, 28, 1.6, TITLE_BG,
"CLASSIFICATION OF FLAPS IN SURGERY",
fontsize=20, bold=True)
# ═══════════════════════════════════════════════════════════════════
# ROOT NODE
# ═══════════════════════════════════════════════════════════════════
box(17, 42.8, 10, 1.0, ROOT_BG,
"SURGICAL FLAP\n(Vascularised tissue transfer)",
fontsize=11, bold=True)
arrow(17, 42.3, 17, 41.65)
# ═══════════════════════════════════════════════════════════════════
# 5 MAIN CLASSIFICATION BRANCHES (level-1)
# X positions spread across width
# ═══════════════════════════════════════════════════════════════════
branches = [
(4.0, "1. BLOOD\nSUPPLY", ACC1),
(10.5, "2. COMPOSITION\n(Tissue type)", ACC3),
(17.0, "3. CONTIGUITY\n(Location)", ACC4),
(23.5, "4. METHOD OF\nTRANSFER", ACC2),
(30.0, "5. MUSCLE FLAP\n(Mathes-Nahai)", MATHES),
]
y_branch = 41.0
y_root_bot = 42.3
# horizontal connector line
vline(17, 41.65, y_branch + 0.5)
hline(4.0, 30.0, y_branch + 0.5)
for bx, bt, bc in branches:
vline(bx, y_branch + 0.5, y_branch + 0.5)
box(bx, y_branch, 5.4, 0.9, bc, bt, fontsize=9.5, bold=True)
arrow(bx, y_branch - 0.45, bx, y_branch - 1.0)
# ═══════════════════════════════════════════════════════════════════
# BRANCH 1 – BLOOD SUPPLY (x=4.0)
# ═══════════════════════════════════════════════════════════════════
y = 39.6
# Two sub-nodes
sub1 = [(2.0, "RANDOM PATTERN"), (6.0, "AXIAL PATTERN")]
hline(2.0, 6.0, y - 0.0)
for sx, st in sub1:
vline(sx, y - 0.0, y - 0.35)
box(sx, y - 0.75, 3.6, 0.7, ACC1, st, fontsize=8.5, bold=True)
# Random pattern details
yy = 38.1
box(2.0, yy, 3.6, 0.65, LEAF_BG,
"No named A-V pedicle\nRelies on microcirculation\nLength:width ratio ≤3:1",
fontsize=7.5)
arrow(2.0, y - 1.1, 2.0, yy + 0.33)
box(2.0, yy - 1.1, 3.6, 0.65, LEAF_BG,
"Examples:\nZ-plasty · Rotation flap\nCross-finger flap · Thenar flap",
fontsize=7.5)
arrow(2.0, yy - 0.33, 2.0, yy - 1.1 + 0.33)
# Axial pattern details
box(6.0, yy, 3.6, 0.65, LEAF_BG,
"Named A-V pedicle\nMore reliable blood supply\nCan be free or pedicled",
fontsize=7.5)
arrow(6.0, y - 1.1, 6.0, yy + 0.33)
box(6.0, yy - 1.1, 3.6, 0.65, LEAF_BG,
"Examples:\nRadial forearm (radial a.)\nLatissimus dorsi (thoracodorsal a.)\nALT (desc. lat. fem. circ. a.)",
fontsize=7.2)
arrow(6.0, yy - 0.33, 6.0, yy - 1.1 + 0.33)
# Perforator flap sub-type under axial
box(6.0, yy - 2.4, 3.6, 0.65, "#1F618D",
"PERFORATOR FLAPS\n(subset of axial)\nSkin/fat supplied by\nperforator vessel",
fontsize=7.2)
arrow(6.0, yy - 1.1 - 0.33, 6.0, yy - 2.4 + 0.33)
box(6.0, yy - 3.45, 3.6, 0.65, LEAF_BG,
"Examples:\nDIEP (deep inf. epigastric perforator)\nALT perforator flap\nTRAM (sup. epigastric a.)",
fontsize=7.2)
arrow(6.0, yy - 2.4 - 0.33, 6.0, yy - 3.45 + 0.33)
# ═══════════════════════════════════════════════════════════════════
# BRANCH 2 – COMPOSITION (x=10.5)
# ═══════════════════════════════════════════════════════════════════
comp_items = [
("CUTANEOUS", "Skin + subcutaneous fat\nPedicle: subdermal plexus\nEx: Thenar, cross-finger flap"),
("FASCIOCUTANEOUS", "Fascia + skin\nPedicle: fascial plexus vessels\nEx: Radial forearm, ALT, Lateral arm\nScapular flap"),
("MUSCULOCUTANEOUS", "Muscle + overlying skin\nPedicle: dominant muscle\npedicle (see Mathes-Nahai)\nEx: TRAM, Latissimus dorsi,\nPectoralis major, Gracilis"),
("MUSCLE ONLY", "Bare muscle flap\n(skin graft applied after)\nPedicle: dominant muscle artery\nEx: Gastrocnemius, Soleus,\nSerratus anterior"),
("OSTEOCUTANEOUS", "Bone + soft tissue\nPedicle: periosteal vessels\nEx: Free fibula (peroneal a.)\nIliac crest (deep circ. iliac a.)\nScapula (circumflex scapular a.)"),
("OMENTUM /\nVISCERAL", "Omentum or bowel\nPedicle: gastroepiploic a. (omentum)\nEx: Omental flap, Jejunal flap"),
]
y_top = 39.3
y_step = 1.55
x_comp = 10.5
vline(x_comp, y_branch - 0.45, y_top + 0.33)
for i, (title, detail) in enumerate(comp_items):
yc = y_top - i * y_step
box(x_comp, yc, 5.0, 0.55, ACC3, title, fontsize=8, bold=True)
arrow(x_comp, yc - 0.28, x_comp, yc - 0.6)
box(x_comp, yc - 0.95, 5.0, 0.65, LEAF_BG, detail, fontsize=7)
if i < len(comp_items) - 1:
arrow(x_comp, yc - 1.28, x_comp, y_top - (i+1)*y_step + 0.28)
# Cormack-Lamberty sub-box for fasciocutaneous
cl_y = y_top - 1*y_step - 0.95 - 0.7
box(x_comp, cl_y, 5.0, 0.85,
"#7D3C98",
"Cormack-Lamberty Classification:\nType A: multiple perforators (Pontén flap)\nType B: single perforator (Scapular flap)\nType C: segmental (Radial forearm, Lat. arm)\nType D: osteomyofasciocutaneous (Free fibula)",
fontsize=6.8)
arrow(x_comp, y_top - 1*y_step - 0.95 + 0.33, x_comp, cl_y + 0.43)
# ═══════════════════════════════════════════════════════════════════
# BRANCH 3 – CONTIGUITY (x=17.0)
# ═══════════════════════════════════════════════════════════════════
cont_data = [
("LOCAL FLAP", ACC4,
"Shares border with defect\nNeighbouring tissue\nBest colour/texture match",
"Rotation flap\nAdvancement flap\nTransposition flap\nZ-plasty\nRhomboid (Limberg) flap\nBilobed flap"),
("REGIONAL FLAP", "#1E8449",
"Near but not adjacent to defect\nPedicled transfer",
"Pectoralis major flap\nLatissimus dorsi flap\nGastrocnemius flap (knee)\nSoleus flap (mid-leg)\nDeltopectoral flap"),
("DISTANT FLAP", "#145A32",
"Far from defect\nPedicled or free transfer\nRequires 2-stage or\nmicrovascular anastomosis",
"Groin flap (superficial\ncircumflex iliac a.)\nAbdominal pocket flap\nFree flaps (microvascular)\nCross-leg flap"),
]
y_cont = 39.3
x_cont = 17.0
vline(x_cont, y_branch - 0.45, y_cont + 0.33)
hline(x_cont - 0.5, x_cont + 0.5, y_cont + 0.33)
y_step_c = 2.8
for i, (title, col, props, exs) in enumerate(cont_data):
yc = y_cont - i * y_step_c
box(x_cont, yc, 5.2, 0.6, col, title, fontsize=9, bold=True)
arrow(x_cont, yc - 0.30, x_cont, yc - 0.62)
box(x_cont, yc - 1.0, 5.2, 0.65, LEAF_BG, props, fontsize=7.5)
arrow(x_cont, yc - 1.33, x_cont, yc - 1.65)
box(x_cont, yc - 2.05, 5.2, 0.7, "#1C2833", "Examples:\n" + exs, fontsize=7.2)
if i < len(cont_data) - 1:
arrow(x_cont, yc - 2.4, x_cont, y_cont - (i+1)*y_step_c + 0.30)
# ═══════════════════════════════════════════════════════════════════
# BRANCH 4 – METHOD OF TRANSFER (x=23.5)
# ═══════════════════════════════════════════════════════════════════
transfer_data = [
("ADVANCEMENT", ACC2,
"Moves in a straight line\ninto the defect",
"V-Y flap\nMoberg flap (thumb)\nBipedicle advancement flap"),
("ROTATION", "#6C3483",
"Semicircular flap pivoted\ninto defect\nRandom pattern",
"Scalp rotation flap\nBack-cut rotation flap\nO-to-Z plasty"),
("TRANSPOSITION", "#5B2C6F",
"Lifted over intervening skin\nMay be axial or random",
"Rhomboid (Limberg) flap\nBilobed flap\nBanner flap\nNote flap"),
("INTERPOLATION\n(Staged)", "#4A235A",
"Pedicle crosses/lies over\nnormal skin; divided later",
"Paramedian forehead flap\n(supratrochlear a.)\nAbdominoplasty flap\nCross-leg flap"),
("FREE FLAP\n(Microsurgical)", "#7B241C",
"Pedicle divided; vessels\nreanastomosed at recipient site\nRequires microvascular surgery",
"Radial forearm free flap (radial a.)\nFibula free flap (peroneal a.)\nALT free flap (desc. LFCA)\nDIEP flap (deep inf. epigastric a.)\nGracilis free flap (med. fem. circ. a.)\nJejunum free flap (SMA branch)\nLatissimus dorsi free flap\n(thoracodorsal a.)"),
]
y_trans = 39.3
x_trans = 23.5
vline(x_trans, y_branch - 0.45, y_trans + 0.33)
y_step_t = 2.2
for i, (title, col, props, exs) in enumerate(transfer_data):
yc = y_trans - i * y_step_t
box(x_trans, yc, 5.2, 0.6, col, title, fontsize=8.5, bold=True)
arrow(x_trans, yc - 0.30, x_trans, yc - 0.62)
box(x_trans, yc - 1.05, 5.2, 0.62, LEAF_BG, props, fontsize=7.5)
arrow(x_trans, yc - 1.36, x_trans, yc - 1.62)
box(x_trans, yc - 2.0, 5.2, 0.68, "#1C2833", "Examples:\n" + exs, fontsize=7.0)
if i < len(transfer_data) - 1:
arrow(x_trans, yc - 2.34, x_trans, y_trans - (i+1)*y_step_t + 0.30)
# ═══════════════════════════════════════════════════════════════════
# BRANCH 5 – MATHES-NAHAI (x=30.0)
# ═══════════════════════════════════════════════════════════════════
mathes_data = [
("TYPE I", "1 vascular pedicle",
"Gastrocnemius (sural a.)\nTensor fascia lata\n(lat. fem. circ. a.)"),
("TYPE II", "1 dominant + minor pedicles\n(cannot survive on minor alone)",
"Gracilis (med. fem. circ. a.)\nSoleus (popliteal a.)\nTrapezius (transverse cerv. a.)"),
("TYPE III", "2 dominant pedicles",
"Rectus abdominis\n(sup. + inf. epigastric a.)\nGluteus maximus\nSerratus anterior\nTemporalis"),
("TYPE IV", "Segmental pedicles\n(no dominant; sacrifice = necrosis)",
"Sartorius\nTibialis anterior\nFlexor hallucis longus"),
("TYPE V", "1 dominant + secondary\nsegmental pedicles\n(can survive on secondary alone)",
"Latissimus dorsi (thoracodorsal a.)\nPectoralis major (thoracoacromial a.)"),
]
y_math = 39.3
x_math = 30.0
vline(x_math, y_branch - 0.45, y_math + 0.33)
y_step_m = 2.15
for i, (title, supply, exs) in enumerate(mathes_data):
yc = y_math - i * y_step_m
box(x_math, yc, 5.2, 0.6, MATHES, title, fontsize=9, bold=True)
arrow(x_math, yc - 0.30, x_math, yc - 0.62)
box(x_math, yc - 1.0, 5.2, 0.62, "#784212", supply, fontsize=7.8)
arrow(x_math, yc - 1.31, x_math, yc - 1.6)
box(x_math, yc - 2.0, 5.2, 0.65, "#1C2833", exs, fontsize=7.3)
if i < len(mathes_data) - 1:
arrow(x_math, yc - 2.33, x_math, y_math - (i+1)*y_step_m + 0.30)
# ═══════════════════════════════════════════════════════════════════
# LEGEND
# ═══════════════════════════════════════════════════════════════════
legend_x, legend_y = 1.2, 3.5
box(legend_x + 1.5, legend_y + 0.5, 3.5, 0.5, BG, "LEGEND", fontsize=9, bold=True, textcolor=TEXT_D)
legend_items = [
(ACC1, "Blood Supply classification"),
(ACC3, "Composition / Tissue type"),
(ACC4, "Contiguity / Location"),
(ACC2, "Method of Transfer"),
(MATHES, "Mathes-Nahai (Muscle types)"),
("#7D3C98", "Cormack-Lamberty (Fasciocutaneous)"),
(LEAF_BG, "Properties / Notes"),
("#1C2833", "Clinical Examples"),
]
for j, (col, label) in enumerate(legend_items):
lx = legend_x
ly = legend_y - j * 0.38
rect = FancyBboxPatch((lx, ly - 0.12), 0.5, 0.24,
boxstyle="round,pad=0.02",
facecolor=col, edgecolor='white', lw=0.6, zorder=5)
ax.add_patch(rect)
ax.text(lx + 0.65, ly, label, va='center', fontsize=8,
color=TEXT_D, zorder=6)
# Source citation
ax.text(17, 0.5,
"Sources: Bailey & Love's Surgery 28e · Schwartz's Principles 11e · Miller's Orthopaedics 9e · Sabiston Surgery",
ha='center', va='center', fontsize=7.5, color="#7F8C8D",
style='italic', zorder=6)
plt.tight_layout(pad=0.3)
plt.savefig('/home/daytona/workspace/flaps-flowchart/flaps_flowchart.png',
dpi=150, bbox_inches='tight', facecolor=BG)
print("Saved.")
cd /home/daytona/workspace/flaps-flowchart && python3 flaps_flowchart.py 2>&1
ls -lh /home/daytona/workspace/flaps-flowchart/
flaps flowchart
Image · PNG
| Type | Features | Pedicle | Examples |
|---|---|---|---|
| Random Pattern | No named A-V pedicle; relies on subdermal microcirculation; length:width ratio ≤3:1 | Dermal/subdermal plexus | Z-plasty, rotation flap, cross-finger flap, thenar flap |
| Axial Pattern | Single named arteriovenous pedicle; predictable blood supply; can be free or pedicled | Named artery + paired vein | Radial forearm (radial a.), latissimus dorsi (thoracodorsal a.), ALT (descending lateral femoral circumflex a.) |
| Perforator Flap (subset of axial) | Skin/fat supplied by isolated perforator; spares underlying muscle | Perforator vessel from deep source artery | DIEP (deep inferior epigastric perforator), ALT perforator, TRAM (superior epigastric a.) |
| Type | Components | Pedicle | Examples |
|---|---|---|---|
| Cutaneous | Skin + subcutaneous fat | Subdermal plexus | Thenar flap, cross-finger flap |
| Fasciocutaneous | Fascia + skin (±subcutaneous tissue) | Fascial plexus vessels | Radial forearm, ALT, lateral arm, scapular flap |
| Musculocutaneous | Muscle + overlying skin + fascia | Dominant muscle pedicle | TRAM, latissimus dorsi, pectoralis major, gracilis |
| Muscle only | Bare muscle (skin graft applied after) | Dominant muscle artery | Gastrocnemius, soleus, serratus anterior |
| Osteocutaneous | Bone + overlying soft tissue | Periosteal/nutrient vessels | Free fibula (peroneal a.), iliac crest (deep circ. iliac a.), scapula (circumflex scapular a.) |
| Omentum/Visceral | Omentum or bowel | Gastroepiploic a. / SMA branch | Omental flap, jejunal free flap |
| Type | Definition | Examples |
|---|---|---|
| Local | Shares a border with defect; best colour/texture match | Rotation, advancement, transposition, Z-plasty, rhomboid (Limberg), bilobed |
| Regional | Near but not adjacent to defect; pedicled transfer | Pectoralis major, latissimus dorsi, gastrocnemius (proximal tibia), soleus (mid-leg), deltopectoral |
| Distant | Far from defect; pedicled or free; may need 2 stages | Groin flap (superficial circumflex iliac a.), abdominal pocket flap, cross-leg flap, all free flaps |
| Method | Mechanism | Examples |
|---|---|---|
| Advancement | Slides in straight line into defect | V-Y flap, Moberg flap (thumb tip), bipedicle advancement |
| Rotation | Semicircular flap pivoted into defect; always random | Scalp rotation, back-cut rotation, O-to-Z plasty |
| Transposition | Lifted over intervening skin; axial or random | Rhomboid (Limberg), bilobed, banner, note flap |
| Interpolation (staged) | Pedicle crosses normal skin; divided at 2nd stage | Paramedian forehead flap (supratrochlear a.), abdominal flap |
| Free Flap (microsurgical) | Pedicle divided; vessels reanastomosed at recipient site | Radial forearm (radial a.), fibula (peroneal a.), ALT (desc. LFCA), DIEP, gracilis (medial femoral circumflex a.), jejunum (SMA branch) |
| Type | Vascular Supply | Pedicle | Key Examples |
|---|---|---|---|
| Type I | 1 vascular pedicle | Single dominant | Gastrocnemius (sural a.), tensor fascia lata (lateral femoral circumflex a.) |
| Type II | 1 dominant + minor pedicles (cannot survive on minor alone) | Dominant + minor | Gracilis (medial femoral circumflex a.), soleus (popliteal a.), trapezius (transverse cervical a.) |
| Type III | 2 dominant pedicles | Two dominant | Rectus abdominis (superior + inferior epigastric a.), gluteus maximus, serratus anterior, temporalis |
| Type IV | Segmental pedicles (no dominant; ligation causes necrosis) | Multiple segmental | Sartorius, tibialis anterior, flexor hallucis longus |
| Type V | 1 dominant + secondary segmental pedicles (can survive on secondary alone) | Dominant + secondary segmental | Latissimus dorsi (thoracodorsal a.), pectoralis major (thoracoacromial a.) |