Skip to content

Commit

Permalink
fix: miscellaneous improvements and fixes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
oesteban committed Jan 1, 2020
1 parent 7be74f9 commit 4d740aa
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 31 deletions.
5 changes: 5 additions & 0 deletions doc/interfaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
========================
Interfaces and Workflows
========================
:Release: |version|
:Date: |today|

Previous versions: `1.3.0 <http://nipype.readthedocs.io/en/1.3.0/>`_ `1.2.3 <http://nipype.readthedocs.io/en/1.2.3/>`_

Workflows
---------
.. important::
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 @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions nipype/interfaces/afni/__init__.py
Original file line number Diff line number Diff line change
@@ -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
<http://afni.nimh.nih.gov/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
Expand Down
28 changes: 17 additions & 11 deletions nipype/interfaces/afni/base.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
<http://afni.nimh.nih.gov/afni/community/board/read.php?1,145346,145347#msg-145347>`__
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)
Expand Down Expand Up @@ -142,6 +147,7 @@ class AFNICommand(AFNICommandBase):
"""Shared options for several AFNI commands."""

input_spec = AFNICommandInputSpec
output_spec = AFNICommandOutputSpec
_outputtype = None

references_ = [
Expand Down Expand Up @@ -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"
Expand All @@ -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
33 changes: 23 additions & 10 deletions nipype/pipeline/engine/base.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
----------
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
6 changes: 0 additions & 6 deletions nipype/sphinxext/apidoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 4d740aa

Please sign in to comment.