Back to Claude Scientific Skills

BIDS Specification Reference

scientific-skills/bids/references/bids_specification.md

2.39.08.2 KB
Original Source

BIDS Specification Reference

Note: The canonical, machine-readable source of truth is bids_schema.json (in this directory), exported from the BIDS Schema. The tables below are a human-readable summary. When the two disagree, trust the schema.

Entity Table

Complete list of BIDS entities, their keys, and where they apply. Rows are listed in the required filename ordering — entities must appear in this order in BIDS filenames. This order is defined in the schema at rules.entities (see bids_schema.json).

#EntityKeyFormatApplies to
1Subjectsub-<label> (alphanumeric)All files (required)
2Templatetpl-<label>derivatives (template-based)
3Sessionses-<label>All datatypes
4Cohortcohort-<label>derivatives (template cohorts)
5Samplesample-<label>microscopy
6Tasktask-<label>func, eeg, meg, ieeg, beh, pet, nirs, motion
7Tracking systemtracksys-<label>motion
8Acquisitionacq-<label>All datatypes
9Nucleusnuc-<label>MR spectroscopy
10Volumevoi-<label>MR spectroscopy
11Contrast enhancing agentce-<label>anat
12Tracertrc-<label>pet
13Stainstain-<label>microscopy
14Reconstructionrec-<label>anat, func, pet
15Directiondir-<label>fmap, dwi, perf, func
16Runrun-<index> (integer)All datatypes
17Modalitymod-<label>fieldmaps
18Echoecho-<index>func, fmap
19Flipflip-<index>anat (quantitative MRI)
20Inversioninv-<index>anat (quantitative MRI)
21Magnetization transfermt-on/offanat (quantitative MRI)
22Partpart-mag/phase/real/imaganat, func
23Processingproc-<label>eeg, meg, ieeg
24Hemispherehemi-L/Rderivatives (surface data)
25Spacespace-<label>derivatives
26Splitsplit-<index>func, dwi, eeg, meg, ieeg
27Recordingrecording-<label>physio, stim, eeg, meg
28Chunkchunk-<index>large files split across chunks
29Atlasatlas-<label>derivatives (atlas-based)
30Segmentationseg-<label>derivatives
31Scalescale-<label>derivatives
32Resolutionres-<label>derivatives
33Densityden-<label>derivatives (surface meshes)
34Labellabel-<label>derivatives (segmentation labels)
35Descriptiondesc-<label>derivatives only

Datatypes (Top-Level Directories)

DatatypeDescriptionCommon Suffixes
anatStructural MRIT1w, T2w, FLAIR, T2star, inplaneT1, inplaneT2, PDw, T1map, T2map, T1rho, UNIT1, MP2RAGE, MTR, MTS
funcFunctional MRIbold, cbv, sbref
dwiDiffusion-weighted imagingdwi, sbref
fmapFieldmapsphasediff, phase1, phase2, magnitude1, magnitude2, fieldmap, epi
perfPerfusion imaging (ASL)asl, m0scan, aslcontext
eegElectroencephalographyeeg, channels, electrodes, events, coordsystem
megMagnetoencephalographymeg, channels, coordsystem, events, headshape
ieegIntracranial EEGieeg, channels, electrodes, events, coordsystem
petPositron Emission Tomographypet, blood
micrMicroscopy2PE, BF, CARS, CONF, DIC, DF, FLUO, MPE, NLO, OCT, PC, PLI, SRS, TL
behBehavioral data (no imaging)events, beh, physio, stim
motionMotion capturemotion, channels, events
nirsNear-infrared spectroscopynirs, channels, optodes, coordsystem, events

File Extensions

ExtensionDescription
.nii.gzCompressed NIfTI (standard for MRI/fMRI/DWI)
.niiUncompressed NIfTI
.jsonJSON sidecar metadata
.tsvTab-separated values (events, participants, etc.)
.bvecb-vectors (DWI gradient directions)
.bvalb-values (DWI gradient strengths)
.edfEuropean Data Format (EEG)
.bdfBioSemi Data Format (EEG)
.vhdr/.vmrk/.eegBrainVision format (EEG)
.setEEGLAB format (EEG)
.fifElekta/MEGIN format (MEG)
.dsCTF dataset (MEG)
.sqd/.conKIT/Yokogawa (MEG)

Required Files

Dataset-level (always required)

  • dataset_description.json
  • README or README.md
  • CHANGES
  • participants.tsv + participants.json
  • LICENSE
  • sub-<label>/[ses-<label>/]sub-<label>[_ses-<label>]_scans.tsv - per-run acquisition metadata

Modality-specific required files

  • func/bold: corresponding _events.tsv for task data; TaskName in JSON sidecar
  • dwi: .bvec and .bval files
  • eeg/meg/ieeg: _channels.tsv, _events.tsv
  • perf/asl: _aslcontext.tsv

Directory Structure Rules

  1. Subject directories are named sub-<label> and sit at dataset root
  2. Session directories ses-<label> are optional; if used, must be used for ALL subjects
  3. Datatype directories (anat/, func/, etc.) sit inside subject (or session) directories
  4. sourcedata/ stores raw unprocessed data (DICOM, etc.) - not validated
  5. derivatives/ stores processed outputs - each pipeline in its own subdirectory
  6. code/ stores analysis scripts
  7. stimuli/ stores stimulus files used during acquisition
  8. phenotype/ stores questionnaire/behavioral data not tied to specific imaging

Metadata Inheritance

JSON metadata cascades from higher to lower directories. If the same key appears at multiple levels, the most specific (closest to the data file) wins.

Resolution order (highest priority first):

  1. File-level sidecar: sub-01/func/sub-01_task-rest_bold.json
  2. Subject-level sidecar: sub-01/sub-01_task-rest_bold.json
  3. Dataset-level sidecar: task-rest_bold.json

This avoids duplicating metadata that is constant across subjects (e.g., RepetitionTime, TaskName).

Standard Template Spaces

Common space- values used in derivatives:

Space LabelDescription
MNI152NLin2009cAsymMNI 2009c nonlinear asymmetric (fMRIPrep default)
MNI152NLin6AsymMNI 6th-generation nonlinear asymmetric (FSL default)
MNI152LinMNI linear registration
MNIPediatricAsymPediatric MNI templates
T1wIndividual subject's T1w native space
fsnativeFreeSurfer individual surface space
fsaverageFreeSurfer average surface (164k vertices)
fsaverage5FreeSurfer average surface (10k vertices)
fsaverage6FreeSurfer average surface (40k vertices)
fsLRHCP fs_LR surface space
OASIS30ANTsOASIS-30 ANTs template
UNCInfantUNC infant templates

Full list managed by TemplateFlow: https://www.templateflow.org/

Specification Changelog (Selected)

VersionKey Changes
1.10.0Motion capture modality; refined derivative entity rules
1.9.0NIRS modality; Python-based validator reference implementation
1.8.0Microscopy modality; chunk- entity for large files
1.7.0PET modality fully specified
1.6.0EEG/MEG/iEEG matured; _coordsystem.json
1.5.0Genetic descriptors; ASL perfusion
1.4.0dataset_description.json expanded; derivatives framework
1.0.0Initial release: MRI only (anat, func, dwi, fmap)

Entity Label Rules

  • Labels (<label>): alphanumeric only, no special characters, no leading zeros (except run-)
  • Indices (<index>): non-negative integers, zero-padded to equal width within a dataset (e.g., run-01, run-02)
  • Subject labels: typically numeric (01, 02) but can be alphanumeric (CON01, PAT01)
  • Session labels: descriptive (pre, post, baseline, followup) or numeric
  • Task labels: brief, descriptive, no spaces (rest, nback, faces, gonogo)