Skip to content

[WIP] Lightweight implementation of InterfaceResult #2805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
2 changes: 1 addition & 1 deletion examples/fmri_freesurfer_smooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@


def subjectinfo(subject_id):
from nipype.interfaces.base import Bunch
from nipype.utils.bunch import Bunch
from copy import deepcopy
print("Subject ID: %s\n" % str(subject_id))
output = []
Expand Down
2 changes: 1 addition & 1 deletion examples/fmri_fsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ def num_copes(files):


def subjectinfo(subject_id):
from nipype.interfaces.base import Bunch
from nipype.utils.bunch import Bunch
from copy import deepcopy
print("Subject ID: %s\n" % str(subject_id))
output = []
Expand Down
2 changes: 1 addition & 1 deletion examples/fmri_fsl_feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from nipype.algorithms import modelgen as model # model generation
from nipype.workflows.fmri.fsl import (
create_featreg_preproc, create_modelfit_workflow, create_reg_workflow)
from nipype.interfaces.base import Bunch
from nipype.utils.bunch import Bunch
"""
Preliminaries
-------------
Expand Down
2 changes: 1 addition & 1 deletion examples/fmri_fsl_reuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def num_copes(files):


def subjectinfo(subject_id):
from nipype.interfaces.base import Bunch
from nipype.utils.bunch import Bunch
from copy import deepcopy
print("Subject ID: %s\n" % str(subject_id))
output = []
Expand Down
2 changes: 1 addition & 1 deletion examples/fmri_nipy_glm.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@


def subjectinfo(subject_id):
from nipype.interfaces.base import Bunch
from nipype.utils.bunch import Bunch
from copy import deepcopy
print("Subject ID: %s\n" % str(subject_id))
output = []
Expand Down
2 changes: 1 addition & 1 deletion examples/fmri_spm.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@


def subjectinfo(subject_id):
from nipype.interfaces.base import Bunch
from nipype.utils.bunch import Bunch
from copy import deepcopy
print("Subject ID: %s\n" % str(subject_id))
output = []
Expand Down
2 changes: 1 addition & 1 deletion examples/fmri_spm_auditory.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def makelist(item):
necessary to generate an SPM design matrix.
"""

from nipype.interfaces.base import Bunch
from nipype.utils.bunch import Bunch
subjectinfo = [
Bunch(
conditions=['Task'], onsets=[list(range(6, 84, 12))], durations=[[6]])
Expand Down
2 changes: 1 addition & 1 deletion examples/fmri_spm_dartel.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def pickFieldFlow(dartel_flow_fields, subject_id):


def subjectinfo(subject_id):
from nipype.interfaces.base import Bunch
from nipype.utils.bunch import Bunch
from copy import deepcopy
print("Subject ID: %s\n" % str(subject_id))
output = []
Expand Down
2 changes: 1 addition & 1 deletion examples/fmri_spm_face.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def makelist(item):
necessary to generate an SPM design matrix.
"""

from nipype.interfaces.base import Bunch
from nipype.utils.bunch import Bunch
"""We're importing the onset times from a mat file (found on
http://www.fil.ion.ucl.ac.uk/spm/data/face_rep/)
"""
Expand Down
2 changes: 1 addition & 1 deletion examples/fmri_spm_nested.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def _template_path(in_data):


def subjectinfo(subject_id):
from nipype.interfaces.base import Bunch
from nipype.utils.bunch import Bunch
from copy import deepcopy
print("Subject ID: %s\n" % str(subject_id))
output = []
Expand Down
2 changes: 1 addition & 1 deletion examples/frontiers_paper/smoothing_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import nipype.pipeline.engine as pe # pypeline engine
import nipype.algorithms.modelgen as model # model specification
import nipype.workflows.fmri.fsl as fsl_wf
from nipype.interfaces.base import Bunch
from nipype.utils.bunch import Bunch
import os # system functions

preprocessing = pe.Workflow(name="preprocessing")
Expand Down
2 changes: 1 addition & 1 deletion examples/frontiers_paper/workflow_from_scratch.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import nipype.interfaces.spm as spm # spm
import nipype.pipeline.engine as pe # pypeline engine
import nipype.algorithms.modelgen as model # model specification
from nipype.interfaces.base import Bunch
from nipype.utils.bunch import Bunch
import os # system functions
"""In the following section, to showcase NiPyPe, we will describe how to create
and extend a typical fMRI processing pipeline. We will begin with a basic
Expand Down
14 changes: 7 additions & 7 deletions nipype/algorithms/modelgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
from scipy.special import gammaln

from ..utils import NUMPY_MMAP
from ..interfaces.base import (BaseInterface, TraitedSpec, InputMultiPath,
traits, File, Bunch, BaseInterfaceInputSpec,
isdefined)
from ..utils.filemanip import ensure_list
from ..utils.bunch import Bunch
from ..utils.misc import normalize_mc_params
from ..utils.filemanip import ensure_list
from ..interfaces.base import (BaseInterface, TraitedSpec, InputMultiPath,
traits, File, BaseInterfaceInputSpec, isdefined)
from .. import config, logging
iflogger = logging.getLogger('nipype.interface')

Expand Down Expand Up @@ -280,7 +280,7 @@ class SpecifyModel(BaseInterface):
--------

>>> from nipype.algorithms import modelgen
>>> from nipype.interfaces.base import Bunch
>>> from nipype.utils.bunch import Bunch
>>> s = modelgen.SpecifyModel()
>>> s.inputs.input_units = 'secs'
>>> s.inputs.functional_runs = ['functional2.nii', 'functional3.nii']
Expand Down Expand Up @@ -481,7 +481,7 @@ class SpecifySPMModel(SpecifyModel):
--------

>>> from nipype.algorithms import modelgen
>>> from nipype.interfaces.base import Bunch
>>> from nipype.utils.bunch import Bunch
>>> s = modelgen.SpecifySPMModel()
>>> s.inputs.input_units = 'secs'
>>> s.inputs.output_units = 'scans'
Expand Down Expand Up @@ -667,7 +667,7 @@ class SpecifySparseModel(SpecifyModel):
--------

>>> from nipype.algorithms import modelgen
>>> from nipype.interfaces.base import Bunch
>>> from nipype.utils.bunch import Bunch
>>> s = modelgen.SpecifySparseModel()
>>> s.inputs.input_units = 'secs'
>>> s.inputs.functional_runs = ['functional2.nii', 'functional3.nii']
Expand Down
3 changes: 2 additions & 1 deletion nipype/algorithms/tests/test_modelgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

import pytest
import numpy.testing as npt
from nipype.interfaces.base import Bunch, TraitError
from nipype.utils.bunch import Bunch
from nipype.interfaces.base import TraitError
from nipype.algorithms.modelgen import (SpecifyModel, SpecifySparseModel,
SpecifySPMModel)

Expand Down
2 changes: 1 addition & 1 deletion nipype/algorithms/tests/test_rapidart.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import numpy.testing as npt
from .. import rapidart as ra
from ...interfaces.base import Bunch
from ...utils.bunch import Bunch


def test_ad_init():
Expand Down
42 changes: 40 additions & 2 deletions nipype/interfaces/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
This module defines the API of all nipype interfaces.

"""
from ...utils.bunch import Bunch
from .core import (Interface, BaseInterface, SimpleInterface, CommandLine,
StdOutCommandLine, MpiCommandLine, SEMLikeCommandLine,
LibraryBaseInterface, PackageInfo)
Expand All @@ -22,5 +23,42 @@
OutputMultiObject, InputMultiObject,
OutputMultiPath, InputMultiPath)

from .support import (Bunch, InterfaceResult, load_template,
NipypeInterfaceError)
from .support import (InterfaceRuntime, InterfaceResult, NipypeInterfaceError)

__all__ = [
'Bunch',
'Interface',
'BaseInterface',
'SimpleInterface',
'CommandLine',
'StdOutCommandLine',
'MpiCommandLine',
'SEMLikeCommandLine',
'LibraryBaseInterface',
'PackageInfo',
'BaseTraitedSpec',
'TraitedSpec',
'DynamicTraitedSpec',
'BaseInterfaceInputSpec',
'CommandLineInputSpec',
'StdOutCommandLineInputSpec',
'traits',
'Undefined',
'TraitDictObject',
'TraitListObject',
'TraitError',
'isdefined',
'File',
'Directory',
'Str',
'DictStrStr',
'has_metadata',
'ImageFile',
'OutputMultiObject',
'InputMultiObject',
'OutputMultiPath',
'InputMultiPath',
'InterfaceRuntime',
'InterfaceResult',
'NipypeInterfaceError',
]
8 changes: 3 additions & 5 deletions nipype/interfaces/base/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from .specs import (BaseInterfaceInputSpec, CommandLineInputSpec,
StdOutCommandLineInputSpec, MpiCommandLineInputSpec,
get_filecopy_info)
from .support import (Bunch, InterfaceResult, NipypeInterfaceError)
from .support import (InterfaceRuntime, InterfaceResult, NipypeInterfaceError)

from future import standard_library
standard_library.install_aliases()
Expand Down Expand Up @@ -478,7 +478,7 @@ def run(self, cwd=None, ignore_exception=None, **inputs):
if self._redirect_x:
env['DISPLAY'] = config.get_display()

runtime = Bunch(
runtime = InterfaceRuntime(
cwd=cwd,
prevcwd=syscwd,
returncode=None,
Expand Down Expand Up @@ -872,9 +872,7 @@ def _run_interface(self, runtime, correct_return_codes=(0, )):
"""

out_environ = self._get_environ()
# Initialize runtime Bunch
runtime.stdout = None
runtime.stderr = None
# Initialize runtime InterfaceRuntime
runtime.cmdline = self.cmdline
runtime.environ.update(out_environ)

Expand Down
Loading