ICA-AROMA error in FMRIPREP: 'Mask and image must be the same size'

Hi – I’m using Docker to run the latest version of FMRIPREP and I’m encountering an error when it reaches ICA-AROMA.

ValueError: invalid literal for int() with base 10: ‘Mask and image must be the same size’

I’ve tried to run it on a few different subjects and the error seems to be reproducible. I’ve also tried different flags in the FMRIPREP command (e.g., --ignore-aroma-denoising-errors and --low-mem).

My command is below:

docker run -it --rm -v /Volumes/Smith_Group/BIDS_testing_TUBRIC/PARAM_TEST/BIDS_out_all:/data:ro -v /Volumes/Smith_Group/BIDS_testing_TUBRIC/PARAM_TEST/FMRIPREP_new:/out -v /Users/tug87422/Desktop/license.txt:/opt/freesurfer/license.txt poldracklab/fmriprep:latest /data /out participant --participant_label 103 --ignore slicetiming --use-aroma --ignore-aroma-denoising-errors --fs-no-reconall --fs-license-file /opt/freesurfer/license.txt --low-mem

The full output is below:

 [Node] Error on "fmriprep_wf.single_subject_104_wf.func_preproc_task_rest_run_08_wf.ica_aroma_wf.ica_aroma" (/root/src/fmriprep/work/fmriprep_wf/single_subject_104_wf/func_preproc_task_rest_run_08_wf/ica_aroma_wf/ica_aroma)

Traceback (most recent call last):
File “/usr/local/miniconda/bin/fmriprep”, line 11, in
load_entry_point(‘fmriprep==1.0.8’, ‘console_scripts’, ‘fmriprep’)()
File “/usr/local/miniconda/lib/python3.6/site-packages/fmriprep/cli/run.py”, line 267, in main
fmriprep_wf.run(**plugin_settings)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/workflows.py”, line 602, in run
runner.run(execgraph, updatehash=updatehash, config=self.config)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/plugins/base.py”, line 168, in run
self._clean_queue(jobid, graph, result=result))
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/plugins/base.py”, line 227, in _clean_queue
raise RuntimeError("".join(result[‘traceback’]))
RuntimeError: Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/plugins/multiproc.py”, line 68, in run_node
result[‘result’] = node.run(updatehash=updatehash)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/nodes.py”, line 487, in run
result = self._run_interface(execute=True)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/nodes.py”, line 571, in _run_interface
return self._run_command(execute)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/nodes.py”, line 650, in _run_command
result = self._interface.run(cwd=outdir)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/base/core.py”, line 516, in run
runtime = self._run_interface(runtime)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/interfaces/report_base.py”, line 51, in _run_interface
ReportCapableInterface, self)._run_interface(runtime)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/base/core.py”, line 1023, in _run_interface
self.raise_exception(runtime)
File “/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/base/core.py”, line 960, in raise_exception
).format(**runtime.dictcopy()))
RuntimeError: Command:
ICA_AROMA.py -den nonaggr -i /root/src/fmriprep/work/fmriprep_wf/single_subject_104_wf/func_preproc_task_rest_run_08_wf/ica_aroma_wf/smooth/vol0000_xform-00000_merged_smooth.nii.gz -meldir /root/src/fmriprep/work/fmriprep_wf/single_subject_104_wf/func_preproc_task_rest_run_08_wf/ica_aroma_wf/melodic -mc /root/src/fmriprep/work/fmriprep_wf/single_subject_104_wf/func_preproc_task_rest_run_08_wf/bold_hmc_wf/normalize_motion/motion_params.txt -o /root/src/fmriprep/work/fmriprep_wf/single_subject_104_wf/func_preproc_task_rest_run_08_wf/ica_aroma_wf/ica_aroma
Standard output:

------------------------------- RUNNING ICA-AROMA -------------------------------
--------------- ‘ICA-based Automatic Removal Of Motion Artifacts’ ---------------

Step 1) MELODIC

  • The existing/specified MELODIC directory will be used.
  • The MELODIC directory does not contain the required ‘stats’ folder. Mixture modeling on the Z-statistical maps will be run.
    Step 2) Automatic classification of the components
  • registering the spatial maps to MNI
  • extracting the CSF & Edge fraction features
    Standard error:
    Traceback (most recent call last):
    File “/opt/ICA-AROMA/ICA_AROMA.py”, line 200, in
    edgeFract, csfFract = aromafunc.feature_spatial(fslDir, outDir, scriptDir, melIC_MNI)
    File “/opt/ICA-AROMA/ICA_AROMA_functions.py”, line 388, in feature_spatial
    ‘-V | awk ‘{print $1}’’])))
    ValueError: invalid literal for int() with base 10: ‘Mask and image must be the same size’
    Return code: 1

Any ideas?

Thanks!
David

Hi David,

Thanks for providing your command and error output. This issue appears to be the same as others have posted and @oesteban is working hard on a fix. You can follow the progress here. However, the fmriprep team may be looking for people to test out the fix to make sure it actually squashes the issue.

There was a link to another person with a very similar problem that was requested to test the revised fmriprep software, I’ll dig it up.

James is probably referring to this question: Fmriprep Error when performing AROMA and select --template-resampling-grid 2mm

As I recommended in that thread, could you run:

docker run -it --rm -v /Volumes/Smith_Group/BIDS_testing_TUBRIC/PARAM_TEST/BIDS_out_all:/data:ro -v /Volumes/Smith_Group/BIDS_testing_TUBRIC/PARAM_TEST/FMRIPREP_new:/out -v /Users/tug87422/Desktop/license.txt:/opt/freesurfer/license.txt poldracklab/fmriprep:1.0.12-dev0 /data /out participant --participant_label 103 --ignore slicetiming --use-aroma --ignore-aroma-denoising-errors --fs-no-reconall --fs-license-file /opt/freesurfer/license.txt --low-mem

(please note that I’ve just rewritten the docker tag latest with a development test version 1.0.12-dev0).

Cheers,
Oscar

Thanks, Oscar and James! Sorry I missed that other post. I ran the suggested command and it seemed to resolve that issue for that subject. However, when I ran it on a different subject, I encountered a new error (which I don’t think has been mentioned on NeuroStars):

[Node] Running "ica_aroma_confound_extraction" ("fmriprep.interfaces.confounds.ICAConfounds")
180502-07:17:39,469 workflow WARNING:
	 [Node] Error on "fmriprep_wf.single_subject_104_wf.func_preproc_task_rest_run_08_wf.ica_aroma_wf.ica_aroma_confound_extraction" (/root/src/fmriprep/work/fmriprep_wf/single_subject_104_wf/func_preproc_task_rest_run_08_wf/ica_aroma_wf/ica_aroma_confound_extraction)
Traceback (most recent call last):
  File "/usr/local/miniconda/bin/fmriprep", line 11, in <module>
    load_entry_point('fmriprep==1.0.12.dev0', 'console_scripts', 'fmriprep')()
  File "/usr/local/miniconda/lib/python3.6/site-packages/fmriprep/cli/run.py", line 280, in main
    fmriprep_wf.run(**plugin_settings)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/workflows.py", line 595, in run
    runner.run(execgraph, updatehash=updatehash, config=self.config)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/plugins/base.py", line 168, in run
    self._clean_queue(jobid, graph, result=result))
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/plugins/base.py", line 227, in _clean_queue
    raise RuntimeError("".join(result['traceback']))
RuntimeError: Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/plugins/multiproc.py", line 68, in run_node
    result['result'] = node.run(updatehash=updatehash)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/nodes.py", line 479, in run
    result = self._run_interface(execute=True)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/nodes.py", line 563, in _run_interface
    return self._run_command(execute)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/nodes.py", line 643, in _run_command
    result = self._interface.run(cwd=outdir)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/base/core.py", line 516, in run
    runtime = self._run_interface(runtime)
  File "/usr/local/miniconda/lib/python3.6/site-packages/fmriprep/interfaces/confounds.py", line 112, in _run_interface
    self.inputs.in_directory, newpath=runtime.cwd)
  File "/usr/local/miniconda/lib/python3.6/site-packages/fmriprep/interfaces/confounds.py", line 239, in _get_ica_confounds
    aggr_confounds = np.asarray([melodic_mix_arr.T[x] for x in motion_ic_indices])
TypeError: 'numpy.int64' object is not iterable

I’m not sure if it’s related, but I’ve noticed the masking fails for some of these data (seems to happen when “prescan normalization” is turned on during acquisition). The recent fix seemed to prevent crashes for the subject here (fmriprep output here: https://osf.io/876pn/), but for this other subject it seems to still be failing – but with this new error.

Hi @dvsmith, we would be extremely interested in adding some of those BOLD runs with “prescan normalization” to add in our test battery. We would compute the reference image from them and keep just that single, reference volume (not everything). Could you share some of those?

As regards the error in ica_aroma_confound_extraction, I’ve filed this (https://github.com/poldracklab/fmriprep/issues/1094). Could you share some data (for instance through OpenNeuro.org) for us to replicate the problem?

Thanks!

Thanks, Oscar! I’d be happy to share some of the images privately. These scans were from developmental time on our scanner to test out sequences, so we did not use our standard consent form that is compatible with public data sharing (e.g., on OpenNeuro.org).

Awesome – looks like issue has already been solved? Please let me know if you’d like me to test a new dev version of fmriprep on these data.

Hi, I just pushed poldracklab/fmriprep:1.0.12-dev7. We’ll be releasing 1.0.12 ASAP.

Cheers,
Oscar

Success! Thanks for the quick fix. Let me know if you still want examples for the pre-scan normalization. I’m seeing the same masking issues with those data, but it’s unclear to me whether it’s a quirk with those acquisition settings.

Hi @dvsmith, we’d love to get those examples. @effigies is putting together a set of challenging datasets to test out the masks creation workflow. We will only keep the 50 first timepoints of your images, sounds okay?

Thanks very much!

1 Like

Hi @oesteban

In 1.0.12 is the flag --template MNI152Lin still necessary to perform ICA-AROMA with --template-resampling-grid 2mm?

Thank you very much!

Good question! None of those are necessary anymore.

Hi @oesteban

So should the following command work?

fmriprep-docker $BIDSfolder $BIDSfolder participant --participant_label ${s} --fs-no-reconall --template-resampling-grid 2mm --use-aroma

I still need the -template-resampling-grid 2mm flag if I want 2mm output grid, right?

Thank you very much!

That looks good. Yes, if you want your outputs in the 2mm grid then you need --template-resampling-grid 2mm. I think the freesurfer license is still necessary (despite --fs-no-reconall).

Cheers,
Oscar

Hey @oesteban and @effigies – can I send you guys a Dropbox link privately? I don’t want to share these data publicly.

Sure. My email is this username @gmail.

2 Likes