billy-lyc/neuropilot/ants-skill
Claude Code and agent skill by billy-lyc/neuropilot
- community
Checking that the SKILL.md file is still in the repository.
Use this skill whenever the user is processing MRI (or any medical/biological volumetric image) data with ANTs / ANTsX — including image registration (rigid, affine, SyN, BSplineSyN, diffeomorphic), brain extraction (skull stripping), N4 bias field correction, denoising, tissue segmentation (Atropos), cortical thickness (KellyKapowski / antsCorticalThickness.sh), template construction (antsMultivariateTemplateConstruction), applying or chaining transforms (antsApplyTransforms), label propagation, and joint label fusion. Trigger this skill on any mention of antsRegistration, antsRegistrationSyN(Quick).sh, antsApplyTransforms, antsBrainExtraction.sh, antsCorticalThickness.sh, N4BiasFieldCorrection, DenoiseImage, Atropos, KellyKapowski, or ANTsPy `ants.registration` / `ants.apply_transforms`. Also trigger on phrases like "register T1 to MNI", "warp this mask", "skull strip", "build a study template", "fix bias field", "compute cortical thickness", or any time the user shares `.nii` / `.nii.gz` files and asks to align, normalize, segment, or compare them. Even when the user does not name ANTs explicitly, prefer this skill for diffeomorphic / SyN registration tasks on neuroimaging data.
Install
npx vskill@latest install billy-lyc/neuropilot/ants-skillSKILL.md
ANTs MRI Processing
This skill turns Claude into a competent ANTs operator: picking the right command, the right parameters for the input resolution, and explaining what the outputs are. The biggest wins it provides are (1) avoiding the most common failure modes (memory blow-ups, non-convergence, mask-on-wrong-image, transform-order bugs) and (2) emitting reproducible commands rather than improvising.
First-contact behavior (read this every time the skill triggers)
The very first thing to do when this skill triggers, before answering anything and before reading any other reference, is to present the menu defined in `references/menu.md`. This is a hard rule, not a suggestion.
Workflow:
- Read `qc/QC.md` now and ask the two QC pre-flight questions before anything else. Store the answers for the rest of the session.
- Read `references/menu.md` now. It defines the exact 2-level menu structure and the wording to use.
- Show the Level-1 menu (4 categories, one-line each). Wait for the user to pick.
- Show the Level-2 sub-menu for whichever category the user picked. Wait for them to pick again. For C, there is a third level (C1a/b/c…) — show it after the user picks C1–C4.
- After they pick a Level-2 task, explain it in 2–4 sentences before asking for parameters. The explanation covers: what command actually runs, what files come out, and (if relevant) one warning or caveat.
- Then ask for the required parameters in a single batched question, not one at a time.
- Then run. Prefer bundled scripts in
scripts/; only hand-writeantsRegistrationfor the "Advanced / custom" option.
Edge cases:
- User describes a specific task without picking a letter (e.g. "I want to register my T1 to MNI"): still show the menu, with the matching option suggested as your best guess ("This sounds like B1 — confirm?"). Don't auto-route past the menu.
- User asks a clarifying question instead of picking ("what's the difference between B1 and C1a?"): answer briefly, then re-show the menu.
- User explicitly says "skip the menu" / "just run X": comply, but state assumptions explicitly before running.
- Follow-up within the same conversation ("now do the same for sub02", "also warp my mask"): skip the menu, proceed.
- Question is about ANTs but not a task ("what license is ANTs?", "is antsRegistrationSyNQuick deterministic?"): answer directly, don't show the menu.
The point of the menu is to make the skill safe to use for non-experts and explicit for experts. Don't shortcut around it.
Bundled brain templates
This skill ships with ready-to-use brain templates. When the user is working on brain data and needs a template, proactively tell them these are available before asking them to provide a path. Always offer the choice: use a bundled template, or bring your own.
Environment variables (set once → scripts pick up defaults automatically):
ANTS_BRAIN_TEMPLATE_DIR→ path toOASIS-30/ANTS_MNI_DIR→ path toMNI152/
Other common templates (not bundled — see references/templates.md for download instructions):
- MNI152NLin2009cAsym — modern nonlinear MNI, used by fMRIPrep / templateflow. Preferred when your pipeline uses fMRIPrep outputs.
- Colin27 — single-subject high-resolution (1×1×1mm), good for anatomy demonstrations or when you need maximum structural detail in a single-subject study.
- MNI152NLin6Asym — HCP project template, same space as HCP data; use when integrating with HCP parcellations.
- Pediatric MNI (NIH Pediatric Database) — for ages 4.5–18.5; do not use adult templates on children.
The standard preprocessing order
Whenever the user asks "what should I do first", default to this order. Skipping a step is fine if the data already had it done upstream — but never reorder.
- Denoise (
DenoiseImage) — optional but cheap - N4 bias field correction (
N4BiasFieldCorrection) - Brain extraction (
antsBrainExtraction.sh) — required before any tissue segmentation or cortical-thickness work - Registration (
antsRegistrationSyN.sh) — to template / atlas / another subject - Apply transforms to derived data (masks, labels, fMRI, DTI) using
antsApplyTransforms
For cortical thickness, antsCorticalThickness.sh does steps 2–4 plus segmentation in one shot — see references/pipeline_corticalthickness.md.
Picking convergence / shrink / smoothing parameters
This is the place new users get burned. Rules of thumb:
- Number of resolution levels = log2(min image dim / 32), rounded down, capped at 4. For a typical 1mm 256-cube T1, use 4 levels (
8x4x2x1). - Smoothing sigmas in voxels: one less per level, ending at 0 (e.g.
3x2x1x0vox). - Iterations: linear stages can use generous iteration counts (
1000x500x250x100) because they're cheap; SyN should be lower (100x70x50x20) because each iteration is expensive. - `SyN[gradStep, updateFieldVar, totalFieldVar]`: defaults
SyN[0.1, 3, 0]are sane. IncreasegradStep(up to 0.25) for faster convergence on similar images; decrease for noisier or cross-modal cases.totalFieldVar=0lets the deformation be unrestricted; nonzero values smooth the total field and reduce overfitting at the cost of accuracy.
assets/default_convergence_profiles.json has ready-to-use profiles keyed by voxel size. Reach for it when generating commands.
Variable conventions used in scripts
All bundled scripts standardize on:
$1(or first named arg) = fixed image (template / target)$2(or second) = moving image (subject)$OUTPREFIX= prefix for outputs; ANTs will produce${OUTPREFIX}0GenericAffine.mat,${OUTPREFIX}1Warp.nii.gz,${OUTPREFIX}1InverseWarp.nii.gz, and${OUTPREFIX}Warped.nii.gz- Threads come from
$NSLOTSif set (cluster convention) elsenprocelse 4
Output file cheat sheet
After a typical rigid+affine+SyN run with prefix sub01_to_MNI_, you get:
| File | What it is | Used by | |
|---|---|---|---|
sub01_to_MNI_0GenericAffine.mat | Combined rigid+affine in ITK format | Forward & inverse linear | |
sub01_to_MNI_1Warp.nii.gz | Forward nonlinear displacement field | Mapping subject → MNI | |
sub01_to_MNI_1InverseWarp.nii.gz | Inverse nonlinear displacement field | Mapping MNI → subject | |
sub01_to_MNI_Warped.nii.gz | Subject resampled into MNI space | Visual QC | |
sub01_to_MNI_InverseWarped.nii.gz | MNI resampled into subject space (only if [fwd,inv] output requested) | Visual QC |
To go subject → MNI: -t sub01_to_MNI_1Warp.nii.gz -t sub01_to_MNI_0GenericAffine.mat (warp listed first in command line, applied last) To go MNI → subject: -t [sub01_to_MNI_0GenericAffine.mat, 1] -t sub01_to_MNI_1InverseWarp.nii.gz
The order is the most common bug — see references/transform_recipes.md section "Transform order" for the full explanation.
Reproducibility checklist
When the user wants reproducible runs (papers, regulatory submissions):
- Set
ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1(multithreading introduces nondeterminism in some metrics) - Use
antsRegistrationSyN.sh -y(forces fixed seed and GC metric on linear stages) - Pin the ANTs version (
antsRegistration --version) and record it - Use
--float 0(double precision) unless memory is tight
Note that -y trades some affine accuracy for reproducibility — Mattes MI on linear stages is usually more accurate but nondeterministic in ITK's implementation.
ANTsPy equivalents
If the user is in Python, every workflow has an ANTsPy equivalent. Key mapping:
| Bash | ANTsPy | |
|---|---|---|
antsRegistrationSyN.sh -t s | ants.registration(fixed, moving, type_of_transform='SyN') | |
antsRegistrationSyNQuick.sh -t s | ants.registration(..., type_of_transform='SyNRA') (rigid+affine+SyN, fewer iterations) | |
antsApplyTransforms | ants.apply_transforms(fixed, moving, transformlist=[...], interpolator='linear') | |
N4BiasFieldCorrection | ants.n4_bias_field_correction(image) | |
antsBrainExtraction.sh | antspynet.brain_extraction(image, modality='t1') (deep-learning version, faster) | |
Atropos | ants.atropos(a=image, m='[0.2,1x1x1]', i='kmeans[3]', x=mask) |
Important ANTsPy gotcha: for deformable-only transform types (SyNOnly, BSplineSyNOnly, time-varying), the default initial transform is identity, not center-of-mass alignment. Pass initial_transform='Identity' explicitly only when you mean it.
Common pitfalls (red-flag triggers)
If you see any of these in the user's setup, stop and address before running anything:
- "Segmentation 11" error → fixed and moving aren't in the same physical space sense; check headers with
PrintHeaderorfslhd. Don't proceed until aligned to same orientation. - Memory blowing past 80% → SyN on >1mm³ data with full-precision is the usual culprit. Switch to
--float 1, reduce SyN iterations, or useBSplineSyNinstead. - User has a lesion / tumor / resection cavity → the lesion mask must NOT be in the moving image without mitigation. Either flip the registration direction (template as moving, subject as fixed, then invert) or pass the lesion as a cost-function mask via
-xon the appropriate image. - Registering label maps directly → never. Always register the underlying intensity image, then apply the transform to the label map with
NearestNeighbororGenericLabelinterpolation. - Cross-modal with CC metric → wrong; CC assumes intensity correlation. Use MI or Mattes for cross-modal.
- No initial transform on very misaligned images →
antsRegistrationwill start from identity and waste 80% of compute trying to find the brain. Always include--initial-moving-transform [fixed,moving,1](the1means center-of-mass) for first-time pairs.
Files in this skill
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingqc-agent-skill/ants_skill/SKILL.md
Popularity
- Repository stars
- 54
- Repository forks
- 5
- 7-day trend score
- 20
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/billy-lyc/neuropilot/ants-skill)