
radiology-preprocessing
Structural MRI/CT preprocessing pipeline for radiology workflows covering skull stripping, bias field correction, registration, and intensity normalization. Triggers on skull stripping, bias correction, registration, ANTs, FSL, HD-BET, N4, brain extraction, normalization, FLIRT, FNIRT, SyN, fslreorient2std, MNI registration, T1 preprocessing.
- Installs
- 91
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/awslabs/hcls-agent-skills --skill radiology-preprocessing- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads radiology-preprocessing automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Radiology Preprocessing
Overview
Deterministic commands for preprocessing structural brain MRI (T1w, T2w, FLAIR) and related volumetric radiology data. Covers the canonical pipeline used by most downstream analyses (segmentation, registration studies, deep-learning training): reorient → bias correction → skull strip → registration → intensity normalization.
Tools used:
- HD-BET — CNN-based brain extraction (state-of-the-art on pathological brains).
- FSL —
bet,flirt,fnirt,fslmaths,fslreorient2std. - ANTs —
N4BiasFieldCorrection,antsRegistrationSyNQuick.sh,antsApplyTransforms. - FreeSurfer —
mri_convertfor resampling/format conversion.
All commands operate on NIfTI (.nii / .nii.gz). Run in a POSIX shell with the respective tool on PATH.
Usage
Standard T1w preprocessing pipeline
Run these steps in order on a single subject volume:
# 1. Reorient to standard (MNI-style RAS orientation)
fslreorient2std input.nii.gz reoriented.nii.gz
# 2. N4 bias field correction (BEFORE skull stripping)
N4BiasFieldCorrection -d 3 \
-i reoriented.nii.gz \
-o [n4.nii.gz,bias_field.nii.gz] \
-s 3 \
-c [50x50x30x20,1e-6] \
-b [300]
# 3. Skull strip with HD-BET
hd-bet -i n4.nii.gz -o brain.nii.gz -device 0 -mode fast -tta 0
# CPU fallback (slower, no CUDA required): -device cpu
# 4. Register to MNI152 template (SyN nonlinear)
antsRegistrationSyNQuick.sh -d 3 \
-f $FSLDIR/data/standard/MNI152_T1_1mm_brain.nii.gz \
-m brain.nii.gz \
-o sub2mni_ \
-t s
# 5. Z-score intensity normalization within brain mask
fslmaths brain.nii.gz -mas brain_mask.nii.gz brain_masked.nii.gz
MEAN=$(fslstats brain_masked.nii.gz -k brain_mask.nii.gz -M)
STD=$(fslstats brain_masked.nii.gz -k brain_mask.nii.gz -S)
fslmaths brain_masked.nii.gz -sub $MEAN -div $STD -mas brain_mask.nii.gz brain_zscore.nii.gz
HD-BET writes brain.nii.gz and brain_mask.nii.gz (mask has _mask suffix by default).
GPU acceleration
HD-BET defaults to GPU; use -device 0 for first CUDA device. -mode fast -tta 0 disables test-time augmentation for ~5x speedup with minimal quality loss.
hd-bet -i n4.nii.gz -o brain.nii.gz -device 0
Response Format
- Lead with the command or code the user needs — explain after
- Structure as: confirm inputs → working code → key parameters explained → gotchas
- One complete working example per task; do not show every alternative
- Keep code comments minimal and functional (what, not why-it-exists)
- Target: 50-100 lines of code with brief surrounding explanation
Do not narrate the pipeline ordering rationale or preprocessing theory unless explicitly asked — produce the correct commands in sequence with brief parameter justification.
Core Concepts
1. Skull stripping (brain extraction)
HD-BET (preferred — robust to pathology):
hd-bet -i input.nii.gz -o output_bet.nii.gz -device cpu -mode fast -tta 0
FSL BET (fallback, classical):
bet input.nii.gz output_bet.nii.gz -R -f 0.3 -g 0
-R: robust centre-of-gravity estimation.-f 0.3: fractional intensity threshold (lower = larger brain mask).-g 0: vertical gradient in threshold.
2. Bias field correction — N4 (ANTs)
Correct low-frequency intensity inhomogeneity from RF coil / B1 field. Always run before skull stripping — the bias field estimate is better with the skull in place, and a skull-stripped input produces artifacts near the brain boundary.
N4BiasFieldCorrection -d 3 \
-i input.nii.gz \
-o [corrected.nii.gz,bias_field.nii.gz] \
-s 3 \
-c [50x50x30x20,1e-6] \
-b [300]
-d 3: 3D image.-s 3: shrink factor (speedup).-c [50x50x30x20,1e-6]: max iterations per level + convergence threshold.-b [300]: B-spline mesh resolution (mm).
3. Registration — ANTs
antsRegistrationSyNQuick.sh is the sensible default wrapper.
# Rigid (6 DOF) — same subject, different timepoint/modality
antsRegistrationSyNQuick.sh -d 3 -f fixed.nii.gz -m moving.nii.gz -o output_ -t r
# Affine (12 DOF) — cross-subject coarse alignment
antsRegistrationSyNQuick.sh -d 3 -f fixed.nii.gz -m moving.nii.gz -o output_ -t a
# SyN (nonlinear) — atlas / MNI registration
antsRegistrationSyNQuick.sh -d 3 -f fixed.nii.gz -m moving.nii.gz -o output_ -t s
Outputs (for -t s):
output_0GenericAffine.mat— affine transform.output_1Warp.nii.gz/output_1InverseWarp.nii.gz— displacement fields.output_Warped.nii.gz— moving resampled into fixed space.
Apply the saved transform to another image (e.g., a segmentation):
# For intensity images — Linear interpolation
antsApplyTransforms -d 3 \
-i input.nii.gz \
-r reference.nii.gz \
-o output.nii.gz \
-t output_1Warp.nii.gz \
-t output_0GenericAffine.mat
# For label maps — NearestNeighbor interpolation
antsApplyTransforms -d 3 \
-i labels.nii.gz \
-r reference.nii.gz \
-o labels_in_ref.nii.gz \
-n NearestNeighbor \
-t output_1Warp.nii.gz \
-t output_0GenericAffine.mat
ANTs applies transforms in reverse order: the last -t is applied first. For moving→fixed, the affine is applied before the warp, so the CLI order is -t warp -t affine.
4. Registration — FSL FLIRT + FNIRT
Linear (affine):
flirt -in moving.nii.gz -ref fixed.nii.gz \
-out output.nii.gz -omat affine.mat -dof 12
Nonlinear (requires affine init):
fnirt --in=moving.nii.gz \
--ref=$FSLDIR/data/standard/MNI152_T1_1mm.nii.gz \
--aff=affine.mat \
--cout=warp \
--iout=output.nii.gz
Apply warp to another image:
applywarp -i input.nii.gz -r MNI152_T1_1mm.nii.gz -w warp -o output.nii.gz
# For labels:
applywarp -i labels.nii.gz -r MNI152_T1_1mm.nii.gz -w warp -o labels_mni.nii.gz --interp=nn
5. Intensity normalization
Needed before most ML models — raw MRI intensities are arbitrary units and vary across scanners/sessions.
Z-score within brain mask (most common):
MEAN=$(fslstats brain.nii.gz -k brain_mask.nii.gz -M)
STD=$(fslstats brain.nii.gz -k brain_mask.nii.gz -S)
fslmaths brain.nii.gz -sub $MEAN -div $STD -mas brain_mask.nii.gz zscore.nii.gz
White matter normalization (scanner-invariant):
- Segment WM with FSL FAST or FreeSurfer.
- Compute mean intensity inside WM mask:
fslstats brain.nii.gz -k wm_mask.nii.gz -M. - Divide volume by that mean.
Histogram matching — match the intensity histogram to a reference subject:
- ANTs:
ImageMath 3 out.nii.gz HistogramMatch moving.nii.gz reference.nii.gz. - SimpleITK:
sitk.HistogramMatchingImageFilter().
6. Resampling
FreeSurfer (preferred for isotropic resampling):
mri_convert --voxel-size 1 1 1 input.nii.gz output_1mm.nii.gz
FSL:
flirt -in input.nii.gz -ref input.nii.gz -applyisoxfm 1 -out output_1mm.nii.gz
# For labels use: -interp nearestneighbour
Standard pipeline order
reorient (fslreorient2std)
→ N4 bias correction
→ skull strip (HD-BET)
→ registration (ANTs SyN or FSL FNIRT)
→ intensity normalization (z-score / WM)
Resampling to isotropic 1 mm is usually done either at reorient time (if input is anisotropic) or implicitly by registration to a 1 mm template.
Quick Reference
| Task | Command |
|---|---|
| Reorient to standard | fslreorient2std in.nii.gz out.nii.gz |
| N4 bias correction | N4BiasFieldCorrection -d 3 -i in.nii.gz -o [out.nii.gz,bias.nii.gz] -s 3 -c [50x50x30x20,1e-6] -b [300] |
| Skull strip (HD-BET) | hd-bet -i in.nii.gz -o brain.nii.gz -device cpu -mode fast -tta 0 |
| Skull strip (BET) | bet in.nii.gz brain.nii.gz -R -f 0.3 -g 0 |
| Rigid register (ANTs) | antsRegistrationSyNQuick.sh -d 3 -f fix.nii.gz -m mov.nii.gz -o out_ -t r |
| Affine register (ANTs) | antsRegistrationSyNQuick.sh -d 3 -f fix.nii.gz -m mov.nii.gz -o out_ -t a |
| SyN register (ANTs) | antsRegistrationSyNQuick.sh -d 3 -f fix.nii.gz -m mov.nii.gz -o out_ -t s |
| Apply ANTs transform (image) | antsApplyTransforms -d 3 -i in.nii.gz -r ref.nii.gz -o out.nii.gz -t out_1Warp.nii.gz -t out_0GenericAffine.mat |
| Apply ANTs transform (labels) | Add -n NearestNeighbor |
| FLIRT affine | flirt -in mov.nii.gz -ref fix.nii.gz -out out.nii.gz -omat aff.mat -dof 12 |
| FNIRT nonlinear | fnirt --in=mov.nii.gz --ref=MNI152_T1_1mm.nii.gz --aff=aff.mat --cout=warp --iout=out.nii.gz |
| Z-score normalize | fslmaths in.nii.gz -sub $MEAN -div $STD -mas mask.nii.gz out.nii.gz |
| Histogram match (ANTs) | ImageMath 3 out.nii.gz HistogramMatch mov.nii.gz ref.nii.gz |
| Resample isotropic 1 mm | mri_convert --voxel-size 1 1 1 in.nii.gz out.nii.gz |
Standard templates (FSL)
$FSLDIR/data/standard/MNI152_T1_1mm.nii.gz— whole-head.$FSLDIR/data/standard/MNI152_T1_1mm_brain.nii.gz— brain-only.$FSLDIR/data/standard/MNI152_T1_2mm_brain.nii.gz— 2 mm for faster registration.
Common Mistakes
-
Wrong: Running skull stripping before bias field correction Right: Always run N4 bias correction first, then skull strip Why: Bias field estimation needs the full field of view including skull/neck to fit a smooth B-spline; N4 on an already-stripped brain introduces edge artifacts and leaves residual inhomogeneity
-
Wrong: Using linear/trilinear interpolation when resampling label maps Right: Use
NearestNeighbor(ANTs:-n NearestNeighbor; FSL:--interp=nn) for any discrete label volume Why: Linear interpolation on integer segmentation labels produces meaningless fractional values and destroys class boundaries -
Wrong: Specifying ANTs transforms in forward CLI order (affine then warp) Right: Use
-t output_1Warp.nii.gz -t output_0GenericAffine.mat— warp first in CLI, affine second Why:antsApplyTransformscomposes in reverse CLI order (last-tapplied first); reversing them silently produces misregistered output -
Wrong: Registering each longitudinal timepoint independently to MNI Right: Build a subject-specific midpoint template, register each timepoint to it, then register the midpoint once to MNI Why: Independent registration introduces asymmetric interpolation bias that corrupts longitudinal measurements (e.g., atrophy)
-
Wrong: Skipping reorientation at the start of the pipeline Right: Always run
fslreorient2stdfirst on inputs from different scanners/vendors Why: Inconsistent storage orientations cause downstream tools to misinterpret coordinate frames -
Wrong: Computing z-score normalization over the full volume including background Right: Compute mean/std within the brain mask only (
fslstats -k brain_mask.nii.gz) Why: Including background zeros drags the mean down and inflates the standard deviation, producing incorrect normalization
References
- HD-BET: Isensee et al. Hum Brain Mapp 2019, https://doi.org/10.1002/hbm.24750
- ANTs: Avants et al. NeuroImage 2011, https://doi.org/10.1016/j.neuroimage.2010.09.025
- N4 bias correction: Tustison et al. IEEE TMI 2010, https://doi.org/10.1109/TMI.2010.2046908
- FSL: Jenkinson et al. NeuroImage 2012, https://doi.org/10.1016/j.neuroimage.2011.09.015
FAQ
What does the radiology-preprocessing skill do?
Structural MRI/CT preprocessing pipeline for radiology workflows covering skull stripping, bias field correction, registration, and intensity normalization. Triggers on skull stripping, bias correction, registration, ANTs, FSL, HD-BET, N4, brain extraction, normalization, FLIRT, FNIRT, SyN, fslreorient2std, MNI registration, T1 preprocessing.
How do I install radiology-preprocessing?
Run npx skills add https://github.com/awslabs/hcls-agent-skills --skill radiology-preprocessing in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/radiology-preprocessing/ (personal) or .claude/skills/radiology-preprocessing/ (project).
Which AI agents can use radiology-preprocessing?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is radiology-preprocessing safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains radiology-preprocessing?
It is published by awslabs in awslabs/hcls-agent-skills. It has 91 recorded installs.
More from awslabs/hcls-agent-skills
ml-researcher
awslabs/hcls-agent-skills
Reason about ML experiment design for healthcare and life sciences data. Use when the user asks to design an ML study, choose a model for clinical/biomedical data, set up cross-validation, pick evaluation metrics, audit fairness, plan a regulatory submission, or critique an ML pipeline on EHR, medical imaging, genomics, molecules, or clinical text. Triggers include "design an ML experiment", "which model for this clinical data", "how should I split", "nested CV", "class imbalance", "AUROC vs AUPRC", "calibration", "decision curve", "net benefit", "TRIPOD+AI", "PROBAST", "CLAIM", "FDA SaMD", "PCCP", "GMLP", "site generalization", "temporal leakage", "scaffold split", "foundation model evaluation", "subgroup fairness", "is this model ready for deployment".
clinical-data-standards
awslabs/hcls-agent-skills
Reason about clinical data terminology standards — MedDRA hierarchy (LLT→PT→HLT→HLGT→SOC), ICD-10 code structure and grouping, SNOMED CT concept model, LOINC panel relationships, and mapping decisions between systems. Use when the user asks to code adverse events, map diagnoses to ICD-10, choose a coding granularity level, group AEs by SOC or PT, interpret SNOMED CT relationships, select LOINC codes for lab panels, convert between terminology systems, or decide when to aggregate at HLT vs PT level. Triggers include "MedDRA coding", "ICD-10 grouping", "SNOMED CT", "LOINC panel", "adverse event coding", "terminology mapping", "SOC table", "preferred term", "code hierarchy", "clinical coding", "AE frequency table", "diagnosis grouping", "lab code selection", "cross-walk between terminologies".
dicom-processing
awslabs/hcls-agent-skills
DICOM and NIfTI medical image processing pipeline. Triggers on DICOM, NIfTI, dcm2niix, de-identification, pydicom, DICOM header, conversion, anonymization, BIDS, DICOM tags, medical image format conversion, "DICOM to NIfTI", "burned-in PHI", "SeriesInstanceUID", "nibabel", "DICOM anonymization".
medical-device-software-compliance
awslabs/hcls-agent-skills
Reason about SaMD (Software as a Medical Device) regulatory compliance for FDA, EU MDR, and global submissions. Use when the user asks about IEC 62304 safety classification, ISO 14971 risk management, 21 CFR 820/QMSR quality system requirements, Design History File structure, 510(k)/De Novo/PMA pathway selection, SOUP/OTS assessment, verification and validation planning, cybersecurity for medical devices, PCCP for AI/ML devices, design reviews, traceability matrices, or post-market surveillance. Triggers include "SaMD", "medical device software", "IEC 62304", "ISO 14971", "ISO 13485", "21 CFR 820", "QMSR", "510(k)", "De Novo", "PMA", "design history file", "DHF", "software safety classification", "SOUP list", "risk management", "hazard analysis", "design review", "V&V protocol", "FDA submission", "EU MDR", "clinical evaluation", "PCCP", "predetermined change control", "GMLP", "cybersecurity premarket", "Part 11", "design controls", "design inputs", "design outputs", "traceability matri
claims-billing-rules
awslabs/hcls-agent-skills
Reasoning skill for healthcare claims billing rules and fraud detection logic. Use when the user asks about CMS billing rules, place of service codes, global surgery periods, modifier usage (25 59 76 77), NCCI edit logic, column 1 column 2 code pairs, mutually exclusive procedures, modifier indicators, fraud waste and abuse patterns, E&M upcoding, unbundling, phantom billing, impossible day detection, coding error versus fraud distinction, FWA investigation methodology, or claims audit logic. Triggers include "CMS billing rules", "NCCI edits", "modifier 25", "modifier 59", "global surgery period", "upcoding", "unbundling", "phantom billing", "impossible day", "FWA", "fraud waste abuse", "coding error vs fraud", "claims audit", "billing compliance", "E&M level selection".
ehr-data-parsing
awslabs/hcls-agent-skills
Parse and extract clinical data from HL7v2 messages and FHIR R4 resources using Python. Use when the user mentions HL7v2, HL7, FHIR, PID segment, OBX segment, MSH segment, Patient resource, Observation resource, Condition resource, MedicationRequest, EHR data extraction, clinical message parsing, FHIR bundle, HL7 to FHIR conversion, ADT message, ORU message, lab result extraction, or clinical data quality checks. Triggers include "parse HL7", "extract FHIR", "HL7v2 message", "FHIR resource", "PID segment", "OBX segment", "Patient resource", "Observation resource", "EHR parsing", "clinical data extraction", "HL7 to CSV", "FHIR to DataFrame".
Popular ai & agents skills
google-agents-cli-publish
google/agents-cli
This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).
google-agents-cli-eval
google/agents-cli
This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).
skill-creator
anthropics/skills
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
codex-pet
prime-skills/runcomfy-agent-skills
Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.
full-output-enforcement
leonxlnx/taste-skill
Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.
executing-plans
obra/superpowers
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available