Skip to main content

Pydantic models for BIDS metadata

Project description



BIDS-pydantic-models is a series of pydantic models which validate against versions of the BIDS metadata schema which is used in the JSON BIDS sidecar, from the official BIDS GitHub page

Each model is created using BIDS-pydantic.

Table of Contents

How To Contribute

Got a great idea for something to implement in BIDS-pydantic, or maybe you have just found a bug? Create an issue to get in touch with the development team and we’ll take it from there.


If you just want to use the models in your project. Download the pydantic models file for the BIDS schema version you wish to use from the models directory, and add it to your code-base. These files are generated using the bids-pydantic make -a command (see below).

If you want to use the command line tool to generate the models, keep reading this README.


Install with:

$ pip install bids-pydantic-models

BIDS-pydantic-models can be installed as a module directly from the python package index. For more information how to use a python package in this way please see

Python Version

We recommend using the latest version of Python. BIDS-pydantic supports Python 3.9 and newer.


These distributions will be installed automatically when installing BIDS-pydantic-models.

  • pydantic - currently only compatible with v1


Just import the model you want to use:

from bids_pydantic_models.bids_metadata_v1_7_0 import BidsMetadata

then use the class as you would with any other pydantic model. For example:

bids_metadata = BidsMetadata(
    EchoTime=5.0, BolusCutOffFlag=True

with open("bids_metadata.json", "w") as f:
    f.write(bids_metadata.json(indent=4, exclude_unset=True))

For more information, reference the pydantic documentation

Currently supported schema versions are:

  • v1.7.0
  • v1.8.0

NOTE: the model files in the Git repository may not correspond directly with those that are installed using pip. This is due to the fact that the models are auto-generated by GSPs CI/CD system. However, version information is always displayed at the top of the model files.


Conversion from schema to pydantic models is carried out using datamodel-code-generator. Data validation is performed using pydantic.


You can check out the full license here This project is licensed under the terms of the MIT license.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

BIDS-pydantic-models-0.0.3.tar.gz (59.1 kB view hashes)

Uploaded Source

Built Distribution

BIDS_pydantic_models-0.0.3-py3-none-any.whl (60.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page