Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b17b76f
add first duecredit item
alexsavio May 3, 2016
b7c3862
RF: move import/use of due into __init__.py so info.py could stay wit…
yarikoptic May 4, 2016
acf6084
BF: provide env for exec in setup.py
yarikoptic May 4, 2016
8e2fb00
Merge pull request #8 from yarikoptic/pr-1466
alexsavio May 4, 2016
8e0f8bd
ENH: travis -- add a run which would execute with DUECREDIT_ENABLE
yarikoptic May 4, 2016
9d096f4
Merge pull request #9 from yarikoptic/pr-1466
alexsavio May 6, 2016
93f927b
add first duecredit item
alexsavio May 3, 2016
0ff3715
RF: move import/use of due into __init__.py so info.py could stay wit…
yarikoptic May 4, 2016
4b42834
BF: provide env for exec in setup.py
yarikoptic May 4, 2016
d1884b3
ENH: travis -- add a run which would execute with DUECREDIT_ENABLE
yarikoptic May 4, 2016
4e1b437
wip: first duecredit implementation suggestion
alexsavio May 11, 2016
d0190f8
Merge remote-tracking branch 'origin/enh/duecredit' into enh/duecredit
alexsavio May 11, 2016
55872db
fix merge
alexsavio May 11, 2016
af9d454
fix spm citation
alexsavio May 12, 2016
f0fb442
add first duecredit item
alexsavio May 3, 2016
706ec0b
RF: move import/use of due into __init__.py so info.py could stay wit…
yarikoptic May 4, 2016
32f3069
BF: provide env for exec in setup.py
yarikoptic May 4, 2016
31e94b2
ENH: travis -- add a run which would execute with DUECREDIT_ENABLE
yarikoptic May 4, 2016
b5aad34
add first duecredit item
alexsavio May 3, 2016
61c9896
RF: move import/use of due into __init__.py so info.py could stay wit…
yarikoptic May 4, 2016
5129557
wip: first duecredit implementation suggestion
alexsavio May 11, 2016
5c5f720
fix merge
alexsavio May 11, 2016
5795b12
fix spm citation
alexsavio May 12, 2016
347eea5
move due.py to external
alexsavio Jun 1, 2016
3782eb3
Merge branch 'enh/duecredit' of github.com:alexsavio/nipype into enh/…
alexsavio Jun 1, 2016
cc341df
fix due approach: use references_ member
alexsavio Jun 1, 2016
b3275d9
Fix conflict.
aweinstein Jul 16, 2016
921ac7c
Fix missing import to "due"
aweinstein Jul 16, 2016
78f3896
Fix typo in variable name.
aweinstein Jul 16, 2016
0b524a6
Remove duplicated parameter setting.
aweinstein Jul 16, 2016
6fed566
Set path as a key in the dictionary.
aweinstein Jul 17, 2016
8dd8468
Merge pull request #10 from aweinstein/enh/duecredit
alexsavio Aug 4, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ python:
env:
- INSTALL_DEB_DEPENDECIES=true
- INSTALL_DEB_DEPENDECIES=false
- INSTALL_DEB_DEPENDECIES=true DUECREDIT_ENABLE=yes
before_install:
- if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh
-O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
Expand Down Expand Up @@ -45,6 +46,7 @@ install:
- if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then conda install --yes vtk; fi
- pip install python-coveralls
- pip install nose-cov
- if [ ! -z "$DUECREDIT_ENABLE"]; then pip install --user -v duecredit; fi
# Add tvtk (PIL is required by blockcanvas)
# Install mayavi (see https://github.com/enthought/mayavi/issues/271)
- if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then
Expand Down
2 changes: 1 addition & 1 deletion nipype/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
from distutils.version import LooseVersion

from .fixes.numpy.testing import nosetester
from .refs import due

try:
import faulthandler
faulthandler.enable()
except (ImportError,IOError) as e:
pass


class _NoseTester(nosetester.NoseTester):
""" Subclass numpy's NoseTester to add doctests by default
"""
Expand Down
72 changes: 72 additions & 0 deletions nipype/external/due.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# emacs: at the end of the file
# ex: set sts=4 ts=4 sw=4 et:
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
"""

Stub file for a guaranteed safe import of duecredit constructs: if duecredit
is not available.

To use it, place it into your project codebase to be imported, e.g. copy as

cp stub.py /path/tomodule/module/due.py

Note that it might be better to avoid naming it duecredit.py to avoid shadowing
installed duecredit.

Then use in your code as

from .due import due, Doi, BibTeX

See https://github.com/duecredit/duecredit/blob/master/README.md for examples.

Origin: Originally a part of the duecredit
Copyright: 2015-2016 DueCredit developers
License: BSD-2
"""

__version__ = '0.0.5'


class InactiveDueCreditCollector(object):
"""Just a stub at the Collector which would not do anything"""
def _donothing(self, *args, **kwargs):
"""Perform no good and no bad"""
pass

def dcite(self, *args, **kwargs):
"""If I could cite I would"""
def nondecorating_decorator(func):
return func
return nondecorating_decorator

cite = load = add = _donothing

def __repr__(self):
return self.__class__.__name__ + '()'


def _donothing_func(*args, **kwargs):
"""Perform no good and no bad"""
pass

try:
from duecredit import due, BibTeX, Doi, Url
if 'due' in locals() and not hasattr(due, 'cite'):
raise RuntimeError(
"Imported due lacks .cite. DueCredit is now disabled")
except Exception as e:
if type(e).__name__ != 'ImportError':
import logging
logging.getLogger("duecredit").error(
"Failed to import duecredit due to %s" % str(e))
# Initiate due stub
due = InactiveDueCreditCollector()
BibTeX = Doi = Url = _donothing_func

# Emacs mode definitions
# Local Variables:
# mode: python
# py-indent-offset: 4
# tab-width: 4
# indent-tabs-mode: nil
# End:
25 changes: 24 additions & 1 deletion nipype/interfaces/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from .. import config, logging, LooseVersion
from .. import __version__
from ..external.six import string_types, text_type
from ..external.due import due

nipype_version = LooseVersion(__version__)

Expand Down Expand Up @@ -748,6 +749,7 @@ class BaseInterface(Interface):
_version = None
_additional_metadata = []
_redirect_x = False
references_ = []

def __init__(self, **inputs):
if not self.input_spec:
Expand All @@ -770,12 +772,24 @@ def help(cls, returnhelp=False):
docstring = ['']

allhelp = '\n'.join(docstring + cls._inputs_help() + [''] +
cls._outputs_help() + [''])
cls._outputs_help() + [''] +
cls._refs_help() + [''])
if returnhelp:
return allhelp
else:
print(allhelp)

@classmethod
def _refs_help(cls):
""" Prints interface references.
"""
helpstr = ['References::']

for r in cls.references_:
helpstr += [repr(r['entry'])]

return helpstr

@classmethod
def _get_trait_desc(self, inputs, name, spec):
desc = spec.desc
Expand Down Expand Up @@ -1000,6 +1014,13 @@ def _run_interface(self, runtime):
"""
raise NotImplementedError

def _duecredit_cite(self):
""" Add the interface references to the duecredit citations
"""
for r in self.references_:
r['path'] = self.__module__
due.cite(**r)

def run(self, **inputs):
"""Execute this interface.

Expand All @@ -1019,6 +1040,8 @@ def run(self, **inputs):
self._check_mandatory_inputs()
self._check_version_requirements(self.inputs)
interface = self.__class__
self._duecredit_cite()

# initialize provenance tracking
env = deepcopy(dict(os.environ))
runtime = Bunch(cwd=os.getcwd(),
Expand Down
12 changes: 12 additions & 0 deletions nipype/interfaces/spm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from ..matlab import MatlabCommand
from ...utils import spm_docs as sd
from ...external.six import string_types
from ...external.due import due, Doi, BibTeX
from ... import logging
logger = logging.getLogger('interface')

Expand Down Expand Up @@ -235,6 +236,17 @@ class SPMCommand(BaseInterface):
_paths = None
_use_mcr = None

references_ = [{'entry': BibTeX("@book{FrackowiakFristonFrithDolanMazziotta1997,"
"author={R.S.J. Frackowiak, K.J. Friston, C.D. Frith, R.J. Dolan, and J.C. Mazziotta},"
"title={Human Brain Function},"
"publisher={Academic Press USA},"
"year={1997},"
"}"),
'description': 'The fundamental text on Statistical Parametric Mapping (SPM)',
# 'path': "nipype.interfaces.spm",
'tags': ['implementation'],
}]

def __init__(self, **inputs):
super(SPMCommand, self).__init__(**inputs)
self.inputs.on_trait_change(self._matlab_cmd_update, ['matlab_cmd',
Expand Down
17 changes: 17 additions & 0 deletions nipype/refs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

# Use duecredit (duecredit.org) to provide a citation to relevant work to
# be cited. This does nothing, unless the user has duecredit installed,
# And calls this with duecredit (as in `python -m duecredit script.py`):
from .external.due import due, Doi, BibTeX

due.cite(Doi("10.3389/fninf.2011.00013"),
description="A flexible, lightweight and extensible neuroimaging data"
" processing framework in Python",
path="nipype",
tags=["implementation"],)

due.cite(Doi("10.5281/zenodo.50186"),
description="A flexible, lightweight and extensible neuroimaging data"
" processing framework in Python",
path="nipype",
tags=["implementation"],)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def _package_status(pkg_name, version, version_getter, checker):

# Get version and release info, which is all stored in nipype/info.py
ver_file = os.path.join('nipype', 'info.py')
exec(open(ver_file).read())
exec(open(ver_file).read(), locals())

# Prepare setuptools args
if 'setuptools' in sys.modules:
Expand Down