Skip to content

Commit 4b25e21

Browse files
committed
update readme to include python library info
1 parent d93f054 commit 4b25e21

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

bids-validator/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,25 @@
2020
1. Docker
2121
1. Install Docker
2222
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')`
2332

2433
## Support
2534

2635
The BIDS Validator is designed to work in both the browser and in Node.js. We
2736
target support for the latest long term stable (LTS) release of Node.js and the
2837
latest version of Chrome.
2938

39+
There is also a library of helper functions written in Python, for use with BIDS
40+
compliant applications written in this language.
41+
3042
Please report any issues you experience while using these support targets. If
3143
you experience issues outside of these supported environments and believe we
3244
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
232244
issues logged to the terminal. Run `bids-validator` without a directory path to
233245
see available options.
234246

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+
235267
## Development
236268

237269
To develop locally, clone the project and run `yarn` from the project

0 commit comments

Comments
 (0)