Skip to content

Commit 972b074

Browse files
committed
ENH: Use duecredit - provide zenodo DOI as citation target
Here is how it would look ATM if you disregard some warnings from duecredit about outdated injections (that is their cons, need to be fixed up: duecredit/duecredit#170) and datalad about datasets without aggregated metadata (need to be fixed up: datalad/datalad#4562), but otherwise -- works! Ideally for this particular use case we should have forced .duecredit.p to be stored within produced path, not in curdir... later > DUECREDIT_ENABLE=1 heudiconv -o /tmp/out -f reproin --datalad --files QA/sourcedata/sub-qa/ses-20190930/anat/sub-qa_ses-20190930_acq-MPRAGE_T1w.dicom.tgz ... DueCredit Report: - DataLad - Data management and distribution platform / datalad (v 0.12.6) [1] - Flexible DICOM converter for organizing brain imaging data / heudiconv (v 0.8.0) [2] - I/O library to access to common neuroimaging file formats / nibabel (v 3.0.1) [3] - Scientific tools library / numpy (v 1.17.4) [4] 4 packages cited 0 modules cited 0 functions cited References ---------- [1] Halchenko, Y.O. et al., 2019. datalad/datalad 0.12.0rc6. [2] Halchenko, Y. et al., 2020. nipy/heudiconv v0.8.0. [3] Brett, M. et al., 2015. Nibabel 2.0.1. [4] Van Der Walt, S., Colbert, S.C. & Varoquaux, G., 2011. The NumPy array: a structure for efficient numerical computation. Computing in Science & Engineering, 13(2), pp.22–30. DUECREDIT_ENABLE=1 heudiconv -o /tmp/out -f reproin --datalad --files 15.50s user 8.34s system 104% cpu 22.917 total
1 parent 1f6ae74 commit 972b074

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed

heudiconv/cli/run.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from ..convert import prep_conversion
1212
from ..bids import populate_bids_templates, tuneup_bids_json_files
1313
from ..queue import queue_conversion
14+
from ..due import due, Doi
1415

1516
import inspect
1617
import logging
@@ -244,6 +245,12 @@ def get_parser():
244245
return parser
245246

246247

248+
@due.dcite(
249+
Doi('10.5281/zenodo.1012598'),
250+
path='heudiconv',
251+
description='Flexible DICOM converter for organizing brain imaging data',
252+
version=__version__,
253+
cite_module=True)
247254
def process_args(args):
248255
"""Given a structure of arguments from the parser perform computation"""
249256

heudiconv/due.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# emacs: at the end of the file
2+
# ex: set sts=4 ts=4 sw=4 et:
3+
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
4+
"""
5+
6+
Stub file for a guaranteed safe import of duecredit constructs: if duecredit
7+
is not available.
8+
9+
To use it, place it into your project codebase to be imported, e.g. copy as
10+
11+
cp stub.py /path/tomodule/module/due.py
12+
13+
Note that it might be better to avoid naming it duecredit.py to avoid shadowing
14+
installed duecredit.
15+
16+
Then use in your code as
17+
18+
from .due import due, Doi, BibTeX, Text
19+
20+
See https://github.com/duecredit/duecredit/blob/master/README.md for examples.
21+
22+
Origin: Originally a part of the duecredit
23+
Copyright: 2015-2019 DueCredit developers
24+
License: BSD-2
25+
"""
26+
27+
__version__ = '0.0.8'
28+
29+
30+
class InactiveDueCreditCollector(object):
31+
"""Just a stub at the Collector which would not do anything"""
32+
def _donothing(self, *args, **kwargs):
33+
"""Perform no good and no bad"""
34+
pass
35+
36+
def dcite(self, *args, **kwargs):
37+
"""If I could cite I would"""
38+
def nondecorating_decorator(func):
39+
return func
40+
return nondecorating_decorator
41+
42+
active = False
43+
activate = add = cite = dump = load = _donothing
44+
45+
def __repr__(self):
46+
return self.__class__.__name__ + '()'
47+
48+
49+
def _donothing_func(*args, **kwargs):
50+
"""Perform no good and no bad"""
51+
pass
52+
53+
54+
try:
55+
from duecredit import due, BibTeX, Doi, Url, Text
56+
if 'due' in locals() and not hasattr(due, 'cite'):
57+
raise RuntimeError(
58+
"Imported due lacks .cite. DueCredit is now disabled")
59+
except Exception as e:
60+
if not isinstance(e, ImportError):
61+
import logging
62+
logging.getLogger("duecredit").error(
63+
"Failed to import duecredit due to %s" % str(e))
64+
# Initiate due stub
65+
due = InactiveDueCreditCollector()
66+
BibTeX = Doi = Url = Text = _donothing_func
67+
68+
# Emacs mode definitions
69+
# Local Variables:
70+
# mode: python
71+
# py-indent-offset: 4
72+
# tab-width: 4
73+
# indent-tabs-mode: nil
74+
# End:

heudiconv/info.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939

4040
EXTRA_REQUIRES = {
4141
'tests': TESTS_REQUIRES,
42-
'extras': [], # Requires patched version ATM ['dcmstack'],
42+
'extras': [
43+
'duecredit', # optional dependency
44+
], # Requires patched version ATM ['dcmstack'],
4345
'datalad': ['datalad >=0.12.3']
4446
}
4547

0 commit comments

Comments
 (0)