bids-standard / bids-matlab

MATLAB / Octave tools for BIDS datasets
https://bids-matlab.readthedocs.io
MIT License
51 stars 31 forks source link

[BUG] jsondecode failure #392

Open Remi-Gau opened 2 years ago

Remi-Gau commented 2 years ago

very edge case

from https://openneuro.org/datasets/ds003216/versions/2.1.5/

json_file: ds003216/sub-02/ses-02/func/sub-02_ses-02_task-tapping_run-05_cbv.json

Many warning and eventually this error

> In matlab.internal.json.makeStructure (line 4
[failing_json.txt](https://github.com/bids-standard/bids-matlab/files/8918450/failing_json.txt)
9)
  In bids.util.jsondecode (line 37) 
Error using cell2struct
Duplicate field name "CsaSeries_MrPhoenixProtocol_asCoilSelectMeas_0__aFFT_SCALE_10__"

Error in matlab.internal.json.makeStructure (line 49)
data = cell2struct(values, names, 1);

Error in bids.util.jsondecode (line 37)
    value = jsondecode(fileread(file));

File content: added as txt

Remi-Gau commented 2 years ago

Check if JSONio fails on this too.

gllmflndn commented 2 years ago

That works for me with jsondecode from MATLAB R2021a and Octave and with JSONio. Which version are you using?

Also, I agree this is a valid JSON file but isn't it a bit odd for a fieldname? "CsaSeries.MrPhoenixProtocol.asCoilSelectMeas[0].aFFT_SCALE[10].flFactor": 0.0419083

Remi-Gau commented 2 years ago

Which version are you using?

Matlab 2017a

Also, I agree this is a valid JSON file but isn't it a bit odd for a fieldname? "CsaSeries.MrPhoenixProtocol.asCoilSelectMeas[0].aFFT_SCALE[10].flFactor": 0.0419083

I don't decide how DICOM headers happen. :-p

gllmflndn commented 2 years ago

OK, I can confirm the issue: jsondecode was introduced in R2016b and it crashes with this JSON file in R2016b and R2017a. It's OK from R2017b onwards.

Remi-Gau commented 2 years ago

Thanks a bunch for cross checking this.

Will add it in the doc.