Skip to content

Commit eec8349

Browse files
authored
update demo (#621)
* update demo * doc changes
1 parent 7abb241 commit eec8349

File tree

4 files changed

+53
-29
lines changed

4 files changed

+53
-29
lines changed

+bids/+util/create_participants_tsv.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@
4848

4949
%%
5050

51-
layout = bids.layout(layout_or_path, 'use_schema', use_schema);
51+
layout = bids.layout(layout_or_path, ...
52+
'use_schema', use_schema, ...
53+
'index_dependencies', false);
5254

5355
if ~isempty(layout.participants)
5456
msg = sprintf(['"participant.tsv" already exist for the following dataset. ', ...

+bids/+util/download_ds.m

+10-3
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,14 @@
7575

7676
verbose = args.Results.verbose;
7777

78+
source = args.Results.source;
79+
80+
demo = args.Results.demo;
81+
7882
out_path = args.Results.out_path;
7983
if isempty(out_path)
8084
out_path = fullfile(bids.internal.root_dir, 'demos');
81-
out_path = fullfile(out_path, args.Results.source, args.Results.demo);
85+
out_path = fullfile(out_path, source, demo);
8286
end
8387

8488
% clean previous runs
@@ -96,7 +100,7 @@
96100
end
97101
bids.util.mkdir(out_path);
98102

99-
[URL] = get_URL(args.Results.source, args.Results.demo, verbose);
103+
[URL] = get_URL(source, demo, verbose);
100104
filename = bids.internal.download(URL, bids.internal.root_dir(), verbose);
101105

102106
% Unzipping dataset
@@ -109,9 +113,12 @@
109113
print_to_screen(msg, verbose);
110114

111115
unzip(filename, out_path);
116+
if strcmpi(source, 'spm') && strcmpi(demo, 'moae')
117+
bids.util.create_participants_tsv(out_path);
118+
end
112119
delete(filename);
113120

114-
switch args.Results.demo
121+
switch demo
115122
case {'moae', 'facerep'}
116123
case 'eeg'
117124
copyfile(fullfile(bids.internal.root_dir, 'EEG', '*'), out_path);

+bids/File.m

+39-25
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
%
55
% USAGE::
66
%
7-
% file = bids.File(input, ...
7+
% bf = bids.File(input, ...
88
% 'use_schema', false, ...
99
% 'tolerant', true,
1010
% 'verbose', false);
@@ -30,7 +30,7 @@
3030
% .. code-block:: matlab
3131
%
3232
% input = fullfile(pwd, 'sub-01_ses-02_T1w.nii');
33-
% file = bids.File(input);
33+
% bf = bids.File(input);
3434
%
3535
% Initialize with a structure
3636
%
@@ -40,16 +40,16 @@
4040
% 'suffix', 'T1w', ...
4141
% 'entities', struct('sub', '01', ...
4242
% 'ses', '02'));
43-
% file = bids.File(input);
43+
% bf = bids.File(input);
4444
%
4545
% Remove prefixes and add a ``desc-preproc`` entity-label pair.
4646
%
4747
% .. code-block:: matlab
4848
%
4949
% input = 'wuasub-01_ses-test_task-faceRecognition_run-02_bold.nii';
50-
% file = bids.File(input, 'use_schema', false);
51-
% file.prefix = '';
52-
% file.entities.desc = 'preproc';
50+
% bf = bids.File(input, 'use_schema', false);
51+
% bf.prefix = '';
52+
% bf.entities.desc = 'preproc';
5353
% disp(file.filename)
5454
%
5555
% Use the BIDS schema to get entities in the right order.
@@ -63,19 +63,20 @@
6363
% 'run', '02', ...
6464
% 'task', 'face recognition');
6565
%
66-
% file = bids.File(name_spec, 'use_schema', true);
66+
% bf = bids.File(name_spec, 'use_schema', true);
6767
%
6868
% Load metadata (supporting inheritance).
6969
%
7070
% .. code-block:: matlab
7171
%
72-
% f = bids.File('tests/data/synthetic/sub-01/anat/sub-01_T1w.nii.gz');
72+
% bf = bids.File('tests/data/synthetic/sub-01/anat/sub-01_T1w.nii.gz');
7373
%
7474
% Access metadata
7575
%
7676
% .. code-block:: matlab
7777
%
78-
% f.metadata()
78+
% bf.metadata()
79+
%
7980
% struct with fields:
8081
% Manufacturer: 'Siemens'
8182
% FlipAngle: 10
@@ -85,24 +86,30 @@
8586
% .. code-block:: matlab
8687
%
8788
% % Adding new value
88-
% f = f.metadata_add('NewField', 'new value');
89-
% f.metadata()
89+
%
90+
% bf = bf.metadata_add('NewField', 'new value');
91+
% bf.metadata()
92+
%
9093
% struct with fields:
9194
% manufacturer: 'siemens'
9295
% flipangle: 10
9396
% NewField: 'new value'
9497
%
9598
% % Appending to existing value
96-
% f = f.metadata_append('NewField', 'new value 1');
97-
% f.metadata()
99+
%
100+
% bf = bf.metadata_append('NewField', 'new value 1');
101+
% bf.metadata()
102+
%
98103
% struct with fields:
99104
% manufacturer: 'siemens'
100105
% flipangle: 10
101106
% NewField: {'new value'; 'new value 1'}
102107
%
103108
% % Removing value
104-
% f = f.metadata_remove('NewField');
105-
% f.metadata()
109+
%
110+
% bf = bf.metadata_remove('NewField');
111+
% bf.metadata()
112+
%
106113
% struct with fields:
107114
% manufacturer: 'siemens'
108115
% flipangle: 10
@@ -111,10 +118,11 @@
111118
%
112119
% .. code-block:: matlab
113120
%
114-
% f = f.metadata_update('Description', 'source file', ...
121+
% bf = bf.metadata_update('Description', 'source file', ...
115122
% 'NewField', 'new value', ...
116123
% 'manufacturer', []);
117-
% f.metadata()
124+
% bf.metadata()
125+
%
118126
% struct with fields:
119127
% flipangle: 10
120128
% description: 'source file'
@@ -124,7 +132,9 @@
124132
%
125133
% .. code-block:: matlab
126134
%
127-
% f.metadata_write()
135+
% bf.metadata_write()
136+
%
137+
%
128138

129139
% (C) Copyright 2021 BIDS-MATLAB developers
130140

@@ -811,12 +821,14 @@ function check_required_entities(obj)
811821
end
812822

813823
function out_file = metadata_write(obj, varargin)
814-
% Export current content of metadata to sidecar json with
815-
% same name as current file. Metadata fields can be modified
816-
% with new values passed in varargin, which can be either a structure,
817-
% or pairs of key-values. These modifications do not affect
818-
% current File object, and only exported into file. Use
819-
% bids.File.metadata_update to update current metadata.
824+
% Export current content of metadata to sidecar json
825+
% with same name as current file.
826+
%
827+
% Metadata fields can be modified with new values passed in varargin,
828+
% which can be either a structure, or pairs of key-values.
829+
% These modifications do not affect current File object,
830+
% and only exported into file.
831+
% Use bids.File.metadata_update to update current metadata.
820832
% Returns full path to the exported sidecar json file.
821833
%
822834
% See also
@@ -826,7 +838,9 @@ function check_required_entities(obj)
826838
%
827839
% f.metadata_write(key1, value1, key2, value2);
828840
% f.metadata_write(struct(key1, value1, ...
829-
% key2, value2));
841+
% key2, value2));
842+
%
843+
830844
[path, ~, ~] = fileparts(obj.path);
831845
out_file = fullfile(path, obj.json_filename);
832846

demos/spm/facerep/code/convert_facerep_ds.m

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
create_changelog(output_dir);
5757
create_datasetdescription(output_dir, opt);
5858
create_bold_json(output_dir, task_name, repetition_time, nb_slices, echo_time, opt);
59+
bids.util.create_participants_tsv(output_dir);
5960

6061
end
6162

0 commit comments

Comments
 (0)