Using the BIDS schema¶
- class +bids.Schema(use_schema)¶
Class to interact with the BIDS schema
USAGE:
schema = bids.Schema(use_schema)
use_schema: logical
- Schema(use_schema)¶
USAGE:
schema = bids.Schema(use_schema)
use_schema: logical
- load(use_schema)¶
Loads schema
USAGE:
schema = bids.Schema() schema = schema.load()
- return_modalities(subject, modality_group)¶
Return the datatypes for a given for a given modality group for a given subject. For example, “mri” will give: “func”, “anat”, “dwi”, “fmap”…
USAGE:
modalities = schema.return_modalities(subject, modality_group)
- Parameters:
subject (
struct
) – Subject information:subject.path
, … Seeparse_subject
subfunction for layout.m for details.modality_group (
char
) – Any of the BIDS modality
If we go schema-less, we list directories in the subject/session folder as proxy of the datatypes that we have to parse.
- entity_order(varargin)¶
Returns the ‘correct’ order for entities of entity list. If there are non BIDS entities they are added after the BIDS ones in alphabetical order.
USAGE:
order = schema.entity_order(entity_list)
EXAMPLE:
schema = bids.Schema(); % get the order of all the BIDS entities order = schema.entity_order() % reorder typical BIDS entities entity_list_to_order = {'description' 'run' 'subject'}; order = schema.entity_order(entity_list_to_order) {'subject' 'run' 'description'}; % reorder non-BIDS and typical BIDS entities entity_list_to_order = {'description' 'run' 'foo' 'subject'}; order = schema.entity_order(entity_list_to_order) {'subject' 'run' 'description' 'foo'};
- return_entity_key(entity)¶
Returns the key of an entity
USAGE:
key = schema.return_entity_key(entity)
EXAMPLE:
key = schema.return_entity_key('description') 'desc'
- return_modality_groups()¶
USAGE:
groups = schema.return_modality_groups()
Returns a dummy variable if we go schema less
- list_suffix_groups(datatype, scope)¶
creates a structure of all the suffix group of a datatype
USAGE:
suffix_groups = schema.list_suffix_groups(datatype, scope)
- Parameters:
datatype (
char
) – for example'func'
scope (
char
) –'raw'
or'derivatives'
or'all'
- return_suffix_groups_for_datatype(datatype)¶
returns a structure of all the suffix group of a datatype
USAGE:
suffix_groups = schema.return_suffix_groups_for_datatype(datatype)
- Parameters:
datatype (
char
) –
EXAMPLE:
suffix_groups = schema.return_suffix_groups_for_datatype('func')
- return_entities_for_suffix_group(suffix_group)¶
entities are returned in the expected order according to the schema
USAGE:
entities = schema.return_entities_for_suffix_group(suffix_group)
- Parameters:
suffix_group (
struct
) –
EXAMPLE:
suffix_groups = return_suffix_groups_for_datatype(obj, datatype) entities = schema.return_entities_for_suffix_group(suffix_groups(1))
- required_entities_for_suffix_group(this_suffix_group)¶
Returns a logical vector to track which entities of a suffix group are required in the bids schema
- Parameters:
this_suffix_group (
struct
) –
USAGE:
required_entities = schema.required_entities_for_suffix_group(this_suffix_group)
- find_suffix_group(modality, suffix)¶
For a given sufffix and modality, this returns the “suffix group” this suffix belongs to
- Parameters:
modality (
char
) –suffix (
char
) –
USAGE:
suffix_group = schema.find_suffix_group(modality, suffix)
EXAMPLE:
schema = bids.Schema(); suffix_group = schema.find_suffix_group('anat', 'T1w'); suffix_group 'nonparametric'
- return_datatypes_for_suffix(suffix)¶
For a given suffix, returns all the possible datatypes that have this suffix.
- Parameters:
suffix (
char
) –
EXAMPLE:
schema = bids.Schema(); datatypes = schema.return_datatypes_for_suffix('bold'); assertEqual(datatypes, {'func'});
- return_entities_for_suffix_modality(suffix, modality)¶
returns the list of entities for a given suffix of a given modality
- Parameters:
modality (
char
) –suffix (
char
) –
USAGE:
[entities, required] = schema.return_entities_for_suffix_modality(suffix, modality)
- return_modality_suffixes_regex(modality)¶
creates a regular expression of suffixes for a given imaging modality
- Parameters:
modality (
char
) –
USAGE:
reg_ex = schema.return_modality_suffixes_regex(modality)
- return_modality_extensions_regex(modality)¶
creates a regular expression of extensions for a given imaging modality
- Parameters:
modality (
char
) –
USAGE:
reg_ex = schema.return_modality_extensions_regex(modality)
- return_modality_regex(modality)¶
creates a regular expression of suffixes and extension for a given imaging modality
- Parameters:
modality (
char
) –
USAGE:
reg_ex = schema.return_modality_regex(modality)
- get_definition(word)¶
finds definition of a column header in a the BIDS schema
USAGE:
[def, status] = schema.get_definition(word)
- static ci_check(variable_to_check)¶
Mostly to avoid some crash in continuous integration