bids.layout.BIDSValidator

class BIDSValidator(index_associated=True)[source]

An object for BIDS (Brain Imaging Data Structure) verification in a data.

The main method of this class is is_bids(). You should use it for checking whether a file path compatible with BIDS.

Parameters:index_associated (bool, default: True) – Specifies if an associated data should be checked. If it is true then any file paths in directories code/, derivatives/, sourcedata/ and stimuli/ will pass the validation, else they won’t.

Examples

>>> from bids.grabbids import BIDSValidator
>>> validator = BIDSValidator()
>>> filepaths = ["/sub-01/anat/sub-01_rec-CSD_T1w.nii.gz",
>>> "/sub-01/anat/sub-01_acq-23_rec-CSD_T1w.exe", #wrong extension
>>> "/participants.tsv"]
>>> for filepath in filepaths:
>>>     print( validator.is_bids(filepath) )
True
False
True

Methods

get_path_values(path) Takes a file path and returns values found for the following path keys: sub- ses-
is_associated_data(path) Check if file is appropriate associated data.
is_bids(path) Checks if a file path appropriate for BIDS.
is_file(path) Check if file is phenotypic data.
is_phenotypic(path) Check if file is phenotypic data.
is_session_level(path) Check if the file has appropriate name for a session level.
is_subject_level(path) Check if the file has appropriate name for a subject level.
is_top_level(path) Check if the file has appropriate name for a top-level file.
conditional_match  
get_regular_expressions  
get_path_values(path)[source]

Takes a file path and returns values found for the following path keys:

sub- ses-
is_associated_data(path)[source]

Check if file is appropriate associated data.

is_bids(path)[source]

Checks if a file path appropriate for BIDS.

Main method of the validator. uses other class methods for checking different aspects of the file path.

Parameters:path (string) – A path of a file you want to check.

Examples

>>> from bids.grabbids import BIDSValidator
>>> validator = BIDSValidator()
>>> validator.is_bids("/sub-01/ses-test/anat/sub-01_ses-test_rec-CSD_run-23_T1w.nii.gz")
True
>>> validator.is_bids("/sub-01/ses-test/sub-01_run-01_dwi.bvec") # missed session in the filename
False
is_file(path)[source]

Check if file is phenotypic data.

is_phenotypic(path)[source]

Check if file is phenotypic data.

is_session_level(path)[source]

Check if the file has appropriate name for a session level.

is_subject_level(path)[source]

Check if the file has appropriate name for a subject level.

is_top_level(path)[source]

Check if the file has appropriate name for a top-level file.