BIDS stats model handling¶
See the BIDS stats model website for more information.
- class +bids.Model(varargin)¶
Class to deal with BIDS stats models
See the BIDS stats model website for more information.
USAGE:
bm = bids.Model('init', true, ... 'file', path_to_bids_stats_model_file, ... 'tolerant', true, 'verbose', false);
- Parameters:
init (
logical
) – iftrue
this will initialize an empty model. Defaults tofalse
.file (
path
) – fullpath the JSON file containing the BIDS stats modeltolerant (
logical
) – turns errors into warningverbose (
logical
) – silences warnings
EXAMPLE:
% initialize and write an empty model bm = bids.Model('init', true); filename = fullfile(pwd, 'model-foo_smdl.json'); bm.write(filename);
EXAMPLE:
% load a stats model from a file model_file = fullfile(get_test_data_dir(), ... '..', ... 'data', ... 'model', ['model-narps_smdl.json']); bm = bids.Model('file', model_file, 'verbose', false);
- content = "''"¶
“raw” content of a loaded JSON
- Name = "'REQUIRED'"¶
Name of the model
- Description = "'RECOMMENDED'"¶
Description of the model
- BIDSModelVersion = "'1.0.0'"¶
Version of the model
- Input = "'REQUIRED'"¶
Input of the model
- Nodes = "{'REQUIRED'}"¶
Nodes of the model
- Edges = '{}'¶
Edges of the model
- tolerant = 'true'¶
if
true
turns error into warning
- verbose = 'true'¶
hides warning if
false
- get_nodes(varargin)¶
Get a specific node from the model given its Level and / or Name.
USAGE:
[value, idx] = bm.get_nodes('Level', '', 'Name', '')
- Parameters:
Level – Must be one of
Run
,Session
,Subject
,Dataset
. Default to''
Name – Default to
''
- Returns: value - Node(s) as struct if there is only one or a cell if more
idx - Node index
EXAMPLE:
bm = bids.Model('file', model_file('narps'), 'verbose', false); % Get all nodes bm.get_nodes() % Get run level node bm.get_nodes('Level', 'Run') % Get the "Negative" node bm.get_nodes('Name', 'negative')
- get_edge(field, value)¶
USAGE:
edge = bm.get_edges(field, value)
field can be any of {‘Source’, ‘Destination’}
- get_edges_from_nodes()¶
Generates all the default edges from the list of nodes in the model.
USAGE:
bm = bm.get_edges_from_nodes(); edges = bm.Edges();
- validate()¶
Very light validation of fields that were not checked on loading. Automatically run on loaoding of a dataset.
USAGE:
bm.validate()
- validate_edges()¶
USAGE:
bm.validate_edges()
- get_transformations(varargin)¶
USAGE:
transformations = bm.get_transformations('Name', 'node_name')
- Parameters:
Name (
char
) – name of the node whose transformations we want
- get_dummy_contrasts(varargin)¶
USAGE:
dummy_contrasts = bm.get_dummy_contrasts('Name', 'node_name')
- Parameters:
Name (
char
) – name of the node whose dummy contrasts we want
- get_contrasts(varargin)¶
USAGE:
contrasts = bm.get_contrasts('Name', 'node_name')
- Parameters:
Name (
char
) – name of the node whose contrasts we want
- get_model(varargin)¶
USAGE:
model = bm.get_model('Name', 'node_name')
- Parameters:
Name (
char
) – name of the node whose model we want
- get_design_matrix(varargin)¶
USAGE:
matrix = bm.get_design_matrix('Name', 'node_name')
- Parameters:
Name (
char
) – name of the node whose model matrix we want
- default(varargin)¶
Generates a default BIDS stats model for a given data set
USAGE:
bm = bm.default(BIDS, tasks)
- Parameters:
BIDS (
path or structure
) – fullpath to a BIDS dataset or output structure frombids.layout
tasks (
char or cellstr
) – tasks to include in the model
EXAMPLE:
pth_bids_example = get_test_data_dir(); BIDS = bids.layout(fullfile(pth_bids_example, 'ds003')); bm = bids.Model(); bm = bm.default(BIDS, 'rhymejudgement'); filename = fullfile(pwd, 'model-rhymejudgement_smdl.json'); bm.write(filename);
- update()¶
Update
content
for writingUSAGE:
bm = bm.update()
- write(filename)¶
USAGE:
bm.write(filename)
- static empty_node(level)¶
USAGE:
node = Model.empty_node('run')
- static empty_transformations()¶
USAGE:
transformations = Model.empty_transformations()
- static empty_model()¶
USAGE:
model = Model.empty_model()