matlabCode in BIDS error in createBIDS_bold_json_full (line 349), Undefined function or variable 'jsonwrite'

After download the file from https://github.com/bids-standard/bids-starter-kit,
run the m file ‘‘createBIDS_bold_json_full’’, error occured: Undefined function or variable ‘jsonwrite’.
The fact is I did not used json before and the there was also a Warning: directory to save json file does not exist, first create: …\templates\sub-01\ses-01\func. So what should I do? To download a toolbox?
Error is shown in the figure uploaded.

Oops. Totally missed that. I have opened an issue on the BIDS starter kit. Thanks for reporting it.

Apparently the code relies in this JSONio library that should be added to the matlab/octave path.

The built-in functions for matlab are jsonencode and jsondecode. There are no equivalent functions for octave (4.4 or 5.1) AFAICT.

Other possibilities:

  • spm12 uses the JSONio library by calling spm_jsonwrite and spm_jsonread and has other interesting functions to help you with BIDS.
  • and if you don’t want to download the whole of SPM just to write a json file, you also have the lighter version BIDS/matlab that has a jsondecode and jsonencode functions taken from SPM but also allows to read a lot of information from the BIDS data set.

Will work on a PR to fix this.

Thank you very much for your power and easy understanding reply!
I have added the JSONio library with your help and it does work, thanks a lot.
However, another occured, “Unable to open file ‘…\templates\sub-01\ses-01\func\sub-01_ses-01_task-FullExample_run-01_bold.jso’ for writing.”
May be I have missed some useful manual about BIDS, but only with the matlab code, I don’t know what others should I do before running the M file except adding the JSONio library.

Are you getting this error when you are running the createBIDS_bold_json_full or when you try to open the json file it created?

I have added the JSONio library and got this error when I again ran the “createBIDS_bold_json_full.m” file in Matlab 2018a