# Brain Imaging Data Structure

The Brain Imaging Data Structure (BIDS) is a simple and intuitive way to organise and describe neuroimaging and behavioural data.

### Standard specification

* Current release
* Current draft

### Validator

* BIDS Validator: online or from the command line bids-validator.

### Discussion Forums

* Google Groups
* NeuroStars

### Tutorials

* BIDS Examples
* BIDS Starter Kit

### Publications

The brain imaging data structure, a format for organizing and describing outputs of neuroimaging experiments. Gorgolewski K.J., Auer T., Calhoun V.D., Craddock R.C., Das S., Duff E.P., Flandin G., Ghosh S.S., Glatard T., Halchenko Y.O., Handwerker D.A., Hanke M., Keator D., Li X., Michael Z., Maumet C., Nichols B.N., Nichols T.E., Pellman J., Poline J.-B., Rokem A., Schaefer G., Sochat V., Triplett W., Turner J.A., Varoquaux G. & Poldrack R.A. Scientific Data 3, 160044 (2016).
BIDS apps: Improving ease of use, accessibility, and reproducibility of neuroimaging data analysis methods. Gorgolewski K.J., Alfaro-Almagro F., Auer T., Bellec P., Capota M., Chakravarty M.M., Churchill N.W., Cohen A.L., Craddock R.C., Devenyi G.A., Eklund A., Esteban O., Flandin G., Ghosh S.S., Guntupalli J.S., Jenkinson M., Keshavan A., Kiar G., Liem F., Raamana P.R., Raffelt D., Steele C.J., Quirion P.-O., Smith R.E., Strother S.C., Varoquaux G., Wang Y., Yarkoni T. & Poldrack R.A. PLoS Computational Biology 13(3):e1005209 (2017).
MEG-BIDS, the brain imaging data structure extended to magnetoencephalography. Niso G., Gorgolewski K.J., Bock E., Brooks T.L., Flandin G., Gramfort A., Henson R.N., Jas M., Litvak V., Moreau J.T., Oostenveld R., Schoffelen J.-M., Tadel F., Wexler J. & Baillet S. Scientific Data 5, 180110 (2018).
EEG-BIDS, an extension to the brain imaging data structure for electroencephalography. Pernet C.R., Appelhoff S., Gorgolewski K.J., Flandin G., Phillips C., Delorme A. & Oostenveld R. Scientific Data 6, 103 (2019) .

## BIDS Tools in SPM/MATLAB

SPM provides a number of functionalities (MATLAB/Octave functions) to facilitate the creation or use of datasets formatted according to BIDS.

### JSON files

A JSON file can be read/written using spm_jsonread and spm_jsonwrite.
These functions are also independently available in JSONio, a JSON library for MATLAB and Octave. They are compatible with MATLAB's jsonencode and jsondecode.

### TSV files

A tab-separated values (TSV) file can be read/written using spm_load and spm_save.
These functions are compatible with MATLAB table array and handle gzip compression transparently.

### NIfTI files

NIfTI files can be read/written using spm_vol or @nifti.
By default, SPM does not support compressed NIfTI files (.nii.gz) but MATLAB/Octave provide gzip/gunzip functions if needed and they are also available through the batch interface from BasicIO > File Operations > Gunzip Files.

### BIDS parser and queries

A data directory organised according to BIDS can be parsed with spm_BIDS.
Here is an example using the ds007 dataset:

### Formatting datasets into BIDS

Helper functions spm_mkdir and spm_copy might come handy, as well as previously mentionned spm_save and spm_jsonwrite.
For example, the following piece of code using spm_mkdir:
creates this directory hierarchy:
while spm_copy makes it easier to copy files and their attached metadata (e.g. sidecar JSON files) with compression on the fly.
See also these options in the batch interface:
* The DICOM Import batch module has an option to create metadata sidecar JSON files:
* The 3D to 4D File Conversion batch module has an option to store the TR in the NIfTI header:

## See also

SPM BIDS-App