Skip to content

Commit

Permalink
update demo (#621)
Browse files Browse the repository at this point in the history
* update demo

* doc changes
  • Loading branch information
Remi-Gau authored Aug 22, 2023
1 parent 7abb241 commit eec8349
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 29 deletions.
4 changes: 3 additions & 1 deletion +bids/+util/create_participants_tsv.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@

%%

layout = bids.layout(layout_or_path, 'use_schema', use_schema);
layout = bids.layout(layout_or_path, ...
'use_schema', use_schema, ...
'index_dependencies', false);

if ~isempty(layout.participants)
msg = sprintf(['"participant.tsv" already exist for the following dataset. ', ...
Expand Down
13 changes: 10 additions & 3 deletions +bids/+util/download_ds.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@

verbose = args.Results.verbose;

source = args.Results.source;

demo = args.Results.demo;

out_path = args.Results.out_path;
if isempty(out_path)
out_path = fullfile(bids.internal.root_dir, 'demos');
out_path = fullfile(out_path, args.Results.source, args.Results.demo);
out_path = fullfile(out_path, source, demo);
end

% clean previous runs
Expand All @@ -96,7 +100,7 @@
end
bids.util.mkdir(out_path);

[URL] = get_URL(args.Results.source, args.Results.demo, verbose);
[URL] = get_URL(source, demo, verbose);
filename = bids.internal.download(URL, bids.internal.root_dir(), verbose);

% Unzipping dataset
Expand All @@ -109,9 +113,12 @@
print_to_screen(msg, verbose);

unzip(filename, out_path);
if strcmpi(source, 'spm') && strcmpi(demo, 'moae')
bids.util.create_participants_tsv(out_path);
end
delete(filename);

switch args.Results.demo
switch demo
case {'moae', 'facerep'}
case 'eeg'
copyfile(fullfile(bids.internal.root_dir, 'EEG', '*'), out_path);
Expand Down
64 changes: 39 additions & 25 deletions +bids/File.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%
% USAGE::
%
% file = bids.File(input, ...
% bf = bids.File(input, ...
% 'use_schema', false, ...
% 'tolerant', true,
% 'verbose', false);
Expand All @@ -30,7 +30,7 @@
% .. code-block:: matlab
%
% input = fullfile(pwd, 'sub-01_ses-02_T1w.nii');
% file = bids.File(input);
% bf = bids.File(input);
%
% Initialize with a structure
%
Expand All @@ -40,16 +40,16 @@
% 'suffix', 'T1w', ...
% 'entities', struct('sub', '01', ...
% 'ses', '02'));
% file = bids.File(input);
% bf = bids.File(input);
%
% Remove prefixes and add a ``desc-preproc`` entity-label pair.
%
% .. code-block:: matlab
%
% input = 'wuasub-01_ses-test_task-faceRecognition_run-02_bold.nii';
% file = bids.File(input, 'use_schema', false);
% file.prefix = '';
% file.entities.desc = 'preproc';
% bf = bids.File(input, 'use_schema', false);
% bf.prefix = '';
% bf.entities.desc = 'preproc';
% disp(file.filename)
%
% Use the BIDS schema to get entities in the right order.
Expand All @@ -63,19 +63,20 @@
% 'run', '02', ...
% 'task', 'face recognition');
%
% file = bids.File(name_spec, 'use_schema', true);
% bf = bids.File(name_spec, 'use_schema', true);
%
% Load metadata (supporting inheritance).
%
% .. code-block:: matlab
%
% f = bids.File('tests/data/synthetic/sub-01/anat/sub-01_T1w.nii.gz');
% bf = bids.File('tests/data/synthetic/sub-01/anat/sub-01_T1w.nii.gz');
%
% Access metadata
%
% .. code-block:: matlab
%
% f.metadata()
% bf.metadata()
%
% struct with fields:
% Manufacturer: 'Siemens'
% FlipAngle: 10
Expand All @@ -85,24 +86,30 @@
% .. code-block:: matlab
%
% % Adding new value
% f = f.metadata_add('NewField', 'new value');
% f.metadata()
%
% bf = bf.metadata_add('NewField', 'new value');
% bf.metadata()
%
% struct with fields:
% manufacturer: 'siemens'
% flipangle: 10
% NewField: 'new value'
%
% % Appending to existing value
% f = f.metadata_append('NewField', 'new value 1');
% f.metadata()
%
% bf = bf.metadata_append('NewField', 'new value 1');
% bf.metadata()
%
% struct with fields:
% manufacturer: 'siemens'
% flipangle: 10
% NewField: {'new value'; 'new value 1'}
%
% % Removing value
% f = f.metadata_remove('NewField');
% f.metadata()
%
% bf = bf.metadata_remove('NewField');
% bf.metadata()
%
% struct with fields:
% manufacturer: 'siemens'
% flipangle: 10
Expand All @@ -111,10 +118,11 @@
%
% .. code-block:: matlab
%
% f = f.metadata_update('Description', 'source file', ...
% bf = bf.metadata_update('Description', 'source file', ...
% 'NewField', 'new value', ...
% 'manufacturer', []);
% f.metadata()
% bf.metadata()
%
% struct with fields:
% flipangle: 10
% description: 'source file'
Expand All @@ -124,7 +132,9 @@
%
% .. code-block:: matlab
%
% f.metadata_write()
% bf.metadata_write()
%
%

% (C) Copyright 2021 BIDS-MATLAB developers

Expand Down Expand Up @@ -811,12 +821,14 @@ function check_required_entities(obj)
end

function out_file = metadata_write(obj, varargin)
% Export current content of metadata to sidecar json with
% same name as current file. Metadata fields can be modified
% with new values passed in varargin, which can be either a structure,
% or pairs of key-values. These modifications do not affect
% current File object, and only exported into file. Use
% bids.File.metadata_update to update current metadata.
% Export current content of metadata to sidecar json
% with same name as current file.
%
% Metadata fields can be modified with new values passed in varargin,
% which can be either a structure, or pairs of key-values.
% These modifications do not affect current File object,
% and only exported into file.
% Use bids.File.metadata_update to update current metadata.
% Returns full path to the exported sidecar json file.
%
% See also
Expand All @@ -826,7 +838,9 @@ function check_required_entities(obj)
%
% f.metadata_write(key1, value1, key2, value2);
% f.metadata_write(struct(key1, value1, ...
% key2, value2));
% key2, value2));
%

[path, ~, ~] = fileparts(obj.path);
out_file = fullfile(path, obj.json_filename);

Expand Down
1 change: 1 addition & 0 deletions demos/spm/facerep/code/convert_facerep_ds.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
create_changelog(output_dir);
create_datasetdescription(output_dir, opt);
create_bold_json(output_dir, task_name, repetition_time, nb_slices, echo_time, opt);
bids.util.create_participants_tsv(output_dir);

end

Expand Down

0 comments on commit eec8349

Please sign in to comment.