|
20 | 20 | 1. Docker |
21 | 21 | 1. Install Docker |
22 | 22 | 1. From a terminal run `docker run -ti --rm -v /path/to/data:/data:ro bids/validator /data` |
| 23 | +1. Python Library: |
| 24 | + 1. Install [Python](https://www.python.org/) (works with python2 and python3) |
| 25 | + 1. Install [Pip](https://pip.pypa.io/en/stable/installing/) package manager for python, if |
| 26 | + not already installed. |
| 27 | + 1. From a terminal run `pip install bids_validator` to acquire the |
| 28 | + [BIDS Validator PyPi package](https://pypi.org/project/bids-validator/) |
| 29 | + 1. Open a Python terminal `python` |
| 30 | + 1. Import the BIDS Validator package `from bids_validator import BIDSValidator` |
| 31 | + 1. Check if a file is BIDS compatible `BIDSValidator().is_bids('path/to/a/bids/file')` |
23 | 32 |
|
24 | 33 | ## Support |
25 | 34 |
|
26 | 35 | The BIDS Validator is designed to work in both the browser and in Node.js. We |
27 | 36 | target support for the latest long term stable (LTS) release of Node.js and the |
28 | 37 | latest version of Chrome. |
29 | 38 |
|
| 39 | +There is also a library of helper functions written in Python, for use with BIDS |
| 40 | +compliant applications written in this language. |
| 41 | + |
30 | 42 | Please report any issues you experience while using these support targets. If |
31 | 43 | you experience issues outside of these supported environments and believe we |
32 | 44 | should extend our targeted support feel free to open a new issue describing the |
@@ -232,6 +244,26 @@ able to run `bids-validator /path/to/your/bids/directory` and see any validation |
232 | 244 | issues logged to the terminal. Run `bids-validator` without a directory path to |
233 | 245 | see available options. |
234 | 246 |
|
| 247 | +## Python Library |
| 248 | + |
| 249 | +There are is a limited library of helper functions written in Python. The main function |
| 250 | +determines if a file extension is compliant with the BIDS specification. You can find |
| 251 | +the available functions in the library, as well as their descriptions, |
| 252 | +[here](https://github.com/bids-standard/bids-validator/blob/master/bids-validator/bids_validator/bids_validator.py). |
| 253 | +To install, run `pip install bids_validator` (requires python and pip). |
| 254 | + |
| 255 | +#### Example |
| 256 | + |
| 257 | +``` |
| 258 | +>>> from bids_validator import BIDSValidator |
| 259 | +>>> validator = BIDSValidator() |
| 260 | +>>> filepaths = ["/sub-01/anat/sub-01_rec-CSD_T1w.nii.gz", "/sub-01/anat/sub-01_acq-23_rec-CSD_T1w.exe"] |
| 261 | +>>> for filepath in filepaths: |
| 262 | +>>> print( validator.is_bids(filepath) ) |
| 263 | +True |
| 264 | +False |
| 265 | +``` |
| 266 | + |
235 | 267 | ## Development |
236 | 268 |
|
237 | 269 | To develop locally, clone the project and run `yarn` from the project |
|
0 commit comments