Skip to content

Execution of spm.Level1Design blocks when the output file already exists #2612

Open
@dhrbn

Description

@dhrbn

Summary

When running spm.Level1Design a "SPM.mat" file is created in the current working directory. If this file already exists, the execution is blocked and need to be stopped manually, generating the following error message (the poll object not receiving any event).

Actual behavior

Traceback (most recent call last):
  File "/home/dhrbn/test/script.py", line 930, in _run_process
    level1design.run()
  File "/usr/local/lib/python3.5/dist-packages/nipype/interfaces/base/core.py", line 521, in run
    runtime = self._run_interface(runtime)
  File "/usr/local/lib/python3.5/dist-packages/nipype/interfaces/spm/base.py", line 377, in _run_interface
    results = self.mlab.run()
  File "/usr/local/lib/python3.5/dist-packages/nipype/interfaces/base/core.py", line 521, in run
    runtime = self._run_interface(runtime)
  File "/usr/local/lib/python3.5/dist-packages/nipype/interfaces/matlab.py", line 162, in _run_interface
    runtime = super(MatlabCommand, self)._run_interface(runtime)
  File "/usr/local/lib/python3.5/dist-packages/nipype/interfaces/base/core.py", line 1041, in _run_interface
    runtime = run_command(runtime, output=self.terminal_output)
  File "/usr/local/lib/python3.5/dist-packages/nipype/interfaces/base/core.py", line 844, in run_command
    stdout, stderr = proc.communicate()
  File "/usr/lib/python3.5/subprocess.py", line 1072, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "/usr/lib/python3.5/subprocess.py", line 1715, in _communicate
    ready = selector.select(timeout)
  File "/usr/lib/python3.5/selectors.py", line 376, in select
    fd_event_list = self._poll.poll(timeout)
KeyboardInterrupt

Expected behavior

No blocking in the execution. Note: the generated "pyscript.m" and "pyscript_level1design.m" scripts seem to be correct because they can be run with SPM12 without any problem, even if the "SPM.mat" already exists.

How to replicate the behavior

Run twice the following script (make sure to have valid data).

Script/Workflow details

from nipype.interfaces import spm
from nipype.interfaces.base import Bunch
from nipype.algorithms.modelgen import SpecifyModel
import os

# Model specification

input_units = 'scans'
functional_runs = [os.path.abspath('./4d_data.nii')]
time_repetition = 3.0
high_pass_filter_cutoff = 427.2
subject_info = Bunch(conditions=['cond1'], onsets=[[2, 50, 100, 180]], durations=[[1]])

specModel = SpecifyModel(input_units=input_units,
                         functional_runs=functional_runs,
                         time_repetition=time_repetition,
                         high_pass_filter_cutoff=high_pass_filter_cutoff,
                         subject_info=subject_info
                         )
model_spec = specModel.run()

# Level1Design execution

level1design = spm.Level1Design()
level1design.inputs.timing_units = 'scans'
level1design.inputs.interscan_interval = 3.0
level1design.inputs.bases = {'hrf': {'derivs': [0, 0]}}
level1design.inputs.session_info = model_spec.outputs.session_info
level1design.run()

Platform details:

{'nibabel_version': '2.2.1', 'commit_hash': 'fed0bd94f', 'networkx_version': '2.1', 'sys_version': '3.5.2 (default, Nov 23 2017, 16:37:01) \n[GCC 5.4.0 20160609]', 'sys_executable': '/usr/bin/python3', 'commit_source': 'installation', 'scipy_version': '1.1.0', 'sys_platform': 'linux', 'numpy_version': '1.14.3', 'traits_version': '4.6.0', 'nipype_version': '1.0.4', 'pkg_path': '/usr/local/lib/python3.5/dist-packages/nipype'}
1.0.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions