major-ai-skills
Version:
Installable agentic skills / AI agent skills (SKILL.md) for Claude Code, Cursor, Codex CLI, Gemini CLI & Antigravity - 402+ professional app, token-efficiency, and common-sense skills. SEO/GEO ready.
123 lines (93 loc) • 6.79 kB
Markdown
title: "3D Slicer Medical Image Computing AI Skill Guide (Gemini)"
description: "Comprehensive operational skill specification for Google Gemini to visually diagnose, automate, script, and troubleshoot 3D Slicer slice viewports (Red/Green/Yellow), Volume Rendering transfers, Markups fiducials, and Segment Editor tools."
category: "Open Source Medical Image Computing"
tags: ["3d-slicer", "medical-visualization", "slice-viewports", "gemini", "volume-rendering", "segment-editor-ui"]
# 3D Slicer Medical Image Computing AI Skill Guide (Gemini)
## Overview & Engine Architecture
3D Slicer provides an advanced multi-planar medical visualization interface, consisting of synchronized orthogonal 2D slice viewports (**Red/Axial, Green/Coronal, Yellow/Sagittal**), interactive 3D GPU volume rendering, anatomical markup measurement tools, and visual segment editing brushes. Gemini acts as an AI Medical Imaging & Radiography Reviewer, specializing in **multimodal 2D slice alignment review**, **Hounsfield Unit (HU) Window/Level visual calibration**, **3D Volume Rendering scalar transfer curve optimization**, and **anatomical landmark fiducial validation**.
### Visual Analytics & Medical Imaging Stack
```
┌─────────────────────────────────────────────────────────────┐
│ 3D Slicer Visual Operations │
│ │
│ Multi-Planar Reconstruction (MPR) Viewports │
│ ├── Red Slice Viewport (Axial / Transverse Plane) │
│ ├── Green Slice Viewport (Coronal Plane) │
│ └── Yellow Slice Viewport (Sagittal Plane) │
│ │
│ 3D Surface & Volume Presentation │
│ ├── 3D Viewport (GPU Ray Casting Volume Rendering) │
│ ├── Window / Level Presets (Lung, Bone, Brain, Soft Tissue)│
│ ├── Markups Fiducials (Angle, Ruler, Curve, ROI Box) │
│ └── Segment Editor Visual Masks (Layer Overlay Blending) │
└─────────────────────────────────────────────────────────────┘
```
## Operational Capabilities & Agent Directives
1. **Multimodal Slice Viewport Triage**: Evaluate screenshots of Axial, Coronal, and Sagittal slice viewports to detect anatomical plane tilt, motion artifacts, metal streak distortions, and slice spacing gaps.
2. **Window / Level (W/L) Optimization**: Calibrate Window/Level settings for specific tissue visualization (*e.g. Bone: W:2000, L:300; Lung: W:1500, L:-600; Soft Tissue: W:400, L:50*).
3. **Volume Rendering Transfer Function Tuning**: Adjust scalar opacity mapping curves and gradient color ramps to isolate vascular or bony anatomy without soft tissue visual noise.
4. **Segment Editor Visual Mask Validation**: Review segmented anatomical masks for under-segmentation, over-spill into adjacent organs-at-risk (OAR), and boundary smoothness.
## Production Python Automation: Automated Window / Level & Slice Viewport Configurator
Execute this script inside the 3D Slicer Python Console to configure clinical Window/Level presets across all slice viewports:
```python
"""
3D Slicer Automated Window/Level & Viewport Setup
Sets standard clinical Window/Level (Bone/Soft Tissue) and centers viewports.
"""
import slicer
def set_clinical_preset(preset_name: str = "Bone"):
presets = {
"Bone": {"window": 2000, "level": 300},
"SoftTissue": {"window": 400, "level": 50},
"Lung": {"window": 1500, "level": -600},
"Brain": {"window": 80, "level": 40}
}
if preset_name not in presets:
print(f"Unknown preset. Choose from: {list(presets.keys())}")
return
w = presets[preset_name]["window"]
l = presets[preset_name]["level"]
print(f"Applying Clinical Preset '{preset_name}' (Window: {w}, Level: {l})...")
# 1. Update Active Volume Display Node
volume_nodes = slicer.util.getNodesByClass("vtkMRMLScalarVolumeNode")
for vol in volume_nodes:
display_node = vol.GetDisplayNode()
if display_node:
display_node.AutoWindowLevelOff()
display_node.SetWindow(w)
display_node.SetLevel(l)
# 2. Reset 2D Slice Views to Center on Volume
slice_logic = slicer.app.layoutManager().sliceLogics()
for i in range(slice_logic.GetNumberOfItems()):
logic = slice_logic.GetItemAsObject(i)
logic.FitSliceToAll()
print("✅ Clinical viewports aligned and calibrated.")
# Run inside Slicer Python Console:
# set_clinical_preset("Bone")
```
## Technical Troubleshooting Matrix
| Issue & Visual Signature | Root Cause Analysis | Diagnostic & Resolution Pathway |
| :--- | :--- | :--- |
| **CT Volume Displays Completely White / Saturated** | Window/Level set too low or scalar range mapped to negative air densities. | Run `set_clinical_preset("SoftTissue")` or in Volumes module click **Auto W/L**. |
| **3D Viewport Shows No 3D Model After Segmentation** | Closed surface representation not generated or volume rendering visibility is toggled OFF. | In Segmentations module $\rightarrow$ Representations, click **Create** under *Closed surface*, then toggle eye icon. |
| **Slice Views Show Wrong Aspect Ratio / Stretched Image** | Non-isotropic pixel spacing in DICOM header ignored during custom file import. | In Volumes module, check Spacing $(x, y, z)$ values against original DICOM header. |
| **Markups Curve Renders with Jagged Polygon Edges** | Curve interpolation method set to `Linear` instead of `Spline` / `Centripetal Catmull-Rom`. | In Markups module $\rightarrow$ Curve settings, set **Interpolation** to `Spline`. |
## Command Line Syntax & Server Control
```bash
# Launch Slicer directly with 3D Volume Rendering Enabled
Slicer.exe --volume "C:\Data\patient_scan.nrrd"
# Capture High-Resolution Viewport Screenshot via Slicer Python
# slicer.util.saveSceneScreenshot("C:/Data/viewport.png")
```
### Key Configuration Locations
- **Layout Manager Config**: Inside `slicer.app.layoutManager()`
- **Default Viewport Presets**: `Slicer.ini`
## Agent Operational Directive
> **MANDATORY**: Always verify Hounsfield Unit (HU) Window/Level settings before reviewing CT segmentation masks; never assess soft tissue margins using high-contrast Bone window settings.