data_dir = fullfile(root_dir, 'demos', 'data');

templates_dir = fullfile(root_dir, 'templates');

partials_path = fullfile(root_dir, 'partials');

BIDS = bids.layout(fullfile(data_dir, 'ds000117'));

%% MRI

anat_metadata = bids.query(BIDS, 'metadata', ...
                           'modality', 'anat');

output = octache(fullfile(templates_dir, 'anat.mustache'), ...
                 'data', anat_metadata, ...
                 'partials_path', partials_path, ...
                 'partials_ext', 'mustache', ...
                 'warn', true, ...
                 'keep', true);

func_metadata = bids.query(BIDS, 'metadata', ...
                           'modality', 'func', ...
                           'suffix', 'bold', ...
                           'run', '01');

output = octache(fullfile(templates_dir, 'func.mustache'), ...
                 'data', func_metadata, ...
                 'partials_path', partials_path, ...
                 'partials_ext', 'mustache', ...
                 'warn', true, ...
                 'keep', true);

dwi_metadata = bids.query(BIDS, 'metadata', ...
                          'modality', 'dwi', ...
                          'suffix', 'dwi', ...
                          'extension', '.nii.gz');

output = octache(fullfile(templates_dir, 'dwi.mustache'), ...
                 'data', dwi_metadata, ...
                 'partials_path', partials_path, ...
                 'partials_ext', 'mustache', ...
                 'warn', true, ...
                 'keep', true);

%% MEG

meg_metadata = bids.query(BIDS, 'metadata', ...
                          'modality', 'meg', ...
                          'suffix', 'meg', ...
                          'run', '01');

output = octache(fullfile(templates_dir, 'meeg.mustache'), ...
                 'data', meg_metadata, ...
                 'partials_path', partials_path, ...
                 'partials_ext', 'mustache', ...
                 'warn', true, ...
                 'keep', true);
