bids
Organizes, queries, validates, and converts neuroscience and biomedical datasets using the Brain Imaging Data Structure (BIDS) standard, covering MRI, PET, EEG, MEG, iEEG, EMG, NIRS, microscopy, motion capture, and behavioral data. Covers PyBIDS (BIDSLayout), the bids-validator, HeuDiConv, dcm2bids, BIDScoin, JSON sidecars, dataset_description.json, events.tsv, participants.tsv, .bidsignore, and derivatives. Use when arranging raw data into BIDS directories and filenames. Use when converting DICOM scans to BIDS. Use when validating a dataset before OpenNeuro or DANDI submission. Use when querying files or sidecar metadata with PyBIDS. Use when writing BIDS derivatives. For extracellular Neuropixels analysis, use neuropixels-analysis instead.
Install this skill
Works with Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, and 70+ other harnesses.
npx skills add KalarisLabs/research-agent-skills --skill bidsuvx research-agent-skills install bidsDocumentation & Instructions
Brain Imaging Data Structure (BIDS)
Overview
The Brain Imaging Data Structure (BIDS) is a community standard for organizing and describing neuroscience and biomedical research datasets. It defines a consistent file naming convention, directory hierarchy, and metadata schema so that datasets are immediately understandable by humans and software tools alike. BIDS is governed by the BIDS Specification (currently v1.11.x) and is maintained by the community via the BIDS-Standard GitHub organization.
While BIDS originated for MRI, it has grown well beyond neuroimaging. The specification now covers 11 modalities spanning imaging, electrophysiology, and behavioral data:
- Imaging: MRI (structural, functional, diffusion, fieldmaps, perfusion/ASL), PET, microscopy
- Electrophysiology: EEG, MEG, iEEG (intracranial EEG), EMG
- Other: NIRS (near-infrared spectroscopy), motion capture, behavioral data (without imaging), MR spectroscopy
Active BEPs are extending BIDS further — notably BEP032 (microelectrode electrophysiology) will add support for extracellular recordings including Neuropixels probes, bringing BIDS to a prevalent methodology in animal neuroscience research (see also the neuropixels-analysis skill).
Adoption is required or strongly encouraged by major data repositories (OpenNeuro, DANDI), leading journals (NeuroImage, Human Brain Mapping, Scientific Data), and funding agencies (NIH, ERC).
The Python ecosystem for BIDS centers on PyBIDS (pybids) for querying and indexing BIDS datasets, and the bids-validator (Deno-based, available as PyPI package bids-validator-deno or via Deno directly) for compliance checking. Conversion from DICOM is typically done with HeuDiConv, dcm2bids, or BIDScoin.
When to Use This Skill
Apply this skill when:
- Organizing raw neuroscience data (imaging, electrophysiology, behavioral) into BIDS-compliant directory structures
- Querying an existing BIDS dataset to find specific files by subject, session, task, run, or modality
- Validating a dataset against the BIDS specification before sharing or submission
- Converting DICOM data from scanners into BIDS format
- Writing or editing JSON sidecar metadata files
- Creating BIDS-compliant derivatives (preprocessed data, analysis outputs)
- Setting up a
dataset_description.jsonfor a new dataset - Working with BIDS entities (subject, session, task, acquisition, run, etc.)
- Configuring
.bidsignoreto exclude files from validation - Preparing data for upload to OpenNeuro, DANDI, or other BIDS-aware repositories
Installation
# Core BIDS querying library
uv pip install pybids
# BIDS validator (Deno-based, installed via PyPI wrapper)
uv pip install bids-validator-deno
# Alternative: install directly via Deno
# deno install -g -A npm:bids-validator
# DICOM-to-BIDS converters (install as needed)
uv pip install heudiconv # HeuDiConv - heuristic-based DICOM conversion
uv pip install dcm2bids # dcm2bids - config-file-based conversion
# BIDScoin: uv pip install bidscoin
# Useful companions
uv pip install nibabel # NIfTI/other neuroimaging file I/O
uv pip install pydicom # DICOM file reading (used by converters)
Core Workflows
Twelve workflow areas, each with worked code, are documented in references/core_workflows.md:
- BIDS directory structure — the required layout and where each modality belongs.
dataset_description.json— the required fields and how to generate it.- Querying with PyBIDS —
BIDSLayout, entity filters, sidecar metadata with automatic inheritance, and building paths from entities. - Validation —
bids-validatorvia the PyPI wrapper (recommended), via Deno directly, the legacy Node validator, and using.bidsignoreto exclude files. - Entities and file naming — the entity order and naming grammar.
- DICOM to BIDS conversion — HeuDiConv (including the turnkey ReproIn path and the reconnaissance → heuristic → convert sequence) and dcm2bids (config-file based).
- Metadata sidecars — required and recommended JSON fields per modality.
- Events files — task fMRI event timing and column conventions.
- Participants file —
participants.tsvand its data dictionary. - Derivatives — the derivatives layout and its
dataset_description.json. - Advanced PyBIDS — index caching, including derivatives, confound regressors, and DataFrame output.
- BIDS-Apps — the standard invocation pattern, and fMRIPrep, MRIQC, and QSIPrep.
Validate early and often: PyBIDS validates structure when it indexes a dataset, so an indexing failure usually means a naming or metadata problem rather than a code bug.
Reference Materials
This skill includes detailed reference documentation:
- bids_schema.json: Machine-readable BIDS schema (from https://bids-specification.readthedocs.io/en/stable/schema.json). This is the authoritative source for entity definitions, ordering rules, filename templates, allowed suffixes per datatype, and metadata field requirements. BEP-specific schemas are at https://github.com/bids-standard/bids-schema/tree/main/BEPs.
- beps.yml: Current list of all BIDS Extension Proposals with titles, leads, status, and links (from bids-website)
- bids_specification.md: Human-readable summary of the entity table, datatype reference, directory structure rules, template spaces, and specification changelog
- metadata_fields.md: Required and recommended JSON sidecar fields for every BIDS modality (anat, func, dwi, fmap, eeg, meg, pet, etc.)
- conversion_tools.md: Detailed workflows for HeuDiConv, dcm2bids, and BIDScoin including heuristic/config examples and troubleshooting
Update schema and BEPs with: python scripts/update_schema.py
Common Issues and Solutions
1. Validator reports "Not a BIDS dataset"
Cause: Missing dataset_description.json at the root.
Fix: Create the file with at minimum {"Name": "...", "BIDSVersion": "1.10.0"}.
2. Inconsistent subjects warning
Cause: Not all subjects have the same set of files (some missing sessions, runs, etc.).
Fix: This is a warning, not an error. Use --ignoreSubjectConsistency if intentional. Document missing data in participants.tsv or a scans.tsv.
3. Missing SliceTiming
Cause: dcm2niix couldn't extract slice timing from DICOM headers.
Fix: Determine slice order from the scan protocol and add manually to the JSON sidecar. Common patterns: ascending, descending, interleaved (odd-first or even-first).
4. Phase encoding direction confusion
Cause: Axis labels (i/j/k vs x/y/z vs LR/AP/SI) are confusing.
Fix: In BIDS, use NIfTI image axes: i=first axis, j=second, k=third. - means negative direction. For standard axial acquisitions: j is typically anterior-posterior. Verify with the acquisition protocol.
5. PyBIDS is slow on large datasets
Cause: Full filesystem indexing on every BIDSLayout() call.
Fix: Use database_path to cache the index to an SQLite file:
layout = BIDSLayout("/data", database_path="/data/.pybids_cache.db")
6. Derivatives not found by PyBIDS
Cause: Derivatives directory missing its own dataset_description.json.
Fix: Every derivatives directory must have dataset_description.json with "DatasetType": "derivative".
7. Events file timing is off
Cause: onset times are relative to the wrong reference (e.g., trigger time vs first volume).
Fix: Onsets must be in seconds relative to the first volume of that run's acquisition. Account for dummy scans if they were discarded.
8. TSV files fail validation
Cause: Encoding or delimiter issues (spaces instead of tabs, BOM characters, Windows line endings).
Fix: Ensure tab-separated values with UTF-8 encoding and Unix line endings (\n). Use n/a (not NA, NaN, or empty) for missing values.
Best Practices
Validate early and often - Run the BIDS validator after every conversion or modification. Fix errors before they compound.
Use metadata inheritance - Place shared metadata (e.g.,
TaskName, scanner parameters) in top-level sidecar files rather than duplicating in every subject's directory.Keep sourcedata - Store the original DICOM (or other raw) data under
sourcedata/so conversions are reproducible. Addsourcedata/to.bidsignore.Use consistent naming from the start - Define your BIDS naming scheme before data collection. Use the ReproIn naming convention for scan protocols to enable automatic conversion.
Document your dataset - Write a thorough
READMEdescribing the study design, acquisition parameters, known issues, and any deviations from BIDS.Use scans.tsv for run-level metadata - Record per-run acquisition times and quality notes:
filename acq_time quality func/sub-01_task-rest_bold.nii.gz 2025-01-15T10:30:00 goodVersion your dataset - Use
CHANGESto document dataset modifications. Consider DataLad for full version control of large datasets.Deface anatomical images - Remove facial features from T1w/T2w images before sharing (e.g., using
pydeface,mri_deface, orafni_refacer). Store defaced versions as the primary data or use_defacemaskfiles.Use BIDS URIs for provenance - In derivatives, reference source files using BIDS URIs:
bids::sub-01/anat/sub-01_T1w.nii.gz.Prefer community tools - Use established BIDS-Apps (fMRIPrep, MRIQC, QSIPrep) rather than custom pipelines when possible. They handle BIDS I/O correctly and produce BIDS-compliant derivatives.
Study bids-examples - The bids-examples repository is the canonical collection of prototypical BIDS datasets covering different modalities and use cases (MRI, fMRI, DWI, EEG, MEG, iEEG, PET, ASL, genetics, derivatives, and more). Use it as a reference when structuring your own dataset, as test data for BIDS tools, or to understand how a specific modality should be organized. Each example passes the BIDS validator.
BIDS Extension Proposals (BEPs)
BEPs are community-driven proposals to extend BIDS to new modalities, derivatives, or metadata. The full list with status, leads, and links is in references/beps.yml (fetched from the bids-website). BEP-specific schema previews are rendered at https://github.com/bids-standard/bids-schema/tree/main/BEPs.
Current BEPs (as of schema update):
| BEP | Title | Content | Status |
|---|---|---|---|
| 004 | Susceptibility Weighted Imaging | raw | Seeking new leader |
| 011 | Structural preprocessing derivatives | derivative | Has PR (#518) |
| 012 | Functional preprocessing derivatives | derivative | Has PR (#519), schema implemented |
| 014 | Affine transforms and nonlinear field warps | derivative | X5 format development |
| 016 | Diffusion weighted imaging derivatives | derivative | Has PR (#2211) |
| 017 | Generic BIDS connectivity data schema | derivative | In development |
| 021 | Common Electrophysiological Derivatives | derivative | In development |
| 023 | PET Preprocessing derivatives | derivative | In development |
| 024 | Computed Tomography scan | raw | Seeking contributors |
| 026 | Microelectrode Recordings | raw | Seeking new leader |
| 028 | Provenance | metadata | Has PR (#2099) |
| 032 | Microelectrode electrophysiology | raw | Has PR (#2307), preview available — covers Neuropixels and other extracellular probes; relates to neuropixels-analysis skill |
| 033 | Advanced Diffusion Weighted Imaging | raw | Seeking contributors |
| 034 | Computational modeling | derivative | Has PR (#967) |
| 035 | Mega-analyses with non-compliant derivatives | derivative | In development |
| 036 | Phenotypic Data Guidelines | raw | Community review |
| 037 | Non-Invasive Brain Stimulation | raw | In development |
| 039 | Dimensionality reduction-based networks | raw | In development |
| 040 | Functional Ultrasound | raw | In development |
| 041 | Statistical Model Derivatives | derivative | Collecting feedback |
| 043 | BIDS Term Mapping | metadata | Collecting feedback |
| 044 | Stimuli | raw | Has PR (#2022), community review |
| 045 | Peripheral Physiological Recordings | raw | Has PR (#2267) |
| 046 | Diffusion Tractography | derivative | In development |
| 047 | Audio/video recordings for behavioral experiments | raw | Has PR (#2231) |
Related standards:
- BIDS-Stats Models: JSON specification for defining GLM-based neuroimaging analyses
- BIDS-Derivatives (BEP003): Standard for preprocessed/analysis outputs (partially merged into spec)
Related Tools Ecosystem
| Tool | Purpose |
|---|---|
| fMRIPrep | fMRI preprocessing (produces BIDS derivatives) |
| MRIQC | MRI quality control (produces BIDS derivatives) |
| QSIPrep | Diffusion MRI preprocessing |
| TemplateFlow | Neuroimaging templates and atlases with BIDS-like naming |
| Fitlins | BIDS Stats Models implementation |
| DataLad | Version control for large datasets, integrates with BIDS |
| OpenNeuro | Free BIDS dataset repository |
| DANDI | Neurophysiology data archive (uses BIDS for some modalities) |
| HeuDiConv | DICOM-to-BIDS with heuristic Python files |
| dcm2bids | DICOM-to-BIDS with JSON config |
| BIDScoin | DICOM-to-BIDS with GUI and YAML config |
| nwb2bids | Convert NWB (Neurodata Without Borders) files to BIDS |
| CuBIDS | BIDS dataset curation and harmonization |
| bids2table | Efficient tabular indexing of BIDS datasets |
| bids-examples | Canonical collection of prototypical BIDS datasets for all modalities |
Documentation
- BIDS Specification: https://bids-specification.readthedocs.io/
- BIDS Website: https://bids.neuroimaging.io/
- PyBIDS Documentation: https://bids-standard.github.io/pybids/
- BIDS Validator: https://github.com/bids-standard/bids-validator
- BIDS Starter Kit: https://bids-standard.github.io/bids-starter-kit/
- BIDS Examples: https://github.com/bids-standard/bids-examples — canonical reference datasets for every BIDS modality; use as templates and test data
- HeuDiConv Docs: https://heudiconv.readthedocs.io/
- Original BIDS paper: Gorgolewski et al. (2016) Scientific Data, doi:10.1038/sdata.2016.44
Trigger Prompts & Evaluation Corpus
These evaluation prompts test that the agent correctly selects bids for relevant tasks and leaves it out for near misses.
Should trigger (3)
- should trigger
“How do I get all the T1w files for sub-03 out of my BIDS folder in Python?”
expects Uses PyBIDS BIDSLayout on the dataset root and calls layout.get() with subject='03', suffix='T1w' (and extension/return_type as needed). Shows how to get file paths and mentions that BIDSLayout indexes the dataset.
- should trigger
“I have DICOMs from a Siemens Prisma in sourcedata/dicom/sub-101/ses-1 with a T1 MPRAGE, two resting-state BOLD runs and an AP/PA spin-echo fieldmap pair. I ran dcm2bids_helper and now need a config so the output lands as sub-101_ses-1_task-rest_run-01_bold.nii.gz and so on, with the fieldmaps getting IntendedFor. The conversion keeps failing with 'No matching description' for the fieldmaps. What should I do?”
expects Explains the dcm2bids workflow: inspect the helper's tmp_dcm2bids/helper JSON sidecars, write config descriptions with datatype/suffix/criteria (SeriesDescription or ProtocolName) that match the fieldmap series, and set entities (dir-AP/PA) and IntendedFor/sidecar_changes. Mentions running dcm2bids with -d -p -s -c, then validating the result with the BIDS validator.
- should trigger
“I'm about to put my EEG study with 40 participants on OpenNeuro. Its folders and files are named in my own lab convention and I have no idea what metadata I need. What do I need to do first so it's accepted?”
expects Recommends restructuring into BIDS: sub-/ses-/eeg directories, BIDS filenames, dataset_description.json (Name, BIDSVersion), participants.tsv, README, and per-recording sidecars (TaskName, SamplingFrequency, EEGReference, PowerLineFrequency), channels.tsv and events.tsv. Then run the bids-validator, fix errors, and use .bidsignore for non-BIDS files.
Near misses (2)
- near miss
“I have Neuropixels 2.0 recordings in SpikeGLX format. How do I run Kilosort and compute unit quality metrics like ISI violations and amplitude cutoff?”
expects Recognizes this as extracellular Neuropixels spike sorting and QC analysis, not BIDS organization. It should use neuropixels-analysis (SpikeInterface/Kilosort, quality metrics) rather than the bids skill.
- near miss
“Write a Python script that loads my fMRI NIfTI file and runs a first-level GLM with nilearn, then plots a thresholded z-map.”
expects Provides nilearn FirstLevelModel code with design matrix and contrast computation, thresholding, and plotting. It does not need BIDS organization or validation tooling.