nipreps / fmriprep

fMRIPrep is a robust and easy-to-use pipeline for preprocessing of diverse fMRI data. The transparent workflow dispenses of manual intervention, thereby ensuring the reproducibility of the results.
https://fmriprep.org
Apache License 2.0
636 stars 294 forks source link

[BUG] ICA-AROMA - Mask and image must be the same size #870

Closed oesteban closed 6 years ago

oesteban commented 6 years ago

From https://neurostars.org/t/runtime-error-invalid-literal-for-int-with-base-10-mask-and-image-must-be-the-same-size-during-ica-aroma-fmriprep-1-0-0-rc8/985?u=oesteban

Node: fmriprep_wf.single_subject_105_wf.func_preproc_task_future_run_01_wf.bold_confounds_wf.ica_aroma_wf.ica_aroma
Working directory: /root/src/fmriprep/work/fmriprep_wf/single_subject_105_wf/func_preproc_task_future_run_01_wf/bold_confounds_wf/ica_aroma_wf/ica_aroma

Node inputs:

TR = <undefined>
args = <undefined>
compress_report = auto
denoise_type = nonaggr
dim = <undefined>
environ = {}
feat_dir = <undefined>
fnirt_warp_file = <undefined>
generate_report = True
ignore_exception = False
in_file = /root/src/fmriprep/work/fmriprep_wf/single_subject_105_wf/func_preproc_task_future_run_01_wf/bold_confounds_wf/ica_aroma_wf/smooth/vol0000_xform-00000_merged_smooth.nii.gz
mask = <undefined>
mat_file = <undefined>
melodic_dir = /root/src/fmriprep/work/fmriprep_wf/single_subject_105_wf/func_preproc_task_future_run_01_wf/bold_confounds_wf/ica_aroma_wf/melodic
motion_parameters = /root/src/fmriprep/work/fmriprep_wf/single_subject_105_wf/func_preproc_task_future_run_01_wf/bold_hmc_wf/normalize_motion/motion_params.txt
out_dir = <undefined>
out_report = ica_aroma_reportlet.svg
report_mask = /root/src/fmriprep/work/fmriprep_wf/single_subject_105_wf/func_preproc_task_future_run_01_wf/bold_mni_trans_wf/mask_mni_tfm/ref_image_corrected_trans_masked_corrected_brain_mask_maths_trans.nii.gz
terminal_output = <undefined>

Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/plugins/multiproc.py", line 51, 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 407, in run
    self._run_interface()
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/nodes.py", line 517, in _run_interface
    self._result = 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()
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/base.py", line 1088, in run
    runtime = self._run_interface(runtime)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/common/report.py", line 55, in _run_interface
    ReportCapableInterface, self)._run_interface(runtime)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/base.py", line 1654, in _run_interface
    self.raise_exception(runtime)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/interfaces/base.py", line 1600, in raise_exception
    **runtime.dictcopy()))
RuntimeError: Command:
ICA_AROMA.py -den nonaggr -i /root/src/fmriprep/work/fmriprep_wf/single_subject_105_wf/func_preproc_task_future_run_01_wf/bold_confounds_wf/ica_aroma_wf/smooth/vol0000_xform-00000_merged_smooth.nii.gz -meldir /root/src/fmriprep/work/fmriprep_wf/single_subject_105_wf/func_preproc_task_future_run_01_wf/bold_confounds_wf/ica_aroma_wf/melodic -mc /root/src/fmriprep/work/fmriprep_wf/single_subject_105_wf/func_preproc_task_future_run_01_wf/bold_hmc_wf/normalize_motion/motion_params.txt -o /root/src/fmriprep/work/fmriprep_wf/single_subject_105_wf/func_preproc_task_future_run_01_wf/bold_confounds_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 <module>
    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
chrisgorgo commented 6 years ago

After reading https://github.com/maartenmennes/ICA-AROMA/issues/16 I'm surprised this is not happening more often. @jdkent have you run into this before?

Potential solution would be to reslice the ICA components to desired resolution/bounding box prior to passing them to AROMA.

jdkent commented 6 years ago

I haven't ran into this problem yet, but after reading the issue I'm surprised I haven't.

oesteban commented 6 years ago

I push this forward until we get further info from maartenmennes/ICA-AROMA#16 (pinging @maartenmennes) or we find out the proper mask ourselves.

maartenmennes commented 6 years ago

This is not happening more often as typically people stay in native space and provide the transformations to AROMA. That way AROMA can put the melodic_IC file into the FSL supplied - read grid size - MNI152 2mm space which is 91x109x91 in size.

as indicated in maartenmennes/ICA-AROMA/issues/16 it was a deliberate choice to bring the components to standard space, rather than bringing the masks to native space. So yes, in this case grid size is unfortunately something to keep in mind... We should implement some proper checking and error messaging in AROMA though.

chrisgorgo commented 6 years ago

I was wondering why this is not happening more often in context of FMRIPREP because we a) feed normalized data to aroma and b) keep the original grid and resolution of the bold data.

The only way I could see people avoiding this problem in the past was setting output grid to 2mm space which is 91x109x91.

Could aroma consider reslicing the masks to input data (for example using nilearn reslice_to_img)? Maybe this could be enabled by a special flag if you are afraid it could lead to misuse.

Best, Chris

On Feb 13, 2018 11:33 PM, "Maarten Mennes" notifications@github.com wrote:

This is not happening more often as typically people stay in native space and provide the transformations to AROMA. That way AROMA can put the melodic_IC file into the FSL supplied - read grid size - MNI152 2mm space which is 91x109x91 in size.

as indicated in maartenmennes/ICA-AROMA#16 https://github.com/maartenmennes/ICA-AROMA/issues/16 it was a deliberate choice to bring the components to standard space, rather than bringing the masks to native space. So yes, in this case grid size is unfortunately something to keep in mind... We should implement some proper checking and error messaging in AROMA though.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/poldracklab/fmriprep/issues/870#issuecomment-365519842, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOkp6qO943DaQBS_-oWTEDTUfRn2oZLks5tUoxBgaJpZM4QzjOC .

chrisgorgo commented 6 years ago

Another reported case: https://neurostars.org/t/fmriprep-error-when-performing-aroma-and-select-template-resampling-grid-2mm/1566

chrisgorgo commented 6 years ago

In the above case AROMA works only if the --template-resampling-grid 2mm argument is not specified.