4
4
%
5
5
% USAGE::
6
6
%
7
- % file = bids.File(input, ...
7
+ % bf = bids.File(input, ...
8
8
% 'use_schema', false, ...
9
9
% 'tolerant', true,
10
10
% 'verbose', false);
30
30
% .. code-block:: matlab
31
31
%
32
32
% input = fullfile(pwd, 'sub-01_ses-02_T1w.nii');
33
- % file = bids.File(input);
33
+ % bf = bids.File(input);
34
34
%
35
35
% Initialize with a structure
36
36
%
40
40
% 'suffix', 'T1w', ...
41
41
% 'entities', struct('sub', '01', ...
42
42
% 'ses', '02'));
43
- % file = bids.File(input);
43
+ % bf = bids.File(input);
44
44
%
45
45
% Remove prefixes and add a ``desc-preproc`` entity-label pair.
46
46
%
47
47
% .. code-block:: matlab
48
48
%
49
49
% 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';
53
53
% disp(file.filename)
54
54
%
55
55
% Use the BIDS schema to get entities in the right order.
63
63
% 'run', '02', ...
64
64
% 'task', 'face recognition');
65
65
%
66
- % file = bids.File(name_spec, 'use_schema', true);
66
+ % bf = bids.File(name_spec, 'use_schema', true);
67
67
%
68
68
% Load metadata (supporting inheritance).
69
69
%
70
70
% .. code-block:: matlab
71
71
%
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');
73
73
%
74
74
% Access metadata
75
75
%
76
76
% .. code-block:: matlab
77
77
%
78
- % f.metadata()
78
+ % bf.metadata()
79
+ %
79
80
% struct with fields:
80
81
% Manufacturer: 'Siemens'
81
82
% FlipAngle: 10
85
86
% .. code-block:: matlab
86
87
%
87
88
% % 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
+ %
90
93
% struct with fields:
91
94
% manufacturer: 'siemens'
92
95
% flipangle: 10
93
96
% NewField: 'new value'
94
97
%
95
98
% % 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
+ %
98
103
% struct with fields:
99
104
% manufacturer: 'siemens'
100
105
% flipangle: 10
101
106
% NewField: {'new value'; 'new value 1'}
102
107
%
103
108
% % Removing value
104
- % f = f.metadata_remove('NewField');
105
- % f.metadata()
109
+ %
110
+ % bf = bf.metadata_remove('NewField');
111
+ % bf.metadata()
112
+ %
106
113
% struct with fields:
107
114
% manufacturer: 'siemens'
108
115
% flipangle: 10
111
118
%
112
119
% .. code-block:: matlab
113
120
%
114
- % f = f .metadata_update('Description', 'source file', ...
121
+ % bf = bf .metadata_update('Description', 'source file', ...
115
122
% 'NewField', 'new value', ...
116
123
% 'manufacturer', []);
117
- % f.metadata()
124
+ % bf.metadata()
125
+ %
118
126
% struct with fields:
119
127
% flipangle: 10
120
128
% description: 'source file'
124
132
%
125
133
% .. code-block:: matlab
126
134
%
127
- % f.metadata_write()
135
+ % bf.metadata_write()
136
+ %
137
+ %
128
138
129
139
% (C) Copyright 2021 BIDS-MATLAB developers
130
140
@@ -811,12 +821,14 @@ function check_required_entities(obj)
811
821
end
812
822
813
823
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.
820
832
% Returns full path to the exported sidecar json file.
821
833
%
822
834
% See also
@@ -826,7 +838,9 @@ function check_required_entities(obj)
826
838
%
827
839
% f.metadata_write(key1, value1, key2, value2);
828
840
% f.metadata_write(struct(key1, value1, ...
829
- % key2, value2));
841
+ % key2, value2));
842
+ %
843
+
830
844
[path , ~ , ~ ] = fileparts(obj .path );
831
845
out_file = fullfile(path , obj .json_filename );
832
846
0 commit comments