poldracklab / tacc-openneuro

0 stars 1 forks source link

ds003540-mriqc: "Input data has incompatible dimensionality: Expect ed dimension is 4D and you provided a 3D image" #40

Open jbwexler opened 1 year ago

jbwexler commented 1 year ago

Happened for every subject. As far as I can tell, the input images are fine and 4-D.

Node: mriqc_wf.funcMRIQC.ICA Working directory: /scratch1/03201/jbwexler/work_dir/mriqc/ds003540_sub-13/mriqc_wf/funcMRIQ C/_infile..scratch1..03201..jbwexler..openneuro_derivatives..derivatives..mriqc..ds003540- mriqc..sourcedata..raw..sub-13..func..sub-13_task-rest_acq-MB3PA_bold.nii.gz/ICA

Node inputs:

ICs = approach = args = bg_image = bg_threshold = compress_report = False cov_weight = dim = dim_est = environ = {'FSLOUTPUTTYPE': 'NIFTI_GZ'} epsilon = epsilonS = in_files = log_power = mask = max_restart = maxit = migp = migpN = migp_factor = migp_shuffle = mix = mm_thresh = no_bet = True no_mask = True no_mm = True non_linearity = num_ICs = out_all = out_dir = out_mean = out_orig = out_pca = out_report = melodic_reportlet.svg out_stats = out_unmix = out_white = output_type = NIFTI_GZ pbsc = rem_cmp = remove_deriv = report = report_maps = report_mask = s_con = s_des = sep_vn = sep_whiten = smode = t_con = t_des = tr_sec = update_mask = var_norm =

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 ICA.

Traceback (most recent call last): File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 399, in run runtime = self._post_run_hook(runtime) File "/opt/conda/lib/python3.9/site-packages/niworkflows/interfaces/reportlets/segmentation.py", line 169, in _post_run_hook self._generate_report() File "/opt/conda/lib/python3.9/site-packages/niworkflows/interfaces/reportlets/segmentatio n.py", line 184, in _generate_report plot_melodic_components( File "/opt/conda/lib/python3.9/site-packages/niworkflows/viz/utils.py", line 640, in plot_melodic_components for i, img in enumerate(iter_img(os.path.join(melodic_dir, "melodic_IC.nii.gz"))): File "/opt/conda/lib/python3.9/site-packages/nilearn/image/image.py", line 676, in iter_img return check_niimg_4d(imgs, return_iterator=True) File "/opt/conda/lib/python3.9/site-packages/nilearn/_utils/niimg_conversions.py", line 379, in check_niimg_4d return check_niimg(niimg, ensure_ndim=4, return_iterator=return_iterator, File "/opt/conda/lib/python3.9/site-packages/nilearn/_utils/niimg_conversions.py", line 296, in check_niimg raise DimensionError(len(niimg.shape), ensure_ndim) nilearn._utils.exceptions.DimensionError: Input data has incompatible dimensionality: Expected dimension is 4D and you provided a 3D image. See https://nilearn.github.io/stable/manipulating_images/input_output.html.

jbwexler commented 1 year ago

@effigies any idea what might cause this?

effigies commented 1 year ago

Not off the top of my head. The source file has 8 volumes:

sub-13/func/sub-13_task-rest_acq-MB3PA_bold.nii.gz int16 [104, 104,  72,   8] 2.00x2.00x2.00x1.91  #exts: 1

I guess it's possible that with only 8 volumes you only get one component, so melodic_IC.nii.gz ends up being 3D. We could update plot_melodic_components to ensure that we get promote a 3D image to a 4D image to pass to iter_img(). It's pretty simple with slicing:

In [1]: import nibabel as nb

In [2]: img = nb.load('/home/chris/Downloads/sample_image.nii.gz')

In [3]: img.shape
Out[3]: (256, 256, 25)

In [4]: img.slicer[..., None]
Out[4]: <nibabel.nifti1.Nifti1Image at 0x7f6d0c0a6eb0>

In [5]: img.slicer[..., None].shape
Out[5]: (256, 256, 25, 1)
jbwexler commented 1 year ago

Is there a way to get MRIQC to use the newest version of niworkflows once the above fix is released? Or would we need a new release of MRIQC for that?

effigies commented 1 year ago

Easiest would be a new MRIQC release, as then you get a coherent docker image.

jbwexler commented 1 year ago

After rerunning with mriqc 23.0.1 I ran into this issue: https://github.com/poldracklab/tacc-openneuro/issues/72