Pydantic models for BIDS metadata
Project description
BIDS-pydantic-models
Overview
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.
Quickstart
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.
Installation
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 https://docs.python.org/3/installing/index.html
Python Version
We recommend using the latest version of Python. BIDS-pydantic supports Python 3.9 and newer.
Dependencies
These distributions will be installed automatically when installing BIDS-pydantic-models.
- pydantic - currently only compatible with v1
Usage
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
)
bids_metadata.LabelingDuration=1.0
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.
Acknowledgements
Conversion from schema to pydantic models is carried out using datamodel-code-generator. Data validation is performed using pydantic.
License
You can check out the full license here This project is licensed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file BIDS-pydantic-models-0.0.3.tar.gz
.
File metadata
- Download URL: BIDS-pydantic-models-0.0.3.tar.gz
- Upload date:
- Size: 59.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d36f819c2ef90e927096402e353f75abe07c90dac4b740eeb23053a71d2ebd9b |
|
MD5 | 437136b2443469ebfa38f4efe789ba31 |
|
BLAKE2b-256 | c70d38863e63aa543a33cfc1089a7681bac5eda0c3ed984c95b5d13cdb8c730a |
File details
Details for the file BIDS_pydantic_models-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: BIDS_pydantic_models-0.0.3-py3-none-any.whl
- Upload date:
- Size: 60.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02fac325e904849de0350d0c8c74126b65df34883ea1f33b70d76a5459578b6f |
|
MD5 | 9416a878858ead3860f91a8d98e70058 |
|
BLAKE2b-256 | e9f4b92f9f3d777c1dab7e09c8cc42e2c4a13430bda04ac73e94d29951518eda |