Skip to content

Commit

Permalink
[ENH] remove atlas and update res and den metadata (#622)
Browse files Browse the repository at this point in the history
* rm atlas and update res and den metadata

* fix
  • Loading branch information
Remi-Gau authored Aug 26, 2023
1 parent eec8349 commit d3f339a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 38 deletions.
22 changes: 2 additions & 20 deletions +bids/derivatives_json.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,38 +69,20 @@

%% entity related content
if any(ismember(fieldnames(p.entities), 'res'))
try
content.Resolution = {{ struct(p.entities.res, 'REQUIRED if "res" entity') }};
catch
bids.internal.error_handling(mfilename(), 'invalidFieldname', ....
sprintf('Invalid field name for entity res-%s', ...
p.entities.res), ...
true, ...
true);
end
content.Resolution = p.entities.res;
end

if any(ismember(fieldnames(p.entities), 'den'))
try
content.Density = {{ struct(p.entities.den, 'REQUIRED if "den" entity') }};
catch
bids.internal.error_handling(mfilename(), 'invalidFieldname', ....
sprintf('Invalid field name for entity den-%s', ...
p.entities.den), ...
true, ...
true);
end
content.Density = p.entities.den;
end

%% suffix related content
if any(ismember(p.suffix, {'dseg', 'probseg'}))
content.Manual = {{'OPTIONAL'}};
content.Atlas = {{'OPTIONAL'}};
end

if any(ismember(p.suffix, {'mask'}))
content.RawSources = {{'REQUIRED'}};
content.Atlas = {{'OPTIONAL'}};
content.Type = {{'OPTIONAL'}};
end

Expand Down
2 changes: 1 addition & 1 deletion demos/notebooks/BIDS_Matlab_03_filenames_and_metadata.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@
json = bids.derivatives_json('sub-01_ses-test_task-faceRecognition_res-r2pt0_space-IXI549Space_desc-brain_mask.nii');
json.filename;
json.content;
json.content.Resolution{1}{1};
json.content.Resolution;
19 changes: 2 additions & 17 deletions tests/test_derivatives_json.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,6 @@ function test_derivatives_json_basic()

end

function test_derivatives_json_entity_as_number()

if bids.internal.is_octave()
moxunit_throw_test_skipped_exception('Octave:mixed-string-concat warning thrown');
end

filename = 'sub-01_ses-test_task-faceRecognition_run-02_res-2_bold.nii';

assertWarning(@() bids.derivatives_json(filename), ...
'derivatives_json:invalidFieldname');

end

function test_derivatives_json_force()

%% force to create default content
Expand All @@ -57,8 +44,8 @@ function test_derivatives_json_preproc()

content = expected_content();

content.Resolution = {{ struct('hi', 'REQUIRED if "res" entity') }};
content.Density = {{ struct('lo', 'REQUIRED if "den" entity') }};
content.Resolution = 'hi';
content.Density = 'lo';

expected.content = content;
expected.filename = 'sub-01_task-faceRecognition_res-hi_den-lo_desc-preproc_bold.json';
Expand All @@ -76,7 +63,6 @@ function test_derivatives_json_segmentation()

content = expected_content();
content.Manual = {{'OPTIONAL'}};
content.Atlas = {{'OPTIONAL'}};

expected.content = content;
expected.filename = 'sub-01_desc-T1w_dseg.json';
Expand All @@ -94,7 +80,6 @@ function test_derivatives_json_mask()

content = expected_content();
content.RawSources = {{'REQUIRED'}};
content.Atlas = {{'OPTIONAL'}};
content.Type = {{'OPTIONAL'}};

expected.content = content;
Expand Down

0 comments on commit d3f339a

Please sign in to comment.