Skip to content

Latest commit

 

History

History
212 lines (153 loc) · 7.12 KB

File metadata and controls

212 lines (153 loc) · 7.12 KB
name dicom-mri
description Analyze medical DICOM imaging data (MRI, CT, X-ray) from any source — a CD/DVD, USB drive, or local directory. Use this skill whenever the user mentions an MRI scan, CT scan, DICOM files, a medical CD, a radiology disc, or wants to understand, view, or report on any medical imaging study. The skill handles the full pipeline: discovering the data, rendering slice images, analyzing findings across all sequences, and generating structured reports in plain or clinical language. Invoke this skill proactively if the user mentions any of: "MRI", "CT scan", "DICOM", "radiology CD", "medical scan", "shoulder MRI", "brain scan", "x-ray disc", "my doctor gave me a CD", "scan results", or similar.

DICOM Medical Imaging Analysis

This skill walks you through a complete, end-to-end analysis of a DICOM medical imaging study — from raw files on a disc or drive, to rendered images, to a written report the patient and their doctor can actually use.

Quick mental model

Think of a DICOM study as a set of series — each series is one imaging sequence (e.g. "T1-weighted axial", "STIR coronal"). Every series contains many slices stored as individual DICOM files. Your job is to:

  1. Find the files
  2. Group them by series
  3. Render the slices as images so you can see them
  4. Analyse what you see
  5. Write up the findings

Step 1 — Find the data

Check common mount points in this order:

ls /run/media/$USER/          # Linux auto-mount (most common for CDs)
ls /media/                    # fallback
ls /Volumes/                  # macOS

If you find a mounted disc/drive, look for a DICOM/ directory inside it. If nothing is mounted, ask the user: "Where are the DICOM files? (e.g., a CD in the drive, a folder on the desktop)"

Once you have the path, count the files:

find <DICOM_PATH> -type f | wc -l

Step 2 — Check and install dependencies

Run the check script first — it will print what's missing:

python3 scripts/check_deps.py

If anything is missing, install via the system package manager. On Omarchy/Arch Linux:

omarchy-pkg-add python-pydicom python-numpy python-matplotlib python-scipy

On Debian/Ubuntu: sudo apt install python3-pydicom python3-numpy python3-matplotlib On macOS: pip3 install pydicom numpy matplotlib


Step 3 — Extract metadata

Run the metadata script to get a clean summary of the study:

python3 scripts/extract_metadata.py <DICOM_PATH>

This will print:

  • Patient name, ID, DOB, sex, weight
  • Study date, description, accession number
  • Institution and scanner info
  • A table of all series (number, description, sequence type, slice count, resolution)

Read this output carefully — it tells you what anatomical region was scanned, what sequences were acquired, and how many slices/images to expect. Use it to understand the clinical context before rendering.


Step 4 — Render all series

Run the render script to produce PNG overview images for every series:

python3 scripts/render_dicom.py <DICOM_PATH> <OUTPUT_DIR>

This creates one s<N>_all.png per series in <OUTPUT_DIR>, showing all slices in a grid. It also creates s<N>_overview.png with 12 representative slices for quick review.

Once rendered, read every overview image using the Read tool so you can visually inspect the anatomy. Render focused close-up panels for areas of clinical interest (rotator cuff, labrum, specific joints, etc.) by re-running the render script with --series <N> --slices <start>-<end>.


Step 5 — Analyse the imaging

Work through each series systematically. For each one, note:

Anatomy present: What body part and structures are visible?

Signal/density: Are there areas of abnormal brightness (fluid, edema, hemorrhage) or darkness (air, calcification, susceptibility)?

Structures to assess by region:

Shoulder: Rotator cuff (supraspinatus, infraspinatus, subscapularis, teres minor), labrum (anterior, posterior, SLAP), biceps tendon and groove, AC joint, glenohumeral cartilage, subacromial-subdeltoid bursa, bone marrow signal, Hill-Sachs/Bankart.

Knee: Menisci (medial, lateral — body, anterior/posterior horns), cruciate ligaments (ACL, PCL), collateral ligaments, cartilage (medial, lateral, patellofemoral), bone marrow edema, effusion, Baker's cyst.

Spine: Disc height and signal, end-plate changes, foraminal stenosis, cord signal, facet joints, paraspinal muscles.

Brain: White matter signal, sulci/gyri symmetry, ventricular size, posterior fossa, brainstem, vascular flow voids.

Cross-reference sequences: Always correlate fluid-sensitive sequences (STIR, T2-SPAIR, T2W) with anatomical sequences (T1W, PDW). A finding on STIR that's also visible on T2W is more reliable. T1W tells you about bone marrow (normally bright = normal fat).

When in doubt about what you're seeing, describe it plainly: "There is a region of increased signal on STIR in the [location] which is also visible on T2W-SPAIR."


Step 6 — Write the report(s)

Ask the user who the report is for before writing:

  • Clinical report — for the patient's doctor; uses medical terminology
  • Plain-language report — for the patient and family; no jargon
  • Both — one of each (common and recommended)

Clinical report structure

# MRI Report — [Body Part]
## Patient Information
[table: name, ID, DOB, sex, weight, study date, accession, institution, scanner]

## Sequences Reviewed
[table: series number, sequence name, plane, slice count]

## Findings
[one section per finding, with status: PRESENT / ABSENT / NORMAL]

## Impression
[numbered list: primary finding first, then secondary, then incidentals]

---
⚠️ AI-generated — not a substitute for a licensed radiologist's report.

Plain-language report structure

# Scan Summary — [Body Part] — Plain Language
## What was scanned and when
## What this scan shows (brief explainer of modality)
## What was found
[one section per finding — use analogies, avoid jargon, explain significance]
## Summary in simple terms
## What to do next
---
⚠️ Written by an AI to help explain findings. Always consult a qualified doctor.

Always include the disclaimer. Never present findings as a definitive diagnosis.


Step 7 — Treatment recommendations (optional)

If the user asks for treatment context or recommendations:

  • Describe the typical conservative treatment pathway for the findings
  • Structure as phases: immediate relief → rehabilitation → return to activity
  • Include warning signs that warrant urgent medical review
  • Include realistic recovery timeline
  • Always note this is general guidance and individual treatment plans must come from a doctor

Output files

Save all outputs to a dedicated directory (e.g. <study-name>-output/):

output/
├── s<N>_overview.png       # 12-slice preview per series
├── s<N>_all.png            # all slices per series
├── report_clinical.md      # clinical report
├── report_plain.md         # plain-language report
└── treatment.md            # treatment notes (if requested)

Tell the user where the files are when done.