From 4d740aaeb42d4c8da082bbc232756777e11b0344 Mon Sep 17 00:00:00 2001 From: oesteban Date: Wed, 1 Jan 2020 12:27:35 -0800 Subject: [PATCH] fix: miscellaneous improvements and fixes In particular, after allowing printing the inheritance of interfaces, links for ZZZCommandBase interfaces were broken, as originally filtered out and not built. Now they are being built and we are back to 5 warnings. --- doc/interfaces.rst | 5 +++++ examples/fmri_spm_auditory.py | 2 +- nipype/interfaces/afni/__init__.py | 7 +++--- nipype/interfaces/afni/base.py | 28 ++++++++++++++---------- nipype/pipeline/engine/base.py | 33 ++++++++++++++++++++--------- nipype/sphinxext/apidoc/__init__.py | 6 ------ 6 files changed, 50 insertions(+), 31 deletions(-) diff --git a/doc/interfaces.rst b/doc/interfaces.rst index ff489df51a..32aabf7d0b 100644 --- a/doc/interfaces.rst +++ b/doc/interfaces.rst @@ -5,6 +5,11 @@ ======================== Interfaces and Workflows ======================== +:Release: |version| +:Date: |today| + +Previous versions: `1.3.0 `_ `1.2.3 `_ + Workflows --------- .. important:: diff --git a/examples/fmri_spm_auditory.py b/examples/fmri_spm_auditory.py index 3431a2b96c..60572f0e97 100755 --- a/examples/fmri_spm_auditory.py +++ b/examples/fmri_spm_auditory.py @@ -316,7 +316,7 @@ def makelist(item): Use the :class:`~nipype.pipeline.engine.workflows.Workflow` to create a graph-based execution pipeline for first level analysis. -Set the :py:attr:`~nipype.pipeline.engine.workflows.Workflow.base_dir` +Set the :py:attr:`~nipype.pipeline.engine.workflows.base.EngineBase.base_dir` option to instruct the pipeline engine to use ``spm_auditory_tutorial/workingdir`` as the filesystem location to use when running the processes and keeping their outputs. diff --git a/nipype/interfaces/afni/__init__.py b/nipype/interfaces/afni/__init__.py index f795e347a3..d5f2bb4361 100644 --- a/nipype/interfaces/afni/__init__.py +++ b/nipype/interfaces/afni/__init__.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: -"""The afni module provides classes for interfacing with the `AFNI -`_ command line tools. +""" +AFNI_ is a software suite for the analysis and display of anatomical and functional MRI data. + +.. include:: ../../../doc/links_names.txt -Top-level namespace for afni. """ from .base import Info diff --git a/nipype/interfaces/afni/base.py b/nipype/interfaces/afni/base.py index c1b181b85d..a5285446e3 100644 --- a/nipype/interfaces/afni/base.py +++ b/nipype/interfaces/afni/base.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: -"""Provide interface to AFNI commands.""" +"""Provide a base interface to AFNI commands.""" import os from sys import platform from distutils import spawn @@ -108,12 +108,17 @@ def standard_image(img_name): class AFNICommandBase(CommandLine): """ - A base class to fix a linking problem in OSX and afni. + A base class to fix a linking problem in OSX and AFNI. + + See Also + -------- + `This thread + `__ + about the particular environment variable that fixes this problem. - See http://afni.nimh.nih.gov/afni/community/board/read.php?1,145346,145347#msg-145347 """ - def _run_interface(self, runtime): + def _run_interface(self, runtime, correct_return_codes=(0,)): if platform == "darwin": runtime.environ["DYLD_FALLBACK_LIBRARY_PATH"] = "/usr/local/afni/" return super(AFNICommandBase, self)._run_interface(runtime) @@ -142,6 +147,7 @@ class AFNICommand(AFNICommandBase): """Shared options for several AFNI commands.""" input_spec = AFNICommandInputSpec + output_spec = AFNICommandOutputSpec _outputtype = None references_ = [ @@ -294,13 +300,6 @@ def _gen_fname(self, basename, cwd=None, suffix=None, change_ext=True, ext=None) return fname -def no_afni(): - """Check whether AFNI is not available.""" - if Info.version() is None: - return True - return False - - class AFNIPythonCommandInputSpec(CommandLineInputSpec): outputtype = traits.Enum( "AFNI", list(Info.ftypes.keys()), desc="AFNI output filetype" @@ -323,3 +322,10 @@ def cmd(self): @property def _cmd_prefix(self): return "{} ".format(self.inputs.py27_path) + + +def no_afni(): + """Check whether AFNI is not available.""" + if Info.version() is None: + return True + return False diff --git a/nipype/pipeline/engine/base.py b/nipype/pipeline/engine/base.py index 6735c19d49..a041fd12e0 100644 --- a/nipype/pipeline/engine/base.py +++ b/nipype/pipeline/engine/base.py @@ -1,11 +1,7 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: -"""Defines functionality for pipelined execution of interfaces - -The `EngineBase` class implements the more general view of a task. -""" +"""Defines functionality for pipelined execution of interfaces.""" from copy import deepcopy import re import numpy as np @@ -16,10 +12,15 @@ class EngineBase(object): - """Defines common attributes and functions for workflows and nodes.""" + """ + Defines common attributes and functions for workflows and nodes. + + Implements the more general view of a task. + """ def __init__(self, name=None, base_dir=None): - """ Initialize base parameters of a workflow or node + """ + Initialize base parameters of a workflow or node. Parameters ---------- @@ -31,15 +32,19 @@ def __init__(self, name=None, base_dir=None): default=None, which results in the use of mkdtemp """ + self._name = None self._hierarchy = None self.name = name self._id = self.name # for compatibility with node expansion using iterables self.base_dir = base_dir + """Define the work directory for this instance of workflow element.""" + self.config = deepcopy(config._sections) @property def name(self): + """Set the unique name of this workflow element.""" return self._name @name.setter @@ -50,6 +55,7 @@ def name(self, name): @property def fullname(self): + """Build the full name down the hierarchy.""" if self._hierarchy: return "%s.%s" % (self._hierarchy, self.name) return self.name @@ -64,20 +70,22 @@ def outputs(self): @property def itername(self): - """Name for expanded iterable""" + """Get the name of the expanded iterable.""" itername = self._id if self._hierarchy: itername = "%s.%s" % (self._hierarchy, self._id) return itername def clone(self, name): - """Clone an EngineBase object + """ + Clone an EngineBase object. Parameters ---------- name : string (mandatory) A clone of node or workflow must have a new name + """ if name == self.name: raise ValueError('Cloning requires a new name, "%s" is ' "in use." % name) @@ -96,15 +104,20 @@ def _check_inputs(self, parameter): return hasattr(self.inputs, parameter) def __str__(self): + """Convert to string.""" return self.fullname def __repr__(self): + """Get Python representation.""" return self.itername def save(self, filename=None): + """Store this workflow element to a file.""" if filename is None: filename = "temp.pklz" savepkl(filename, self) - def load(self, filename): + @staticmethod + def load(filename): + """Load this workflow element from a file.""" return loadpkl(filename) diff --git a/nipype/sphinxext/apidoc/__init__.py b/nipype/sphinxext/apidoc/__init__.py index cb46ff5b06..67cb00c59a 100644 --- a/nipype/sphinxext/apidoc/__init__.py +++ b/nipype/sphinxext/apidoc/__init__.py @@ -41,12 +41,6 @@ class Config(NapoleonConfig): _config_values = { "nipype_skip_classes": ( [ - "AFNI(Python)?Command", - "ANTS", - "FSLCommand", - "FS(Command|Script)", - "Info", - "^SPM", "Tester", "InputSpec", "OutputSpec",