MRIQC IndexError on Singularity

Running MRIQC docker version: nipreps/mriqc:22.0.6 and came into several edge cases where subjects have the following value error:

cannot do a non-empty take from an empty axes

This appears to have come up for someone else (github issue) in an older version of MRIQC but cannot seem to identify the cause. I have 27 instances of this error. All remaining steps completed without errors. Wanted to ask here before opening issue on git

crash log:

Node: mriqc_wf.anatMRIQC.ComputeIQMs.measures
Working directory: /wd/mriqc_wf/anatMRIQC/ComputeIQMs/_in_file_..bids_dir..sub-*[redacted]*..anat..*[redacted]*_T2w.nii.gz/measures

Node inputs:

air_msk = <undefined>
artifact_msk = <undefined>
head_msk = <undefined>
human = True
in_bias = <undefined>
in_file = <undefined>
in_fwhm = <undefined>
in_noinu = <undefined>
in_pvms = <undefined>
in_segm = <undefined>
in_tpms = <undefined>
mni_tpms = <undefined>
rot_msk = <undefined>

Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/mriqc/engine/", line 60, in run_node
    result["result"] =
  File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/", line 524, in run
    result = self._run_interface(execute=True)
  File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/", line 642, in _run_interface
    return self._run_command(execute)
  File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/", line 750, in _run_command
    raise NodeExecutionError(
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node measures.

Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/base/", line 398, in run
    runtime = self._run_interface(runtime)
  File "/opt/conda/lib/python3.9/site-packages/mriqc/interfaces/", line 164, in _run_interface
    stats = summary_stats(inudata, pvmdata, airdata, erode=erode)
  File "/opt/conda/lib/python3.9/site-packages/mriqc/qc/", line 637, in summary_stats
    "p95": float(np.percentile(img[mask == 1], 95)),
  File "<__array_function__ internals>", line 180, in percentile
  File "/opt/conda/lib/python3.9/site-packages/numpy/lib/", line 4134, in percentile
    return _quantile_unchecked(
  File "/opt/conda/lib/python3.9/site-packages/numpy/lib/", line 4383, in _quantile_unchecked
    r, k = _ureduce(a,
  File "/opt/conda/lib/python3.9/site-packages/numpy/lib/", line 3702, in _ureduce
    r = func(a, **kwargs)
  File "/opt/conda/lib/python3.9/site-packages/numpy/lib/", line 4552, in _quantile_ureduce_func
    result = _quantile(arr,
  File "/opt/conda/lib/python3.9/site-packages/numpy/lib/", line 4658, in _quantile
    take(arr, indices=-1, axis=DATA_AXIS)
  File "<__array_function__ internals>", line 180, in take
  File "/opt/conda/lib/python3.9/site-packages/numpy/core/", line 190, in take
    return _wrapfunc(a, 'take', indices, axis=axis, out=out, mode=mode)
  File "/opt/conda/lib/python3.9/site-packages/numpy/core/", line 57, in _wrapfunc
    return bound(*args, **kwds)
IndexError: cannot do a non-empty take from an empty axes.

Hi @mdemi,

What was your full mriqc command, and are your data BJDS valid?


1 Like

This is going to be an empty mask. I would check your input data to make sure nothing looks obviously terrible, try rerunning in case it is non-deterministically empty, and if that fails open a bug report on MRIQC that the interface is not checking for empty masks before masking.

1 Like

Hi Steven -

Yes, the data passed the BIDS validation and the command was:

# run MRIQC pipeline
singularity run --cleanenv \
-B ${data_dir}/bids_dir/sub-${subj_id}_ses-${ses_id}:/bids_dir \
-B ${data_dir}/processed/mriqc_v22_0_6/sub-${subj_id}_ses-${ses_id}:/output_dir \
-B ${data_dir}/work_dir/mriqc_v22_0_6/sub-${subj_id}_ses-${ses_id}:/wd \
${sif_img} \
/bids_dir /output_dir participant \
--ants-nthreads 8 \
--nprocs 12 \
--mem_gb 30 \
-vv \
--verbose-reports \
-w /wd \
-m bold T1w T2w