[Node] Error on "mriqc_wf.dwiMRIQC.ComputeIQMs.datasink"

Hi all,
I’m new to learn fmriprep relevant knowledge, now i step to MRIQC and encountered some issues, please anyone experts in this community could help me?

:slight_smile:

Summary of what happened:

MRIQC version 24.1.0.dev0+g3fe90466.d20240417 was used to calculate the subject-level analysis, there were 56 subjects in total, and all subject folder generated the JOSN file, but almost half of them no figures and htmls generated. after checked the error, I found the wrong subjects were no info write into the sub-xxx_dwi.json file. I don’t know why this happened, cause all nifti file of each subjects are intact, include the json file. by the way i used heudoconv to convert all DICOM file into NIFTI format.

Command used (and if a helper script was used, a link to the helper script or the command generated):

I installed docker on windows, here is my code

$subids =  $(cat H:\MRI_data\sublist.txt)
foreach($indexs in 0..55)
{
$proc_subs = $subids[$indexs]
docker run -it --rm `
-v F:\attention_data\Nift:/data:ro `
-v F:\attention_data\MRIQC:/out `
nipreps/mriqc:latest /data /out participant --participant_label $proc_subs
}

Version:

MRIQC version 24.1.0.dev0+g3fe90466.d20240417

Environment (Docker, Singularity / Apptainer, custom installation):

docker on windows wsl2

Data formatted according to a validatable standard? Please provide the output of the validator:

passed the online validation

Relevant log outputs (up to 20 lines):

2024-04-25 03:15:14 | INFO     | niworkflows      | Generating visual report
2024-04-25 03:16:16 | WARNING  | nipype.interface | Estimated signal variation in the background was too small (MAD=0.0, sigma=11.2851)
2024-04-25 03:16:16 | WARNING  | nipype.interface | Estimated signal variation in the background was too small (MAD=0.0, sigma=11.2851)
2024-04-25 03:16:16 | WARNING  | nipype.interface | Estimated signal variation in the background was too small (MAD=0.0, sigma=11.2851)
2024-04-25 03:22:26 | WARNING  | nipype.workflow  | Storing result file without outputs
2024-04-25 03:22:26 | WARNING  | nipype.workflow  | [Node] Error on "mriqc_wf.dwiMRIQC.ComputeIQMs.datasink" (/tmp/work/mriqc_wf/dwiMRIQC/ComputeIQMs/_in_file_..data..sub-114..dwi..sub-114_dwi.nii.gz/datasink)

Screenshots / relevant information: Traceback:

    Traceback (most recent call last):
      File "/opt/conda/lib/python3.11/site-packages/nipype/interfaces/base/core.py", line 397, in run
        runtime = self._run_interface(runtime)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/conda/lib/python3.11/site-packages/mriqc/interfaces/bids.py", line 188, in _run_interface
        json.dumps(
      File "/opt/conda/lib/python3.11/site-packages/simplejson/__init__.py", line 395, in dumps
        **kw).encode(obj)
              ^^^^^^^^^^^
      File "/opt/conda/lib/python3.11/site-packages/simplejson/encoder.py", line 300, in encode
        chunks = list(chunks)
                 ^^^^^^^^^^^^
      File "/opt/conda/lib/python3.11/site-packages/simplejson/encoder.py", line 714, in _iterencode
        for chunk in _iterencode_dict(o, _current_indent_level):
      File "/opt/conda/lib/python3.11/site-packages/simplejson/encoder.py", line 645, in _iterencode_dict
        yield _floatstr(value)
              ^^^^^^^^^^^^^^^^
      File "/opt/conda/lib/python3.11/site-packages/simplejson/encoder.py", line 351, in floatstr
        raise ValueError(
    ValueError: Out of range float values are not JSON compliant: nan

This issue seems related to JSON encoders, which are not equipped to parse NaN values. This is not unique to mriqc, but it does disrupt its functionality. The likely cause is that some fields in your JSON file(s) contain NaN values. For additional information, see this discussion on the mriqc-users Google group and this GitHub issue.

In my opinion, the best strategy is to create a small utility script that sanitizes these fields in a JSON-compliant manner, for example by converting NaN values to null, although I haven’t tested this solution yet. Alternatively, these fields could be removed. Regardless of the method chosen, a BIDS validation is recommended after sanitizing the files.

If you decide to write such a utility, please consider sharing it here to assist others facing similar issues. I have encountered this problem with at least two different fMRI datasets in the past few years, and several other users have reported similar errors. While we wait for the mriqc maintainers to resolve this issue, having such a utility to sanitize the NaN JSON fields would be beneficial to the broader community :slight_smile:

1 Like