nipreps / mriqc

Automated Quality Control and visual reports for Quality Assessment of structural (T1w, T2w) and functional MRI of the brain
http://mriqc.readthedocs.io
Apache License 2.0
299 stars 132 forks source link

An issue with refaced data "Input X contains NaN" #1133

Closed diramigo closed 3 months ago

diramigo commented 1 year ago

What happened?

I am running MRIQC on our T1w images, which I previously refaced with afni's reface+ v2.2. While it runs fine on most of them, it raises an error on some images (48/254). There were no issues on our bold and T2w images, which were not anonymized. I then ran MRIQC on the non-refaced T1w of one of the images MRIQC was raising an error, and it ran successfully, so it seems to be an issue with afni_reface output. Any idea on what the problem might be? I loaded the images with nibabel and couldn't find any missing values or something out of the ordinary

What command did you use?

mriqc --participant-label ${subject} inputs/bids_dataset outputs/ participant

What version of the software are you running?

23.1.0

How are you running this software?

Singularity

Is your data BIDS valid?

Yes

Are you reusing any previously computed results?

No

Please copy and paste any relevant log output.

Running MRIQC version 23.1.0:
      * BIDS dataset path: /tmp/job-mriqc_sub-128B_T1w/inputs/mri-raw.
      * Output folder: /tmp/job-mriqc_sub-128B_T1w/outputs.
      * Analysis levels: ['participant'].

230827-13:14:26,480 cli WARNING:
     IMPORTANT: Anonymized quality metrics (IQMs) will be submitted to MRIQC's metrics repository. Submission of IQMs can be disabled using the ``--no-sub`` argument. Please visit https://mriqc.readthedocs.io/en/latest/dsa.html to revise MRIQC's Data Sharing Agreement.
230827-13:19:49,597 nipype.workflow WARNING:
     Storing result file without outputs
230827-13:19:49,598 nipype.workflow WARNING:
     [Node] Error on "mriqc_wf.anatMRIQC.ComputeIQMs.ComputeQI2" (/tmp/job-mriqc_sub-128B_T1w/work/mriqc_wf/anatMRIQC/ComputeIQMs/_in_file_..tmp..job-mriqc_sub-128B_T1w..inputs..mri-raw..sub-128B..anat..sub-128B_T1w.nii.gz/ComputeQI2)
230827-13:19:51,155 nipype.workflow ERROR:
     Node ComputeQI2.a0 failed to run on host geminis.
230827-13:19:51,155 nipype.workflow ERROR:
     Saving crash info to /tmp/job-mriqc_sub-128B_T1w/outputs/logs/crash-20230827-131951-ramirezd-ComputeQI2.a0-84c140e4-757b-466c-9a6a-f9a4cdf06551.txt
Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/mriqc/engine/plugin.py", line 60, in run_node
    result["result"] = node.run(updatehash=updatehash)
  File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
  File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
  File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/nodes.py", line 771, in _run_command
    raise NodeExecutionError(msg)
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node ComputeQI2.

Traceback:
    Traceback (most recent call last):
      File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 397, in run
        runtime = self._run_interface(runtime)
      File "/opt/conda/lib/python3.9/site-packages/mriqc/interfaces/anatomical.py", line 376, in _run_interface
        qi2, out_file = art_qi2(imdata, airdata)
      File "/opt/conda/lib/python3.9/site-packages/mriqc/qc/anatomical.py", line 488, in art_qi2
        kde_skl = KernelDensity(kernel="gaussian", bandwidth=4.0).fit(modelx[:, np.newaxis])
      File "/opt/conda/lib/python3.9/site-packages/sklearn/neighbors/_kde.py", line 189, in fit
        X = self._validate_data(X, order="C", dtype=DTYPE)
      File "/opt/conda/lib/python3.9/site-packages/sklearn/base.py", line 577, in _validate_data
        X = check_array(X, input_name="X", **check_params)
      File "/opt/conda/lib/python3.9/site-packages/sklearn/utils/validation.py", line 899, in check_array
        _assert_all_finite(
      File "/opt/conda/lib/python3.9/site-packages/sklearn/utils/validation.py", line 146, in _assert_all_finite
        raise ValueError(msg_err)
    ValueError: Input X contains NaN.
    KernelDensity does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values

Additional information / screenshots

No response

egarza commented 1 year ago

Hi,

Same problem here using docker in WSL Ubuntu 20.04

What command did you use?

sudo docker run -it --rm -v /mnt/d/Trabajo/Academia/Docencia/Cursos/2023/CursoRedes_2023/Practica/raw20:/data:ro -v /mnt/d/Trabajo/Academia/Docencia/Cursos/2023/CursoRedes_2023/Practica/practica20mriqcout:/out -v /mnt/d/Trabajo/Academia/Docencia/Cursos/2023/CursoRedes_2023/Practica/working:/work nipreps/mriqc:latest --nprocs 2 -m T1w bold --fd_thres 0.5 -w /work /data /out participant --participant_label 020 --verbose-reports

What version of the software are you running?

23.1.0

How are you running this software?

Singularity

Is your data BIDS valid?

Yes

Are you reusing any previously computed results?

No

Please copy and paste any relevant log output.

Node: mriqc_wf.anatMRIQC.ComputeIQMs.ComputeQI2
Working directory: /work/mriqc_wf/anatMRIQC/ComputeIQMs/_in_file_..data..sub-020..anat..sub-020_T1w.nii.gz/ComputeQI2

Node inputs:

air_msk = <undefined>
in_file = <undefined>

Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/mriqc/engine/plugin.py", line 60, in run_node
    result["result"] = node.run(updatehash=updatehash)
  File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
  File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
  File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/nodes.py", line 771, in _run_command
    raise NodeExecutionError(msg)
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node ComputeQI2.

Traceback:
    Traceback (most recent call last):
      File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 397, in run
        runtime = self._run_interface(runtime)
      File "/opt/conda/lib/python3.9/site-packages/mriqc/interfaces/anatomical.py", line 376, in _run_interface
        qi2, out_file = art_qi2(imdata, airdata)
      File "/opt/conda/lib/python3.9/site-packages/mriqc/qc/anatomical.py", line 488, in art_qi2
        kde_skl = KernelDensity(kernel="gaussian", bandwidth=4.0).fit(modelx[:, np.newaxis])
      File "/opt/conda/lib/python3.9/site-packages/sklearn/neighbors/_kde.py", line 189, in fit
        X = self._validate_data(X, order="C", dtype=DTYPE)
      File "/opt/conda/lib/python3.9/site-packages/sklearn/base.py", line 577, in _validate_data
        X = check_array(X, input_name="X", **check_params)
      File "/opt/conda/lib/python3.9/site-packages/sklearn/utils/validation.py", line 899, in check_array
        _assert_all_finite(
      File "/opt/conda/lib/python3.9/site-packages/sklearn/utils/validation.py", line 146, in _assert_all_finite
        raise ValueError(msg_err)
    ValueError: Input X contains NaN.
    KernelDensity does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values

For some reason the mask and in file are empty, but I don't see the problem in my code.

You can reproduce the same error if you use sub-20 from this dataset: https://openneuro.org/datasets/ds003346/versions/1.1.2

Thanks,

Eduardo