From d3f339a2f7bf4b72c6698351b72183552b04efce Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Sat, 26 Aug 2023 11:18:32 -0400 Subject: [PATCH] [ENH] remove atlas and update res and den metadata (#622) * rm atlas and update res and den metadata * fix --- +bids/derivatives_json.m | 22 ++----------------- .../BIDS_Matlab_03_filenames_and_metadata.m | 2 +- tests/test_derivatives_json.m | 19 ++-------------- 3 files changed, 5 insertions(+), 38 deletions(-) diff --git a/+bids/derivatives_json.m b/+bids/derivatives_json.m index 8319a113..75a11387 100644 --- a/+bids/derivatives_json.m +++ b/+bids/derivatives_json.m @@ -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 diff --git a/demos/notebooks/BIDS_Matlab_03_filenames_and_metadata.m b/demos/notebooks/BIDS_Matlab_03_filenames_and_metadata.m index 04ebdbba..9471d236 100644 --- a/demos/notebooks/BIDS_Matlab_03_filenames_and_metadata.m +++ b/demos/notebooks/BIDS_Matlab_03_filenames_and_metadata.m @@ -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; diff --git a/tests/test_derivatives_json.m b/tests/test_derivatives_json.m index 30280834..32470e76 100644 --- a/tests/test_derivatives_json.m +++ b/tests/test_derivatives_json.m @@ -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 @@ -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'; @@ -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'; @@ -94,7 +80,6 @@ function test_derivatives_json_mask() content = expected_content(); content.RawSources = {{'REQUIRED'}}; - content.Atlas = {{'OPTIONAL'}}; content.Type = {{'OPTIONAL'}}; expected.content = content;