Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
diramigo opened this issue Aug 28, 2023 · 1 comment
Open

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

diramigo opened this issue Aug 28, 2023 · 1 comment
Labels

Comments

@diramigo
Copy link

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

@diramigo diramigo added the bug label Aug 28, 2023
@egarza
Copy link

egarza commented Sep 5, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants