billy-lyc/neuropilot/neuroimage-pre-skill
Claude Code and agent skill by billy-lyc/neuropilot
- community
Checking that the SKILL.md file is still in the repository.
Brain MRI data preprocessing pipelines for any SLURM HPC cluster. Runs fMRIPrep, XCP-D, QSIPrep (including infant mode), QSIRecon, sMRIPrep, FreeSurfer, and PET surface pipelines to produce functional connectivity (FC), structural connectivity (SC), and cortical surface data. Use this skill when the user wants to preprocess brain MRI data, run neuroimaging pipelines, generate FC or SC matrices, process DWI/fMRI/PET data, or work with BIDS-formatted neuroimaging datasets on an HPC cluster. Trigger for any mention of fMRIPrep, QSIPrep, XCP-D, sMRIPrep, BOLD extraction, tractography, ACT-Atropos, surface projection, or cortical thickness downsampling.
Install
npx vskill@latest install billy-lyc/neuropilot/neuroimage-pre-skillSKILL.md
Brain MRI Data Preprocessing Pipelines
Preprocesses brain MRI data on any SLURM HPC cluster with Apptainer to produce functional connectivity (FC), structural connectivity (SC), and cortical surface metrics.
All pipeline scripts are bundled as assets under scripts/. Each script takes all paths as arguments — no manual path editing is needed. Cluster-specific settings (bind paths, module names, SLURM resources) are centralized in a single config file.
Step 0 — ALWAYS ask first: adult or infant?
When this skill is invoked, the first thing you must do is ask the user whether the subjects are adult or infant / neonate. Do not pick a pipeline or ask anything else until they answer — the population changes which pipelines are valid (infant anatomy needs QSIPrep --infant / infant atlases, not adult sMRIPrep+FreeSurfer).
If the user answers adult → pick by available modalities
| Available modalities | Pipeline | Reference | Output | |
|---|---|---|---|---|
| fMRI + DWI | fMRIPrep → XCP-D → QSIPrep → QSIRecon | references/fmri_dwi.md | FC + SC matrices | |
| Structural (T1/T2) + DTI, no fMRI | sMRIPrep → QSIPrep → QSIRecon | references/struct_dti_recon.md | SC matrices | |
| PET + FreeSurfer surfaces | Surface projection → Downsampling → VTK overlay | references/pet_surface.md | Cortical surface metrics |
Ask which of these matches their data, then read the matching reference.
If the user answers infant / neonate → offer the SC pipeline
The infant route in this skill produces structural connectivity (SC). Ask the user whether they want to run SC; if yes, use:
| Available modalities | Pipeline | Reference | Output | |
|---|---|---|---|---|
| Structural (T2) + DTI | QSIPrep (--infant) → ACT-Atropos tractography | references/struct_dti.md | SC matrices |
(For infant functional connectivity, that is a separate skill — fc-infant — not this one.)
Required user inputs
Only `BIDS_DIR` is truly required — ask for it. OUTPUT_DIR, WORK_DIR, LOG_DIR and CONFIG_FILE are fully customizable — the user may give any path they want — but each has a sensible default under the current working directory so they don't have to specify one:
| Input | If the user specifies a path | If they don't (default) | |
|---|---|---|---|
| `BIDS_DIR` — BIDS input data | use it | required — must ask | |
| `OUTPUT_DIR` — final results | use it | ./output | |
| `WORK_DIR` — scratch (deleted between batches) | use it | ./work | |
`LOG_DIR` — SLURM .out/.err | use it | ./logs | |
`CONFIG_FILE` — the pipeline.env | use it | ./pipeline.env (copied from template if missing) |
Offer the defaults, let the user override any of them (e.g. put WORK_DIR on fast scratch, OUTPUT_DIR on a project share), then mkdir -p whatever paths are chosen and proceed — don't block on it. CONFIG_FILE still needs the cluster-specific values (containers, FS license) filled in.
Setup
The scripts contain no hardcoded paths — every cluster-specific value lives in your own copy of scripts/pipeline.env.template. After pulling the repo:
The config declares: APPTAINER_BIND (filesystem roots the container must see), module names (MOD_APPTAINER/MOD_FREESURFER/MOD_MRTRIX/MOD_ANTS, empty if on PATH), the container .sif paths, FS_LICENSE, TEMPLATEFLOW_HOME, atlas dirs, and SLURM defaults.
Download the containers
Containers, the FreeSurfer license, and atlas files are not bundled (multi-GB / license-gated). Build each .sif once from its official Docker image, then point the matching variable in pipeline.env at it. Only build the ones your pipeline needs.
Pin these versions. The run scripts pass version-specific CLI flags. The tagsbelow are the tested, known-working combinations — using older/newer tags canreintroduce the exactunrecognized arguments/ missing-flag crashes these werechosen to avoid. If you must change a version, re-check the flags in the matchingscripts/*/run_*.shagainst that container's--help.
Version notes (why the pins matter):
- sMRIPrep ≥ 0.17:
run_smriprep.shdoes not pass--skip-bids-validation
(sMRIPrep 0.17 has no such flag; passing it aborts the job). Fixed in the script.
- Infant QSIPrep must be 1.x (e.g.
1.1.1):--infantand
--subject-anatomical-reference sessionwise are 1.x-only. run_qsiprep.sh (struct_dti) passes both — a 0.x qsiprep will reject them.
- Adult QSIPrep 0.19.x:
run_qsiprep.sh(struct_dti_recon) uses--freesurfer-input;
present in 0.16–0.19. The adult and infant SC routes may therefore use different qsiprep .sif files — set QSIPREP_IMG accordingly per route.
FreeSurfer license (free): register at https://surfer.nmr.mgh.harvard.edu/registration.html and set FS_LICENSE.
TemplateFlow (do this right — it is the #1 cause of "0%" batches)
fMRIPrep / sMRIPrep / QSIPrep read MNI (and infant) templates from TEMPLATEFLOW_HOME. Two failure modes bite people:
- Read-only shared cache — pointing
TEMPLATEFLOW_HOMEat someone else's dir
(e.g. a group /proj/.../templateflow) fails with PermissionError: ... denied the moment a needed file is missing, because TemplateFlow can't write to repair it.
- 0-byte stub files — a bare TemplateFlow install seeds empty placeholder files;
on an offline compute node the pipeline can't download the real file and crashes.
Do this instead — pre-populate a cache you own on a login node (which has internet), fetching the real files through the container so versions match:
Then set TEMPLATEFLOW_HOME in pipeline.env to that path. Verify the key file is a real (non-zero) file, e.g. ls -l $TEMPLATEFLOW_HOME/tpl-MNI152NLin6Asym/tpl-MNI152NLin6Asym_res-01_T1w.nii.gz. (Leftover empty stubs for unused atlases/resolutions are harmless — only the templates your pipeline requests must be real.)
Infant --infant: age metadata is REQUIRED
QSIPrep --infant picks the MNIInfant cohort from each participant's age and aborts (RuntimeError: Could not find age for sub-XXX) if it is missing. Provide a per-subject sub-XXX/sub-XXX_sessions.tsv (or a root participants.tsv with an age column):
For term neonates age_months=1 selects the neonate cohort. If your dataset lacks these files, add them (or a symlinked BIDS overlay carrying them) before submitting — otherwise every infant job fails at QSIPrep. Infant runs also need the MNIInfant/UNCInfant templates (see above) and the UNC_ATLAS_DIR / DHCP_ATLAS_DIR atlases for ACT-Atropos.
Checkpoints
Every pipeline step has two checkpoints built into the submission scripts:
- Pre-run checkpoint: Before submitting jobs, verifies that required input files/directories exist. Prints a summary of found/missing inputs and aborts if critical inputs are missing.
- Post-run checkpoint: After jobs complete, scans output directories to verify expected files were produced. Reports which subjects succeeded and which need rerun.
Run checkpoints standalone:
DWI input QC (run before any SC/QSIPrep step)
dwi-qc catches the malformed DWI that makes QSIPrep crash deep in the run (missing .bval/.bvec/.json, missing PhaseEncodingDirection, or a bvec/bval direction count that does not match the number of image volumes — i.e. truncated DWI). Run it first and exclude/fix the flagged subjects so you don't submit jobs that are guaranteed to fail. The SC submit_qsiprep.sh scripts also call it automatically as a pre-run warning.
- Portable & dataset-agnostic: globs BIDS-standard
*/dwi/*_dwi.nii*, checks
the standard sidecars, and reads the volume count straight from the NIfTI header with Python stdlib (gzip+struct) — no FSL/nibabel needed. Verified across single- and multi-shell data and heterogeneous subject-ID schemes.
- Scope: checks structural completeness only. It will not catch image
content problems (motion, low SNR) or rare in-tool runtime issues where the files are structurally valid — use the post-run checkpoint for those.
HPC environment
Processing strategy for large datasets
- Process in batches of ~500 subjects
- Run cleanup daemons concurrently to delete work directories as jobs finish
- Multiple users can run simultaneously on disjoint subject ranges
- Check completion after each batch before starting the next
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 repositoryCheckingneuroimage-pre-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. Refreshed 14 Oct 2026, 26 days ago.
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/neuroimage-pre-skill)