Skip to content

Commit cc341df

Browse files
committed
fix due approach: use references_ member
1 parent 3782eb3 commit cc341df

File tree

7 files changed

+37
-97
lines changed

7 files changed

+37
-97
lines changed

nipype/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
from .fixes.numpy.testing import nosetester
1919
from .refs import due
2020

21-
<<<<<<< 5129557c96d5481bb93d64e157a0faf4caa729eb
22-
23-
=======
24-
>>>>>>> fix merge
2521
try:
2622
import faulthandler
2723
faulthandler.enable()

nipype/due.py

Lines changed: 0 additions & 72 deletions
This file was deleted.

nipype/interfaces/base.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ class BaseInterface(Interface):
748748
_version = None
749749
_additional_metadata = []
750750
_redirect_x = False
751+
references_ = []
751752

752753
def __init__(self, **inputs):
753754
if not self.input_spec:
@@ -770,12 +771,24 @@ def help(cls, returnhelp=False):
770771
docstring = ['']
771772

772773
allhelp = '\n'.join(docstring + cls._inputs_help() + [''] +
773-
cls._outputs_help() + [''])
774+
cls._outputs_help() + [''] +
775+
cls._refs_help() + [''])
774776
if returnhelp:
775777
return allhelp
776778
else:
777779
print(allhelp)
778780

781+
@classmethod
782+
def _refs_help(cls):
783+
""" Prints interface references.
784+
"""
785+
helpstr = ['References::']
786+
787+
for r in cls.references_:
788+
helpstr += [repr(r['entry'])]
789+
790+
return helpstr
791+
779792
@classmethod
780793
def _get_trait_desc(self, inputs, name, spec):
781794
desc = spec.desc
@@ -1000,6 +1013,13 @@ def _run_interface(self, runtime):
10001013
"""
10011014
raise NotImplementedError
10021015

1016+
def _duecredit_cite(self):
1017+
""" Add the interface references to the duecredit citations
1018+
"""
1019+
for r in self._references:
1020+
r['path'] = self.__module__ # TODO: check if this is correct
1021+
due.cite(**r, path=self.__module__)
1022+
10031023
def run(self, **inputs):
10041024
"""Execute this interface.
10051025
@@ -1019,6 +1039,8 @@ def run(self, **inputs):
10191039
self._check_mandatory_inputs()
10201040
self._check_version_requirements(self.inputs)
10211041
interface = self.__class__
1042+
self._duecredit_cite()
1043+
10221044
# initialize provenance tracking
10231045
env = deepcopy(dict(os.environ))
10241046
runtime = Bunch(cwd=os.getcwd(),
@@ -1197,7 +1219,7 @@ def _read(self, drain):
11971219
# Get number of threads for process
11981220
def _get_num_threads(proc):
11991221
"""Function to get the number of threads a process is using
1200-
NOTE: If
1222+
NOTE: If
12011223
12021224
Parameters
12031225
----------

nipype/interfaces/spm/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,3 @@
1212
PairedTTestDesign, MultipleRegressionDesign)
1313
from .utils import (Analyze2nii, CalcCoregAffine, ApplyTransform, Reslice,
1414
ApplyInverseDeformation, ResliceToReference, DicomImport)
15-
16-
from .refs import due

nipype/interfaces/spm/base.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from ..matlab import MatlabCommand
3636
from ...utils import spm_docs as sd
3737
from ...external.six import string_types
38+
from ...external.due import due, Doi, BibTeX
3839
from ... import logging
3940
logger = logging.getLogger('interface')
4041

@@ -235,6 +236,17 @@ class SPMCommand(BaseInterface):
235236
_paths = None
236237
_use_mcr = None
237238

239+
references_ = [{'entry': BibTeX("@book{FrackowiakFristonFrithDolanMazziotta1997,"
240+
"author={R.S.J. Frackowiak, K.J. Friston, C.D. Frith, R.J. Dolan, and J.C. Mazziotta},"
241+
"title={Human Brain Function},"
242+
"publisher={Academic Press USA},"
243+
"year={1997},"
244+
"}"),
245+
'description': 'The fundamental text on Statistical Parametric Mapping (SPM)',
246+
# 'path': "nipype.interfaces.spm",
247+
'tags': ['implementation'],
248+
}]
249+
238250
def __init__(self, **inputs):
239251
super(SPMCommand, self).__init__(**inputs)
240252
self.inputs.on_trait_change(self._matlab_cmd_update, ['matlab_cmd',

nipype/interfaces/spm/refs.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

nipype/refs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Use duecredit (duecredit.org) to provide a citation to relevant work to
33
# be cited. This does nothing, unless the user has duecredit installed,
44
# And calls this with duecredit (as in `python -m duecredit script.py`):
5-
from .due import due, Doi, BibTeX
5+
from .external.due import due, Doi, BibTeX
66

77
due.cite(Doi("10.3389/fninf.2011.00013"),
88
description="A flexible, lightweight and extensible neuroimaging data"

0 commit comments

Comments
 (0)