Did anyone ever find a solution to this? I just ran into this problem myself, where the code crashes within a Docker container, but runs fine in the terminal. Code and error message copied below.
import nibabel as nib
import numpy as np
import nipype.pipeline.engine as pe
import nipype.interfaces.fsl as fsl
import os, glob
#### INPUT ####
path_base = '/home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/*/model/fwhm_5.0*/_modelestimate0/'
work_dir = '/home/neuro/workdir/2020-02-28_simple_lvl2/'
con_list = [
# 'cope1_instructions.nii.gz',
'cope2_speech_prep.nii.gz',
'cope3_no_speech.nii.gz'
]
########
fixed_fx = pe.Workflow(name='fixedfx')
copemerge = pe.MapNode(
interface=fsl.Merge(dimension='t'),
iterfield=['in_files'],
name='copemerge')
varcopemerge = pe.MapNode(
interface=fsl.Merge(dimension='t'),
iterfield=['in_files'],
name='varcopemerge')
level2model = pe.Node(interface=fsl.L2Model(), name='l2model')
flameo = pe.MapNode(
interface=fsl.FLAMEO(run_mode='flame1'),
name='flameo',
iterfield=['cope_file', 'var_cope_file'])
fixed_fx.connect([
(copemerge, flameo, [('merged_file', 'cope_file')]),
(varcopemerge, flameo, [('merged_file', 'var_cope_file')]),
(level2model, flameo, [('design_mat', 'design_file'),
('design_con', 't_con_file'),
('design_grp', 'cov_split_file')]),
])
for con in con_list:
if not os.path.exists(os.path.join(work_dir, con.split('.')[0])):
os.mkdir(os.path.join(work_dir, con.split('.')[0]))
fixed_fx.base_dir = os.path.join(work_dir, con.split('.')[0])
print('working on con:', con)
cope_path = [path_base + con]
varcope_path = [path_base + 'var' + con]
# get files
cope_list = glob.glob(cope_path[0])
varcope_list = glob.glob(varcope_path[0])
# build mask.
mask = np.mean(np.array([nib.load(f).get_data() for f in cope_list]), axis=0)
mask[mask!=0] = 1
nib.save(nib.Nifti1Image(mask, nib.load(cope_list[0]).affine, nib.load(cope_list[0]).header),
os.path.join(work_dir, 'mask.nii.gz'))
mask_file = os.path.join(work_dir, 'mask.nii.gz')
fixed_fx.inputs.flameo.mask_file = mask_file
fixed_fx.inputs.copemerge.in_files = cope_list
fixed_fx.inputs.varcopemerge.in_files = varcope_list
fixed_fx.inputs.l2model.num_copes = len(cope_list)
fixed_fx.run()
working on con: cope1_instructions.nii.gz
200228-22:58:03,729 nipype.workflow INFO:
Workflow fixedfx settings: ['check', 'execution', 'logging', 'monitoring']
200228-22:58:03,789 nipype.workflow INFO:
Running serially.
200228-22:58:03,791 nipype.workflow INFO:
[Node] Setting-up "fixedfx.l2model" in "/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/l2model".
200228-22:58:03,805 nipype.workflow INFO:
[Node] Running "l2model" ("nipype.interfaces.fsl.model.L2Model")
200228-22:58:03,838 nipype.workflow INFO:
[Node] Finished "fixedfx.l2model".
200228-22:58:03,840 nipype.workflow INFO:
[Node] Setting-up "fixedfx.varcopemerge" in "/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/varcopemerge".
200228-22:58:04,49 nipype.workflow INFO:
[Node] Setting-up "_varcopemerge0" in "/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/varcopemerge/mapflow/_varcopemerge0".
200228-22:58:04,207 nipype.workflow INFO:
[Node] Running "_varcopemerge0" ("nipype.interfaces.fsl.utils.Merge"), a CommandLine Interface with command:
fslmerge -t varcope1_instructions_merged.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-001/model/fwhm_5.0sub-001/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-002/model/fwhm_5.0sub-002/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-003/model/fwhm_5.0sub-003/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-004/model/fwhm_5.0sub-004/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-005/model/fwhm_5.0sub-005/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-006/model/fwhm_5.0sub-006/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-007/model/fwhm_5.0sub-007/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-008/model/fwhm_5.0sub-008/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-009/model/fwhm_5.0sub-009/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-010/model/fwhm_5.0sub-010/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-011/model/fwhm_5.0sub-011/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-012/model/fwhm_5.0sub-012/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-013/model/fwhm_5.0sub-013/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-015/model/fwhm_5.0sub-015/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-016/model/fwhm_5.0sub-016/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-019/model/fwhm_5.0sub-019/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-022/model/fwhm_5.0sub-022/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-023/model/fwhm_5.0sub-023/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-024/model/fwhm_5.0sub-024/_modelestimate0/varcope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-025/model/fwhm_5.0sub-025/_modelestimate0/varcope1_instructions.nii.gz
200228-22:58:20,824 nipype.workflow INFO:
[Node] Finished "_varcopemerge0".
200228-22:58:20,836 nipype.workflow INFO:
[Node] Finished "fixedfx.varcopemerge".
200228-22:58:20,837 nipype.workflow INFO:
[Node] Setting-up "fixedfx.copemerge" in "/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/copemerge".
200228-22:58:21,39 nipype.workflow INFO:
[Node] Setting-up "_copemerge0" in "/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/copemerge/mapflow/_copemerge0".
200228-22:58:21,195 nipype.workflow INFO:
[Node] Running "_copemerge0" ("nipype.interfaces.fsl.utils.Merge"), a CommandLine Interface with command:
fslmerge -t cope1_instructions_merged.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-001/model/fwhm_5.0sub-001/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-002/model/fwhm_5.0sub-002/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-003/model/fwhm_5.0sub-003/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-004/model/fwhm_5.0sub-004/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-005/model/fwhm_5.0sub-005/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-006/model/fwhm_5.0sub-006/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-007/model/fwhm_5.0sub-007/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-008/model/fwhm_5.0sub-008/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-009/model/fwhm_5.0sub-009/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-010/model/fwhm_5.0sub-010/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-011/model/fwhm_5.0sub-011/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-012/model/fwhm_5.0sub-012/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-013/model/fwhm_5.0sub-013/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-015/model/fwhm_5.0sub-015/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-016/model/fwhm_5.0sub-016/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-019/model/fwhm_5.0sub-019/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-022/model/fwhm_5.0sub-022/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-023/model/fwhm_5.0sub-023/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-024/model/fwhm_5.0sub-024/_modelestimate0/cope1_instructions.nii.gz /home/neuro/data/stress_combinebaseline_v2/stress_combinebaseline_v2/smooth/sub-025/model/fwhm_5.0sub-025/_modelestimate0/cope1_instructions.nii.gz
200228-22:58:37,714 nipype.workflow INFO:
[Node] Finished "_copemerge0".
200228-22:58:37,723 nipype.workflow INFO:
[Node] Finished "fixedfx.copemerge".
200228-22:58:37,724 nipype.workflow INFO:
[Node] Setting-up "fixedfx.flameo" in "/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/flameo".
200228-22:58:37,797 nipype.workflow INFO:
[Node] Setting-up "_flameo0" in "/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/flameo/mapflow/_flameo0".
200228-22:58:37,830 nipype.workflow INFO:
[Node] Running "_flameo0" ("nipype.interfaces.fsl.model.FLAMEO"), a CommandLine Interface with command:
flameo --copefile=/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/copemerge/mapflow/_copemerge0/cope1_instructions_merged.nii.gz --covsplitfile=/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/l2model/design.grp --designfile=/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/l2model/design.mat --ld=stats --maskfile=/home/neuro/workdir/2020-02-28_simple_lvl2/mask.nii.gz --runmode=flame1 --tcontrastsfile=/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/l2model/design.con --varcopefile=/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/varcopemerge/mapflow/_varcopemerge0/varcope1_instructions_merged.nii.gz
200228-22:58:38,87 nipype.interface INFO:
stdout 2020-02-28T22:58:38.086954:Log directory is: stats
200228-22:58:38,102 nipype.interface INFO:
stdout 2020-02-28T22:58:38.102748:Setting up:
200228-22:58:44,135 nipype.interface INFO:
stdout 2020-02-28T22:58:44.129119:ntptsing=20.000000
200228-22:58:44,756 nipype.interface INFO:
stdout 2020-02-28T22:58:44.129119:
200228-22:58:44,761 nipype.interface INFO:
stdout 2020-02-28T22:58:44.129119:evs_group=1.000000
200228-22:58:44,763 nipype.interface INFO:
stdout 2020-02-28T22:58:44.129119:
200228-22:58:44,933 nipype.interface INFO:
stderr 2020-02-28T22:58:44.933059:Aborted
200228-22:58:45,155 nipype.workflow WARNING:
Storing result file without outputs
200228-22:58:45,162 nipype.workflow WARNING:
[Node] Error on "_flameo0" (/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/flameo/mapflow/_flameo0)
200228-22:58:45,177 nipype.workflow WARNING:
[Node] Error on "fixedfx.flameo" (/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/flameo)
200228-22:58:45,187 nipype.workflow ERROR:
Node flameo failed to run on host 9f1a15736eea.
200228-22:58:45,190 nipype.workflow ERROR:
Saving crash info to /home/neuro/scripts/jupyter_scrap/crash-20200228-225845-root-flameo-6a557025-6f3e-49cd-9c7e-6ed7c370010f.pklz
Traceback (most recent call last):
File "/opt/miniconda-latest/envs/py36/lib/python3.6/site-packages/nipype/pipeline/plugins/linear.py", line 48, in run
node.run(updatehash=updatehash)
File "/opt/miniconda-latest/envs/py36/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py", line 479, in run
result = self._run_interface(execute=True)
File "/opt/miniconda-latest/envs/py36/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py", line 1282, in _run_interface
self.config['execution']['stop_on_first_crash'])))
File "/opt/miniconda-latest/envs/py36/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py", line 1204, in _collate_results
(self.name, '\n'.join(msg)))
Exception: Subnodes of node: flameo failed:
Subnode 0 failed
Error: Traceback (most recent call last):
File "/opt/miniconda-latest/envs/py36/lib/python3.6/site-packages/nipype/pipeline/engine/utils.py", line 103, in nodelist_runner
result = node.run(updatehash=updatehash)
File "/opt/miniconda-latest/envs/py36/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py", line 479, in run
result = self._run_interface(execute=True)
File "/opt/miniconda-latest/envs/py36/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py", line 569, in _run_interface
return self._run_command(execute)
File "/opt/miniconda-latest/envs/py36/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py", line 662, in _run_command
result = self._interface.run(cwd=outdir)
File "/opt/miniconda-latest/envs/py36/lib/python3.6/site-packages/nipype/interfaces/base/core.py", line 376, in run
runtime = self._run_interface(runtime)
File "/opt/miniconda-latest/envs/py36/lib/python3.6/site-packages/nipype/interfaces/fsl/model.py", line 1072, in _run_interface
return super(FLAMEO, self)._run_interface(runtime)
File "/opt/miniconda-latest/envs/py36/lib/python3.6/site-packages/nipype/interfaces/base/core.py", line 761, in _run_interface
self.raise_exception(runtime)
File "/opt/miniconda-latest/envs/py36/lib/python3.6/site-packages/nipype/interfaces/base/core.py", line 698, in raise_exception
).format(**runtime.dictcopy()))
RuntimeError: Command:
flameo --copefile=/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/copemerge/mapflow/_copemerge0/cope1_instructions_merged.nii.gz --covsplitfile=/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/l2model/design.grp --designfile=/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/l2model/design.mat --ld=stats --maskfile=/home/neuro/workdir/2020-02-28_simple_lvl2/mask.nii.gz --runmode=flame1 --tcontrastsfile=/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/l2model/design.con --varcopefile=/home/neuro/workdir/2020-02-28_simple_lvl2/cope1_instructions/fixedfx/varcopemerge/mapflow/_varcopemerge0/varcope1_instructions_merged.nii.gz
Standard output:
Log directory is: stats
Setting up:
ntptsing=20.000000
evs_group=1.000000
Standard error:
Aborted
Return code: 134
When creating this crashfile, the results file corresponding
to the node could not be found.
200228-22:58:45,195 nipype.workflow INFO:
***********************************
200228-22:58:45,197 nipype.workflow ERROR:
could not run node: fixedfx.flameo
200228-22:58:45,198 nipype.workflow INFO:
crashfile: /home/neuro/scripts/jupyter_scrap/crash-20200228-225845-root-flameo-6a557025-6f3e-49cd-9c7e-6ed7c370010f.pklz
200228-22:58:45,199 nipype.workflow INFO:
***********************************
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-19-32ca7d40d850> in <module>
58 fixed_fx.inputs.l2model.num_copes = len(cope_list)
59
---> 60 fixed_fx.run()
61
/opt/miniconda-latest/envs/py36/lib/python3.6/site-packages/nipype/pipeline/engine/workflows.py in run(self, plugin, plugin_args, updatehash)
597 if str2bool(self.config['execution']['create_report']):
598 self._write_report_info(self.base_dir, self.name, execgraph)
--> 599 runner.run(execgraph, updatehash=updatehash, config=self.config)
600 datestr = datetime.utcnow().strftime('%Y%m%dT%H%M%S')
601 if str2bool(self.config['execution']['write_provenance']):
/opt/miniconda-latest/envs/py36/lib/python3.6/site-packages/nipype/pipeline/plugins/linear.py in run(self, graph, config, updatehash)
69
70 os.chdir(old_wd) # Return wherever we were before
---> 71 report_nodes_not_run(notrun)
/opt/miniconda-latest/envs/py36/lib/python3.6/site-packages/nipype/pipeline/plugins/tools.py in report_nodes_not_run(notrun)
93 logger.debug(subnode._id)
94 logger.info("***********************************")
---> 95 raise RuntimeError(('Workflow did not execute cleanly. '
96 'Check log for details'))
97
RuntimeError: Workflow did not execute cleanly. Check log for details