fMRI preprocessing: Standard error: Mask and image must be the same size

Dear all,

I am currently trying to apply the preprocessing pipeline from Michael Notter’s tutorial (https://miykael.github.io/nipype_tutorial/notebooks/handson_preprocessing.html) to my data. I recreated the workflow but when running it breaks with “Error on “preproc_wf.susan.median”” and further it gives “Standard error:
Mask and image must be the same size”.

Below you find the output up to the error.

Thanks for your help in advance!

191114-11:44:35,831 nipype.workflow INFO:
	 Workflow preproc_wf settings: ['check', 'execution', 'logging', 'monitoring']
191114-11:44:35,848 nipype.workflow INFO:
	 Running in parallel.
191114-11:44:35,853 nipype.workflow INFO:
	 [MultiProc] Running 0 tasks, and 1 jobs ready. Free memory (GB): 28.06/28.06, Free processors: 4/4.
191114-11:44:35,960 nipype.workflow INFO:
	 [Node] Setting-up "preproc_wf.datagrabber" in "/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/datagrabber".
191114-11:44:35,997 nipype.workflow INFO:
	 [Node] Running "datagrabber" ("nipype.interfaces.io.DataGrabber")
191114-11:44:36,13 nipype.workflow INFO:
	 [Node] Finished "preproc_wf.datagrabber".
191114-11:44:37,858 nipype.workflow INFO:
	 [Job 0] Completed (preproc_wf.datagrabber).
191114-11:44:37,868 nipype.workflow INFO:
	 [MultiProc] Running 0 tasks, and 2 jobs ready. Free memory (GB): 28.06/28.06, Free processors: 4/4.
191114-11:44:37,985 nipype.workflow INFO:
	 [Node] Setting-up "preproc_wf.gunzip_func" in "/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/gunzip_func".
191114-11:44:37,990 nipype.workflow INFO:
	 [Node] Running "gunzip_func" ("nipype.algorithms.misc.Gunzip")
191114-11:44:37,985 nipype.workflow INFO:
	 [Node] Setting-up "preproc_wf.gunzip_anat" in "/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/gunzip_anat".
191114-11:44:38,5 nipype.workflow INFO:
	 [Node] Running "gunzip_anat" ("nipype.algorithms.misc.Gunzip")
191114-11:44:38,177 nipype.workflow INFO:
	 [Node] Finished "preproc_wf.gunzip_anat".
191114-11:44:39,449 nipype.workflow INFO:
	 [Node] Finished "preproc_wf.gunzip_func".
191114-11:44:39,858 nipype.workflow INFO:
	 [Job 1] Completed (preproc_wf.gunzip_anat).
191114-11:44:39,863 nipype.workflow INFO:
	 [Job 6] Completed (preproc_wf.gunzip_func).
191114-11:44:39,870 nipype.workflow INFO:
	 [MultiProc] Running 0 tasks, and 2 jobs ready. Free memory (GB): 28.06/28.06, Free processors: 4/4.
191114-11:44:39,974 nipype.workflow INFO:
	 [Node] Setting-up "preproc_wf.mcflirt" in "/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/mcflirt".
191114-11:44:39,974 nipype.workflow INFO:
	 [Node] Setting-up "preproc_wf.segment" in "/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/segment".
191114-11:44:39,978 nipype.workflow INFO:
	 [Node] Running "mcflirt" ("nipype.interfaces.fsl.preprocess.MCFLIRT"), a CommandLine Interface with command:
mcflirt -in /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/gunzip_func/DICOM_cmrr_mbep2d_bold_H20_44_MB2_20190930162755_10.nii -meanvol -out /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/mcflirt/DICOM_cmrr_mbep2d_bold_H20_44_MB2_20190930162755_10_mcf.nii.gz -plots
191114-11:44:39,981 nipype.workflow INFO:
	 [Node] Running "segment" ("nipype.interfaces.spm.preprocess.NewSegment")
191114-11:44:41,858 nipype.workflow INFO:
	 [MultiProc] Running 2 tasks, and 0 jobs ready. Free memory (GB): 27.66/28.06, Free processors: 2/4.
                     Currently running:
                       * preproc_wf.mcflirt
                       * preproc_wf.segment
191114-11:47:33,114 nipype.workflow INFO:
	 [Node] Finished "preproc_wf.mcflirt".
191114-11:47:34,16 nipype.workflow INFO:
	 [Job 7] Completed (preproc_wf.mcflirt).
191114-11:47:34,18 nipype.workflow INFO:
	 [MultiProc] Running 1 tasks, and 1 jobs ready. Free memory (GB): 27.86/28.06, Free processors: 3/4.
                     Currently running:
                       * preproc_wf.segment
191114-11:47:34,84 nipype.workflow INFO:
	 [Node] Setting-up "preproc_wf.art" in "/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/art".
191114-11:47:34,89 nipype.workflow INFO:
	 [Node] Running "art" ("nipype.algorithms.rapidart.ArtifactDetect")
191114-11:47:36,18 nipype.workflow INFO:
	 [MultiProc] Running 2 tasks, and 0 jobs ready. Free memory (GB): 27.66/28.06, Free processors: 2/4.
                     Currently running:
                       * preproc_wf.art
                       * preproc_wf.segment
191114-11:47:37,679 nipype.workflow INFO:
	 [Node] Finished "preproc_wf.art".
191114-11:47:38,19 nipype.workflow INFO:
	 [Job 18] Completed (preproc_wf.art).
191114-11:47:38,23 nipype.workflow INFO:
	 [MultiProc] Running 1 tasks, and 0 jobs ready. Free memory (GB): 27.86/28.06, Free processors: 3/4.
                     Currently running:
                       * preproc_wf.segment
191114-11:47:50,347 nipype.workflow INFO:
	 [Node] Finished "preproc_wf.segment".
191114-11:47:52,35 nipype.workflow INFO:
	 [Job 2] Completed (preproc_wf.segment).
191114-11:47:52,42 nipype.workflow INFO:
	 [MultiProc] Running 0 tasks, and 2 jobs ready. Free memory (GB): 28.06/28.06, Free processors: 4/4.
191114-11:47:52,104 nipype.workflow INFO:
	 [Node] Setting-up "preproc_wf.resample" in "/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/resample".
191114-11:47:52,104 nipype.workflow INFO:
	 [Node] Setting-up "preproc_wf.threshold_WM" in "/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/threshold_WM".
191114-11:47:52,109 nipype.workflow INFO:
	 [Node] Running "resample" ("nipype.interfaces.fsl.preprocess.FLIRT"), a CommandLine Interface with command:
flirt -in /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/segment/c1DICOM_t1_mprage_sag_fast_grappa2_20190930162755_11.nii -ref /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/segment/c1DICOM_t1_mprage_sag_fast_grappa2_20190930162755_11.nii -out c1DICOM_t1_mprage_sag_fast_grappa2_20190930162755_11_flirt.nii -omat c1DICOM_t1_mprage_sag_fast_grappa2_20190930162755_11_flirt.mat -applyisoxfm 4.000000
191114-11:47:52,110 nipype.workflow INFO:
	 [Node] Running "threshold_WM" ("nipype.interfaces.fsl.maths.Threshold"), a CommandLine Interface with command:
fslmaths /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/segment/c2DICOM_t1_mprage_sag_fast_grappa2_20190930162755_11.nii -thr 0.5000000000 -bin /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/threshold_WM/c2DICOM_t1_mprage_sag_fast_grappa2_20190930162755_11_thresh.nii
191114-11:47:52,607 nipype.workflow INFO:
	 [Node] Finished "preproc_wf.threshold_WM".
191114-11:47:54,35 nipype.workflow INFO:
	 [Job 5] Completed (preproc_wf.threshold_WM).
191114-11:47:54,39 nipype.workflow INFO:
	 [MultiProc] Running 1 tasks, and 1 jobs ready. Free memory (GB): 27.86/28.06, Free processors: 3/4.
                     Currently running:
                       * preproc_wf.resample
191114-11:47:54,104 nipype.workflow INFO:
	 [Node] Setting-up "preproc_wf.coreg" in "/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/coreg".
191114-11:47:54,111 nipype.workflow INFO:
	 [Node] Running "coreg" ("nipype.interfaces.fsl.preprocess.FLIRT"), a CommandLine Interface with command:
flirt -in /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/mcflirt/DICOM_cmrr_mbep2d_bold_H20_44_MB2_20190930162755_10_mcf_mean_reg.nii.gz -ref /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/gunzip_anat/DICOM_t1_mprage_sag_fast_grappa2_20190930162755_11.nii -out DICOM_cmrr_mbep2d_bold_H20_44_MB2_20190930162755_10_mcf_mean_reg_flirt.nii -omat DICOM_cmrr_mbep2d_bold_H20_44_MB2_20190930162755_10_mcf_mean_reg_flirt.mat -cost bbr -dof 6 -schedule /usr/local/fsl/etc/flirtsch/bbr.sch -wmseg /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/threshold_WM/c2DICOM_t1_mprage_sag_fast_grappa2_20190930162755_11_thresh.nii
191114-11:47:55,110 nipype.workflow INFO:
	 [Node] Finished "preproc_wf.resample".
191114-11:47:56,37 nipype.workflow INFO:
	 [Job 3] Completed (preproc_wf.resample).
191114-11:47:56,39 nipype.workflow INFO:
	 [MultiProc] Running 1 tasks, and 1 jobs ready. Free memory (GB): 27.86/28.06, Free processors: 3/4.
                     Currently running:
                       * preproc_wf.coreg
191114-11:47:56,105 nipype.workflow INFO:
	 [Node] Setting-up "preproc_wf.mask_GM" in "/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/mask_GM".
191114-11:47:56,109 nipype.workflow INFO:
	 [Node] Running "mask_GM" ("nipype.interfaces.fsl.maths.Threshold"), a CommandLine Interface with command:
fslmaths /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/resample/c1DICOM_t1_mprage_sag_fast_grappa2_20190930162755_11_flirt.nii -thr 0.5000000000 -bin -dilF /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/mask_GM/c1DICOM_t1_mprage_sag_fast_grappa2_20190930162755_11_flirt_thresh.nii
191114-11:47:56,364 nipype.workflow INFO:
	 [Node] Finished "preproc_wf.mask_GM".
191114-11:47:58,39 nipype.workflow INFO:
	 [Job 4] Completed (preproc_wf.mask_GM).
191114-11:47:58,41 nipype.workflow INFO:
	 [MultiProc] Running 1 tasks, and 0 jobs ready. Free memory (GB): 27.86/28.06, Free processors: 3/4.
                     Currently running:
                       * preproc_wf.coreg
191114-11:48:45,397 nipype.workflow INFO:
	 [Node] Finished "preproc_wf.coreg".
191114-11:48:46,90 nipype.workflow INFO:
	 [Job 8] Completed (preproc_wf.coreg).
191114-11:48:46,97 nipype.workflow INFO:
	 [MultiProc] Running 0 tasks, and 1 jobs ready. Free memory (GB): 28.06/28.06, Free processors: 4/4.
191114-11:48:46,169 nipype.workflow INFO:
	 [Node] Setting-up "preproc_wf.applywarp" in "/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/applywarp".
191114-11:48:46,175 nipype.workflow INFO:
	 [Node] Running "applywarp" ("nipype.interfaces.fsl.preprocess.FLIRT"), a CommandLine Interface with command:
flirt -in /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/mcflirt/DICOM_cmrr_mbep2d_bold_H20_44_MB2_20190930162755_10_mcf.nii.gz -ref /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/gunzip_anat/DICOM_t1_mprage_sag_fast_grappa2_20190930162755_11.nii -out DICOM_cmrr_mbep2d_bold_H20_44_MB2_20190930162755_10_mcf_flirt.nii -omat DICOM_cmrr_mbep2d_bold_H20_44_MB2_20190930162755_10_mcf_flirt.mat -applyisoxfm 4.000000 -init /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/coreg/DICOM_cmrr_mbep2d_bold_H20_44_MB2_20190930162755_10_mcf_mean_reg_flirt.mat -interp spline
191114-11:48:48,90 nipype.workflow INFO:
	 [MultiProc] Running 1 tasks, and 0 jobs ready. Free memory (GB): 27.86/28.06, Free processors: 3/4.
                     Currently running:
                       * preproc_wf.applywarp
191114-11:50:36,333 nipype.workflow INFO:
	 [Node] Finished "preproc_wf.applywarp".
191114-11:50:38,195 nipype.workflow INFO:
	 [Job 9] Completed (preproc_wf.applywarp).
191114-11:50:38,202 nipype.workflow INFO:
	 [MultiProc] Running 0 tasks, and 2 jobs ready. Free memory (GB): 28.06/28.06, Free processors: 4/4.
191114-11:50:38,268 nipype.workflow INFO:
	 [Node] Setting-up "preproc_wf.susan.mask" in "/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/susan/_run_id_1_subject_id_2/mask".
191114-11:50:38,270 nipype.workflow INFO:
	 [Node] Setting-up "preproc_wf.susan.median" in "/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/susan/_run_id_1_subject_id_2/median".
191114-11:50:38,272 nipype.workflow INFO:
	 [Node] Setting-up "_mask0" in "/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/susan/_run_id_1_subject_id_2/mask/mapflow/_mask0".
191114-11:50:38,275 nipype.workflow INFO:
	 [Node] Running "_mask0" ("nipype.interfaces.fsl.utils.ImageMaths"), a CommandLine Interface with command:
fslmaths /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/applywarp/DICOM_cmrr_mbep2d_bold_H20_44_MB2_20190930162755_10_mcf_flirt.nii -mas /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/mask_GM/c1DICOM_t1_mprage_sag_fast_grappa2_20190930162755_11_flirt_thresh.nii /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/susan/_run_id_1_subject_id_2/mask/mapflow/_mask0/DICOM_cmrr_mbep2d_bold_H20_44_MB2_20190930162755_10_mcf_flirt_mask.nii.gz
191114-11:50:38,276 nipype.workflow INFO:
	 [Node] Setting-up "_median0" in "/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/susan/_run_id_1_subject_id_2/median/mapflow/_median0".
191114-11:50:38,283 nipype.workflow INFO:
	 [Node] Running "_median0" ("nipype.interfaces.fsl.utils.ImageStats"), a CommandLine Interface with command:
fslstats /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/applywarp/DICOM_cmrr_mbep2d_bold_H20_44_MB2_20190930162755_10_mcf_flirt.nii -k /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/mask_GM/c1DICOM_t1_mprage_sag_fast_grappa2_20190930162755_11_flirt_thresh.nii -p 50 
191114-11:50:39,339 nipype.workflow WARNING:
	 Storing result file without outputs
191114-11:50:39,342 nipype.workflow WARNING:
	 [Node] Error on "_median0" (/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/susan/_run_id_1_subject_id_2/median/mapflow/_median0)
191114-11:50:39,345 nipype.workflow WARNING:
	 [Node] Error on "preproc_wf.susan.median" (/media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/susan/_run_id_1_subject_id_2/median)

exception calling callback for <Future at 0x7f6ea465f4e0 state=finished raised FileNotFoundError>
concurrent.futures.process._RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/home/marius/anaconda3/lib/python3.7/site-packages/nipype/pipeline/plugins/multiproc.py", line 69, in run_node
    result['result'] = node.run(updatehash=updatehash)
  File "/home/marius/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 479, in run
    result = self._run_interface(execute=True)
  File "/home/marius/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 1298, in _run_interface
    self.config['execution']['stop_on_first_crash'])))
  File "/home/marius/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 1220, in _collate_results
    (self.name, '\n'.join(msg)))
Exception: Subnodes of node: median failed:
Subnode 0 failed
Error: Traceback (most recent call last):

  File "/home/marius/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/utils.py", line 107, in nodelist_runner
    result = node.run(updatehash=updatehash)

  File "/home/marius/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 479, in run
    result = self._run_interface(execute=True)

  File "/home/marius/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 585, in _run_interface
    return self._run_command(execute)

  File "/home/marius/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 678, in _run_command
    result = self._interface.run(cwd=outdir)

  File "/home/marius/anaconda3/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 382, in run
    runtime = self._run_interface(runtime)

  File "/home/marius/anaconda3/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 767, in _run_interface
    self.raise_exception(runtime)

  File "/home/marius/anaconda3/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 704, in raise_exception
    ).format(**runtime.dictcopy()))

RuntimeError: Command:
fslstats /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/applywarp/DICOM_cmrr_mbep2d_bold_H20_44_MB2_20190930162755_10_mcf_flirt.nii -k /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/_run_id_1_subject_id_2/mask_GM/c1DICOM_t1_mprage_sag_fast_grappa2_20190930162755_11_flirt_thresh.nii -p 50 
Standard output:

Standard error:
Mask and image must be the same size
Return code: 3


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/marius/anaconda3/lib/python3.7/concurrent/futures/process.py", line 232, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
  File "/home/marius/anaconda3/lib/python3.7/site-packages/nipype/pipeline/plugins/multiproc.py", line 72, in run_node
    result['result'] = node.result
  File "/home/marius/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 198, in result
    op.join(self.output_dir(), 'result_%s.pklz' % self.name))
  File "/home/marius/anaconda3/lib/python3.7/site-packages/nipype/pipeline/engine/utils.py", line 304, in load_resultfile
    raise FileNotFoundError(results_file)
FileNotFoundError: /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/susan/_run_id_1_subject_id_2/median/result_median.pklz
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/marius/anaconda3/lib/python3.7/concurrent/futures/_base.py", line 324, in _invoke_callbacks
    callback(self)
  File "/home/marius/anaconda3/lib/python3.7/site-packages/nipype/pipeline/plugins/multiproc.py", line 149, in _async_callback
    result = args.result()
  File "/home/marius/anaconda3/lib/python3.7/concurrent/futures/_base.py", line 425, in result
    return self.__get_result()
  File "/home/marius/anaconda3/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
FileNotFoundError: /media/marius/data/experimental_data/arrow_gaze/participants_data/datasink/preproc_wf/susan/_run_id_1_subject_id_2/median/result_median.pklz

MANAGED BY INCF