Help with BIDS-validator error

Hi,
I am having trouble creating a bids valid dataset. I have used the dcm2nii to create the .json files and have adjusted the files to the bids specifications to the best of my knowledge, however many of the errors that are being flagged with the bids validator seem false. For example, repetition time, task name, etc are included in the json files.

I have tried to run fmriprep on a single subject, since I cannot find a way to make the dataset bids appropriate, however I get the following error:

Process Process-2:
Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.6/multiprocessing/process.py”, line 258, in _bootstrap
self.run()
File “/usr/local/miniconda/lib/python3.6/multiprocessing/process.py”, line 93, in run
self._target(*self._args, **self._kwargs)
File “/usr/local/miniconda/lib/python3.6/site-packages/fmriprep/cli/run.py”, line 510, in build_workflow
ignore_aroma_err=opts.ignore_aroma_denoising_errors,
File “/usr/local/miniconda/lib/python3.6/site-packages/fmriprep/workflows/base.py”, line 202, in init_fmriprep_wf
ignore_aroma_err=ignore_aroma_err)
File “/usr/local/miniconda/lib/python3.6/site-packages/fmriprep/workflows/base.py”, line 458, in init_single_subject_wf
ignore_aroma_err=ignore_aroma_err)
File “/usr/local/miniconda/lib/python3.6/site-packages/fmriprep/workflows/bold/base.py”, line 262, in init_func_preproc_wf
fmaps = layout.get_fieldmap(ref_file, return_list=True)
File “/usr/local/miniconda/lib/python3.6/site-packages/bids/grabbids/bids_layout.py”, line 244, in get_fieldmap
fieldmaps = self._get_fieldmaps(path)
File “/usr/local/miniconda/lib/python3.6/site-packages/bids/grabbids/bids_layout.py”, line 267, in _get_fieldmaps
metadata = self.get_metadata(file.filename)
File “/usr/local/miniconda/lib/python3.6/site-packages/bids/grabbids/bids_layout.py”, line 169, in get_metadata
encoding=‘utf-8’))
File “/usr/local/miniconda/lib/python3.6/json/init.py”, line 299, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File “/usr/local/miniconda/lib/python3.6/json/init.py”, line 354, in loads
return _default_decoder.decode(s)
File “/usr/local/miniconda/lib/python3.6/json/decoder.py”, line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/local/miniconda/lib/python3.6/json/decoder.py”, line 357, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 14 column 17 (char 396)

Can anyone tell me what I am doing wrong?

Thanks,
Kaylena

Hi @kaylena88 !

Could you please post an example json file ? It would help to diagnose the error.

Thanks,

Elizabeth

1 Like

Sure! Here I have copied the sub-01_task-fogplank_run-1_bold.json

{
“TaskName”: “fogplank”,
“RepetitionTime”: 2,
“TotalReadoutTime”: 0.027216,
“ConversionSoftware”: “dicm2nii.m 20180116”,
“SeriesNumber”: 4,
“SeriesDescription”: “fMRI FOG 1”,
“ImageType”: “ORIGINAL\PRIMARY\EPI\NONE”,
“Modality”: “MR”,
“AcquisitionDateTime”: “20180530091633”,
“SliceTiming”: [
0.00019546,
9.547e-05,
0.0001907,
9.07e-05,
0.00018594,
0,
0.00018118,
8.118e-05,
0.00017642,
0,
0.00017166,
7.166e-05,
0.00016689,
6.689e-05,
0.00016213,
6.213e-05,
0.00015737,
5.737e-05,
0.00015261,
5.261e-05,
0.00014785,
4.785e-05,
0.00014309,
0,
0.00013832,
3.832e-05,
0.00013356,
3.356e-05,
0.0001288,
2.88e-05,
0.00012404,
0,
0.00011928,
0,
0.00011451,
1.451e-05,
0,
9.75e-06,
0,
4.99e-06,
0.00010023,
2.3e-07 ],

"PhaseEncodingDirection": "j-",
"EffectiveEchoSpacing": 0.000432,
"EchoTime": 0.03,
"PatientName": "PD 00037 JC^RESEARCH",
"PatientSex": "F",
"PatientAge": "075Y",
"PatientWeight": 53,
"PatientPosition": "HFS",
"SliceThickness": 3.4,
"FlipAngle": 77,
"Manufacturer": "GE MEDICAL SYSTEMS",
"SoftwareVersion": "27\\LX\\MR Software release:DV26.0_R01_1725.a",
"MRAcquisitionType": "2D",
"InstitutionName": "Diagnostic MRI Services - BMRI",
"DeviceSerialNumber": "0000000910272071",
"ScanningSequence": "EP\\GR",
"SequenceVariant": "SS",
"ScanOptions": "EPI_GEMS\\ACC_GEMS",
"SequenceName": "EPI"

}

This file is fine, but if you click on the JSON_INVALID text in the validator it will show which lines in which files are problematic.

Thanks for posting that, @kaylena88 !

In addition to what @ChrisGorgolewski said, you can also check JSON correctness using an online JSON validator – this is what I was running.

Hopefully if you fix the errors flagged there and re-run the BIDS validator, it should return as a valid BIDS dataset !

Elizabeth

Thank Chris - so here is the .json file that it takes issue with:

{
“TaskName”: “fogplank”,
“ConversionSoftware”: “dicm2nii.m 20180116”,
“SeriesNumber”: 6,
“SeriesDescription”: “fMRI 1 (blip-down)”,
“ImageType”: “ORIGINAL\PRIMARY\OTHER”,
“Modality”: “MR”,
“AcquisitionDateTime”: “20180529091143”,
“TotalReadoutTime”: 0.027216,
“RepetitionTime”: 2,
“PhaseEncodingDirection”: “j-”,
“EffectiveEchoSpacing”: 0.000432,
“EchoTime”: 0.03,
“IntendedFor”: sub-19_task-fogplank_run-1_bold.nii.gz,
“PatientName”: “PD 00889 WB^RESEARCH”,
“PatientSex”: “M”,
“PatientAge”: “076Y”,
“PatientWeight”: 65,
“PatientPosition”: “HFS”,
“SliceThickness”: 3.4,
“FlipAngle”: 90,
“Manufacturer”: “GE MEDICAL SYSTEMS”,
“SoftwareVersion”: “27\LX\MR Software release:DV26.0_R01_1725.a”,
“MRAcquisitionType”: “2D”,
“InstitutionName”: “Diagnostic MRI Services - BMRI”,
“DeviceSerialNumber”: “0000000910272071”,
“ScanningSequence”: “EP\SE”,
“SequenceVariant”: “NONE”,
“ScanOptions”: “EPI_GEMS\ACC_GEMS”,
“SequenceName”: “EPI”
}

I tried to correct by putting “” around the name, or verifying that the name of the file is correct, however it did ameliorate the error.

Adding quotes (like in here: https://gist.githubusercontent.com/chrisfilo/ec868280f0fd20f04a616abaf4dc21fd/raw/43464ef699afabe2a7d09e754eb52427f9a9dadc/gistfile1.txt) should make it a valid JSON file. The validator will most likely throw other errors though (the IntendedFor needs to be a specific relative path - see https://bids-specification.readthedocs.io/en/latest/04-modality-specific-files/01-magnetic-resonance-imaging-data.html#fieldmap-data).

Focus on getting rid of all INVALID_JSON errors first and then run the validator again. The remaining ones should be easier to interpret with the help of the specification.

Thanks- I will try this.

Kaylena

This worked. Thank you.

1 Like