Using the BIDS schema
- class bids.Schema
Class to interact with the BIDS schema
USAGE:
schema = bids.Schema(use_schema)
use_schema: logical
- Constructor Summary
- Schema(use_schema)
USAGE:
schema = bids.Schema(use_schema)
use_schema: logical
- Method Summary
- load(use_schema)
Load schema.
USAGE:
schema = bids.Schema() schema = schema.load()
- return_entities(varargin)
Return all the entities for or one or more datatype and one or more suffixes.
USAGE:
entities = schema.return_entities('datatypes', datatypes, ... 'suffixes', suffixes, ... 'required_only', false)
- Parameters:
datatypes (
char or cellstr
) – For example'func'
.suffixes (
char or cellstr
) – For example'bold'
.required_only (
logical
) – If true, only the required entities are returned.
Example
suffixes = schema.return_entities('datatypes', 'func') suffixes = schema.return_entities('datatypes', 'func', 'suffixes', 'bold') suffixes = schema.return_suffixes('datatypes', {'anat', 'func'}, ... 'suffixes', {'T1w', 'bold'}, ... 'required_only', true)
- 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)
Return 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, 'use_short_form', true)
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_name(entity_key)
Return the name of an entity key.
USAGE:
entity_name = schema.return_entity_key(entity_key)
Example
key = schema.return_entity_key('desc') 'description' key = schema.return_entity_key({'desc', 'sub'}) {'description'; 'subject'}
- return_entity_key(entity_names)
Return 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)
Return a logical vector to track which entities of a suffix group are required in the bids schema.
USAGE:
required_entities = schema.required_entities_for_suffix_group(this_suffix_group)
- Parameters:
this_suffix_group (
struct
)
- find_suffix_group(modality, suffix)
For a given sufffix and modality, this return the “suffix group” this suffix belongs to.
USAGE:
suffix_group = schema.find_suffix_group(modality, suffix)
- Parameters:
modality (
char
)suffix (
char
)
Example
schema = bids.Schema(); suffix_group = schema.find_suffix_group('anat', 'T1w'); suffix_group 'nonparametric'
- return_suffixes(varargin)
Return all the suffixes for or one or more datatype.
USAGE:
suffixes = schema.return_suffixes('datatypes', datatypes)
Example
suffixes = schema.return_suffixes('datatypes', 'func') suffixes = schema.return_suffixes('datatypes', {'anat', 'func'})
- 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
USAGE:
[entities, required] = schema.return_entities_for_suffix_modality(suffix, modality)
- Parameters:
modality (
char
)suffix (
char
)
- return_modality_suffixes_regex(modality)
creates a regular expression of suffixes for a given imaging modality
USAGE:
reg_ex = schema.return_modality_suffixes_regex(modality)
- Parameters:
modality (
char
)
- return_modality_extensions_regex(modality)
creates a regular expression of extensions for a given imaging modality
USAGE:
reg_ex = schema.return_modality_regex(modality)
- Parameters:
modality (
char
)
- return_modality_regex(modality)
creates a regular expression of suffixes and extension for a given imaging modality
- Parameters:
modality (
char
)
- 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