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

FIX: Address non-empty take from empty axes (anatomical IQMs) #1077

Closed oesteban closed 1 year ago

oesteban commented 1 year ago

This patch addresses this problem encountered in some occassions, where the mask on which summary stats are to be calculated is too small.

Fixes: #1048. Fixes: #868.

oesteban commented 1 year ago

@demidenm could you test this branch?

demidenm commented 1 year ago

@oesteban - Thanks for the help with this & the follow up!

I couldn't easily test the branch but I pulled the anatomical.py so I used the following to test it on two subjects:

...
sif_img=mriqc_22.0.6.sif
anatpy_new=anatomical.py
anatpy_old=/opt/conda/lib/python3.9/site-packages/mriqc/qc/anatomical.py
...
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 \
-B ${anatpy_new}:${anatpy_old} \
${sif_img} \ 
...

I got the following error:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 398, in run
    runtime = self._run_interface(runtime)
  File "/opt/conda/lib/python3.9/site-packages/mriqc/interfaces/functional.py", line 119, in _run_interface
    stats = summary_stats(epidata, mskdata, erode=True)
  File "/opt/conda/lib/python3.9/site-packages/mriqc/qc/anatomical.py", line 607, in summary_stats
    nvox = mask.sum()
AttributeError: 'tuple' object has no attribute 'sum'
oesteban commented 1 year ago

@demidenm thanks for your patience -- I made a mistake, which I hope I fixed in the latest commit.

demidenm commented 1 year ago

@oesteban - thanks for the help and follow up. It looks like that error was resolved but I am getting the following issue now. Not sure whether this is because I am using mriqc v22.0.6 and there is a newer tag v23.0.0?

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 524, in run
    result = self._run_interface(execute=True)
  File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/nodes.py", line 642, in _run_interface
    return self._run_command(execute)
  File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/nodes.py", line 750, in _run_command
    raise NodeExecutionError(
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node ComputeQI2.

Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 398, in run
    runtime = self._run_interface(runtime)
  File "/opt/conda/lib/python3.9/site-packages/mriqc/interfaces/anatomical.py", line 386, in _run_interface
    qi2, out_file = art_qi2(imdata, airdata)
  File "/opt/conda/lib/python3.9/site-packages/mriqc/qc/anatomical.py", line 462, in art_qi2
    from nireports.reportlets.nuisance import plot_qi2
ModuleNotFoundError: No module named 'nireports'
oesteban commented 1 year ago

Not sure whether this is because I am using mriqc v22.0.6 and there is a newer tag v23.0.0

Correct - we are preparing for a new 23.0.0 release. I will try to back-propagate this patch to the 22.x series though.

Thanks for the debugging!