JSONDecodeError

Dear experts,

I’m getting the following error on fMRIPrep ver 20.2.1:

/usr/local/miniconda/lib/python3.7/site-packages/bids/layout/validation.py:46: UserWarning: The ability to pass arguments to BIDSLayout that control indexing is likely to be removed in future; possibly as early as PyBIDS 0.14. This includes the `config_filename`, `ignore`, `force_index`, and `index_metadata` arguments. The recommended usage pattern is to initialize a new BIDSLayoutIndexer with these arguments, and pass it to the BIDSLayout via the `indexer` argument.
  warnings.warn("The ability to pass arguments to BIDSLayout that control "
Traceback (most recent call last):
  File "/usr/local/miniconda/bin/fmriprep", line 10, in <module>
sys.exit(main())
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/run.py", line 17, in main
parse_args()
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/parser.py", line 602, in parse_args
config.from_dict(vars(opts))
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/config.py", line 617, in from_dict
execution.load(settings)
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/config.py", line 218, in load
cls.init()
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/config.py", line 453, in init
re.compile(r"^\."),
  File "/usr/local/miniconda/lib/python3.7/site-packages/bids/layout/layout.py", line 136, in __init__
root, description = validate_root(root, validate)
  File "/usr/local/miniconda/lib/python3.7/site-packages/bids/layout/validation.py", line 83, in validate_root
description = json.load(desc_fd)
  File "/usr/local/miniconda/lib/python3.7/json/__init__.py", line 296, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/local/miniconda/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
  File "/usr/local/miniconda/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/miniconda/lib/python3.7/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 3 column 2 (char 20)

My .json file looks like this:

{
	"Modality": "MR",
	"MagneticFieldStrength": 3,
	"ImagingFrequency": 123.219,
	"Manufacturer": "Siemens",
	"ManufacturersModelName": "Verio",
	"InstitutionName": "REDACTED",
	"InstitutionalDepartmentName": "Department",
	"InstitutionAddress": "REDACTED",
	"DeviceSerialNumber": "REDACTED",
	"StationName": "REDACTED",
	"PatientPosition": "HFS",
	"ProcedureStepDescription": "Neuro_Brain_Research",
	"SoftwareVersions": "syngo_MR_B19",
	"MRAcquisitionType": "3D",
	"SeriesDescription": "T1_MPR_SAG_EM",
	"ProtocolName": "T1_MPR_SAG_EM",
	"ScanningSequence": "GR_IR",
	"SequenceVariant": "SP_MP",
	"ScanOptions": "IR",
	"SequenceName": "_tfl3d1_ns",
	"ImageType": ["ORIGINAL", "PRIMARY", "M", "ND", "NORM"],
	"SeriesNumber": 2,
	"AcquisitionTime": "16:29:4.455000",
	"AcquisitionNumber": 1,
	"SliceThickness": 1,
	"SAR": 0.039084,
	"EchoTime": 0.0035,
	"RepetitionTime": 2.53,
	"InversionTime": 1.1,
	"FlipAngle": 7,
	"PartialFourier": 1,
	"BaseResolution": 256,
	"ShimSetting": [
		-7175,
		4960,
		-9437,
		153,
		127,
		-555,
		800,
		-112	],
	"TxRefAmp": 516.209,
	"PhaseResolution": 1,
	"ReceiveCoilName": "HeadMatrix",
	"CoilString": "T:HEA;HEP",
	"PulseSequenceDetails": "%SiemensSeq%_tfl",
	"RefLinesPE": 32,
	"PercentPhaseFOV": 100,
	"PercentSampling": 100,
	"PhaseEncodingSteps": 255,
	"AcquisitionMatrixPE": 256,
	"ReconMatrixPE": 256,
	"ParallelReductionFactorInPlane": 2,
	"PixelBandwidth": 190,
	"DwellTime": 1.03e-05,
	"ImageOrientationPatientDICOM": [
		0,
		0.999998,
		-0.00174528,
		0,
		-0.00174528,
		-0.999998	],
	"InPlanePhaseEncodingDirectionDICOM": "ROW",
	"ConversionSoftware": "dcm2niix",
	"ConversionSoftwareVersion": "v1.0.20200331"
}

Everything passes BIDS Validation, and I’ve gotten other data sets to run with identical-looking JSON files, so I’m a little stumped. Has anyone encountered this error?

File “/usr/local/miniconda/lib/python3.7/site-packages/bids/layout/validation.py”, line 83, in validate_root

The traceback seems to indicate that the error is coming from loading the top-level dataset_description.json, rather than the imaging sidecar files. Can you share that one?

Thank you! That was where the error was (d’oh).

I’m now getting the following error:

dim[0] is out-of-range, we'll simply try continuing to read the file, but this will most likely fail horribly.
dim[0] is out-of-range, we'll simply try continuing to read the file, but this will most likely fail horribly.
dim[0] is out-of-range, we'll simply try continuing to read the file, but this will most likely fail horribly.
dim[0] is out-of-range, we'll simply try continuing to read the file, but this will most likely fail horribly.
/usr/local/miniconda/lib/python3.7/site-packages/bids/layout/validation.py:46: UserWarning: The ability to pass arguments to BIDSLayout that control indexing is likely to be removed in future; possibly as early as PyBIDS 0.14. This includes the `config_filename`, `ignore`, `force_index`, and `index_metadata` arguments. The recommended usage pattern is to initialize a new BIDSLayoutIndexer with these arguments, and pass it to the BIDSLayout via the `indexer` argument.
  warnings.warn("The ability to pass arguments to BIDSLayout that control "
Traceback (most recent call last):
  File "/usr/local/miniconda/bin/fmriprep", line 10, in <module>
    sys.exit(main())
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/run.py", line 17, in main
    parse_args()
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/parser.py", line 703, in parse_args
    config.environment.exec_env, opts.bids_dir, opts.participant_label
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/utils/bids.py", line 155, in validate_input_dir
    subprocess.check_call(['bids-validator', bids_dir, '-c', temp.name])
  File "/usr/local/miniconda/lib/python3.7/subprocess.py", line 341, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['bids-validator', PosixPath('PATH REDACTED'), '-c', '/scratch/local/66071616/tmppf9cdmwj']' returned non-zero exit status 1.

Can anyone shed insight on this one? The validator still indicates everything looks good.

That indicates that you probably have malformed NIfTI files. Might try running fslhd or mri_info on all of your NIfTIs to see if you can narrow it down. Not sure why the validator isn’t telling you which ones it is.

Thank you so much for your help with this.

Here’s my mri_info. Everything looks pretty similar to scans from another study that run through fMRIPrep OK, so I’m not sure what the issue might be.

Volume information for sub-5658_ses-01_task-nback_run-01_bold.nii
      type: SHORT (4)
       fov: 224.000
       dof: 1
    xstart: -112.0, xend: 112.0
    ystart: -112.0, yend: 112.0
    zstart: -63.0, zend: 63.0
        TR: 2000.00 msec, TE: 0.00 msec, TI: 0.00 msec, flip angle: 0.00 deg                                 rees
   nframes: 277
   PhEncDir: UNKNOWN
   FieldStrength: 0.000000
ras xform present
xform info: x_r =  -1.0000, y_r =   0.0000, z_r =  -0.0000, c_r =     0.0000
          : x_a =  -0.0000, y_a =   0.9219, z_a =  -0.3875, c_a =   -17.6305
          : x_s =   0.0000, y_s =   0.3875, z_s =   0.9219, c_s =    10.7645
Orientation   : LAS
Primary Slice Direction: axial

voxel to ras transform:
           -3.5000   0.0000  -0.0000   112.0000
           -0.0000   3.2265  -1.3563   -96.4657
            0.0000   1.3563   3.2265   -90.7147
            0.0000   0.0000   0.0000     1.0000

voxel-to-ras determinant -42.875

ras to voxel transform:
           -0.2857  -0.0000  -0.0000    32.0000
           -0.0000   0.2634   0.1107    35.4519
           -0.0000  -0.1107   0.2634    13.2127
           -0.0000  -0.0000  -0.0000     1.0000

Thanks again!

Doesn’t look like mri_info shows the dim field. fslhd should, although it may do some fixing up prior to display. Again, I think you need to run on all NIfTI files to determine which ones are causing the error.

If you have Python and nibabel installed, you could do something like:

from glob import glob
import nibabel as nb

for fname in glob("/path/to/dataset/**/*.nii*", recursive=True):
    try:
        img = nb.load(fname)
    except:
        print(f"Failed to load: {fname}")
    else:
        print(f"{fname}: {img.header['dim']}")

MANAGED BY INCF