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
284 stars 128 forks source link

Do not apply drift correction if only one b=0 is provided (or calculate it with the lowest shell?) #1209

Closed araikes closed 2 months ago

araikes commented 3 months ago

What happened?

I pulled v. 23.1.1 to test the DWI workflow. The data I'm testing on is a single b=0 and 54 b=1000 volumes. It crashes pretty much at the outset.

What command did you use?

singularity run --containall -B $PWD/nifti:/nifti:ro -B $PWD/derivatives/mriqc:/output -B /tmp:/tmp /groups/adamraikes/singularity_images/mriqc_23.1.1.sif /nifti /output participant --participant_label 108 -w /tmp

What version of the software are you running?

23.1.1

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.

240320-09:29:36,207 cli IMPORTANT:
     ------------------------------------------------------------------
         Running MRIQC version 24.0.0.dev0+g4d96184d.d20240320
         ------------------------------------------------------------------
           * BIDS dataset path: /nifti.
           * Output folder: /output.
           * Analysis levels: ['participant'].
         ------------------------------------------------------------------

240320-09:29:42,258 cli IMPORTANT:
     Building MRIQC's workflows...
240320-09:29:47,885 cli IMPORTANT:
     Workflow building finished (exit code 0).
240320-09:29:52,527 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.
240320-09:32:29,174 nipype.workflow WARNING:
     Storing result file without outputs
240320-09:32:29,174 nipype.workflow WARNING:
     [Node] Error on "mriqc_wf.dwiMRIQC.drift" (/tmp/mriqc_wf/dwiMRIQC/_in_file_..nifti..sub-108..dwi..sub-108_dwi.nii.gz/drift)
240320-09:32:30,754 nipype.workflow ERROR:
     Node drift.a0 failed to run on host r3u16n2.puma.hpc.arizona.edu.
240320-09:32:30,755 nipype.workflow ERROR:
     Saving crash info to /output/logs/crash-20240320-093230-adamraikes-drift.a0-182b0627-5505-4d93-9afc-df75b974048c.txt
Traceback (most recent call last):
  File "/opt/conda/lib/python3.11/site-packages/mriqc/engine/plugin.py", line 60, in run_node
    result['result'] = node.run(updatehash=updatehash)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/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 drift.

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/diffusion.py", line 280, in _run_interface
        global_signal = np.array([
                                 ^
      File "/opt/conda/lib/python3.11/site-packages/mriqc/interfaces/diffusion.py", line 281, in <listcomp>
        np.median(data[..., n_b0][bmask]) for n_b0 in range(img.shape[-1])
                  ~~~~~~~~~~~~~~~^^^^^^^
    IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed

Traceback (most recent call last):
  File "/opt/conda/bin/mriqc", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/mriqc/cli/run.py", line 166, in main
    mriqc_wf.run(**_plugin)
  File "/opt/conda/lib/python3.11/site-packages/nipype/pipeline/engine/workflows.py", line 638, in run
    runner.run(execgraph, updatehash=updatehash, config=self.config)
  File "/opt/conda/lib/python3.11/site-packages/mriqc/engine/plugin.py", line 183, in run
    notrun.append(self._clean_queue(jobid, graph, result=result))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/mriqc/engine/plugin.py", line 256, in _clean_queue
    raise RuntimeError(''.join(result['traceback']))
RuntimeError: Traceback (most recent call last):
  File "/opt/conda/lib/python3.11/site-packages/mriqc/engine/plugin.py", line 60, in run_node
    result['result'] = node.run(updatehash=updatehash)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/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 drift.

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/diffusion.py", line 280, in _run_interface
        global_signal = np.array([
                                 ^
      File "/opt/conda/lib/python3.11/site-packages/mriqc/interfaces/diffusion.py", line 281, in <listcomp>
        np.median(data[..., n_b0][bmask]) for n_b0 in range(img.shape[-1])
                  ~~~~~~~~~~~~~~~^^^^^^^
    IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed

Additional information / screenshots

bval file: 0 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000

araikes commented 3 months ago

Tested on a different dataset that has multiple b=0 volumes and it ran without an issue. So it seems that it is the single b=0 volume acquisitions that fail.

Are any IQMs other than the shell values stored somewhere?

JonteP commented 3 months ago

I can replicate this one as well. It seems that (at line 281) img.shape is expected to be [xdim,ydim,zdim,n_b0] but when n_b0=1 img is a 3d-array.

JonteP commented 3 months ago

I guess correcting for signal drift doesn't make sense for single b=0 anyway? I tried bypassing the signal drift correction and the pipeline finished without further issues.