Skip to content

Commit 1413824

Browse files
authored
Merge pull request #454 from dbic/enh-citation
ENH: zenodo referencing in README.rst + support for ducredit for heudiconv and reproin
2 parents d855f64 + 887ba12 commit 1413824

File tree

8 files changed

+123
-3
lines changed

8 files changed

+123
-3
lines changed

README.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
:target: http://heudiconv.readthedocs.io/en/latest/?badge=latest
2121
:alt: Readthedocs
2222

23+
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1012598.svg
24+
:target: https://doi.org/10.5281/zenodo.1012598
25+
:alt: Zenodo (latest)
26+
2327
About
2428
-----
2529

@@ -33,3 +37,10 @@ into structured directory layouts.
3337
- it can track the provenance of the conversion from DICOM to NIfTI in W3C PROV format
3438
- it provides assistance in converting to `BIDS <http://bids.neuroimaging.io/>`_.
3539
- it integrates with `DataLad <https://www.datalad.org/>`_ to place converted and original data under git/git-annex version control, while automatically annotating files with sensitive information (e.g., non-defaced anatomicals, etc)
40+
41+
How to cite
42+
-----------
43+
44+
Please use `Zenodo record <https://doi.org/10.5281/zenodo.1012598>`_ for
45+
your specific version of HeuDiConv. We also support gathering
46+
all relevant citations via `DueCredit <http://duecredit.org>`_.

heudiconv/bids.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class BIDSError(Exception):
4444
pass
4545

4646

47+
BIDS_VERSION = "1.4.1"
48+
49+
4750
def populate_bids_templates(path, defaults={}):
4851
"""Premake BIDS text files with templates"""
4952

@@ -53,7 +56,7 @@ def populate_bids_templates(path, defaults={}):
5356
save_json(descriptor,
5457
OrderedDict([
5558
('Name', "TODO: name of the dataset"),
56-
('BIDSVersion', "1.0.1"),
59+
('BIDSVersion', BIDS_VERSION),
5760
('License', defaults.get('License',
5861
"TODO: choose a license, e.g. PDDL "
5962
"(http://opendatacommons.org/licenses/pddl/)")),

heudiconv/cli/run.py

100644100755
File mode changed.

heudiconv/convert.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import sys
88
import re
99

10+
from .due import due, Doi
11+
1012
from .utils import (
1113
read_config,
1214
load_json,
@@ -27,7 +29,8 @@
2729
save_scans_key,
2830
tuneup_bids_json_files,
2931
add_participant_record,
30-
BIDSError
32+
BIDSError,
33+
BIDS_VERSION,
3134
)
3235
from .dicoms import (
3336
group_dicoms_into_seqinfos,
@@ -410,6 +413,20 @@ def convert(items, converter, scaninfo_suffix, custom_callable, with_prov,
410413
prov_files = []
411414
tempdirs = TempDirs()
412415

416+
if bids_options is not None:
417+
due.cite(
418+
# doi matches the BIDS_VERSION
419+
Doi("10.5281/zenodo.4085321"),
420+
description="Brain Imaging Data Structure (BIDS) Specification",
421+
path="bids",
422+
version=BIDS_VERSION,
423+
tags=["implementation"])
424+
due.cite(
425+
Doi("10.1038/sdata.2016.44"),
426+
description="Brain Imaging Data Structure (BIDS), Original paper",
427+
path="bids",
428+
tags=["documentation"])
429+
413430
for item_idx, item in enumerate(items):
414431

415432
prefix, outtypes, item_dicoms = item[:3]

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/heuristics/reproin.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@
123123
import hashlib
124124
from glob import glob
125125

126+
from heudiconv.due import due, Doi
127+
126128
import logging
127129
lgr = logging.getLogger('heudiconv')
128130

@@ -467,6 +469,10 @@ def ls(study_session, seqinfo):
467469
# XXX we killed session indicator! what should we do now?!!!
468470
# WE DON:T NEED IT -- it will be provided into conversion_info as `session`
469471
# So we just need subdir and file_suffix!
472+
@due.dcite(
473+
Doi('10.5281/zenodo.1207117'),
474+
path='heudiconv.heuristics.reproin',
475+
description='ReproIn heudiconv heuristic for turnkey conversion into BIDS')
470476
def infotodict(seqinfo):
471477
"""Heuristic evaluator for determining which runs belong where
472478

heudiconv/info.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
MIN_DATALAD_VERSION = '0.12.4'
4141
EXTRA_REQUIRES = {
4242
'tests': TESTS_REQUIRES,
43-
'extras': [], # Requires patched version ATM ['dcmstack'],
43+
'extras': [
44+
'duecredit', # optional dependency
45+
], # Requires patched version ATM ['dcmstack'],
4446
'datalad': ['datalad >=%s' % MIN_DATALAD_VERSION]
4547
}
4648

heudiconv/main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from . import __version__, __packagename__
66
from .bids import populate_bids_templates, tuneup_bids_json_files
77
from .convert import prep_conversion
8+
from .due import due, Doi
89
from .parser import get_study_sessions
910
from .queue import queue_conversion
1011
from .utils import anonymize_sid, load_heuristic, treat_infofile, SeqInfo
@@ -122,6 +123,12 @@ def ensure_heuristic_arg(heuristic=None):
122123
% ', '.join(get_known_heuristic_names()))
123124

124125

126+
@due.dcite(
127+
Doi('10.5281/zenodo.1012598'),
128+
path='heudiconv',
129+
description='Flexible DICOM converter for organizing brain imaging data',
130+
version=__version__,
131+
cite_module=True)
125132
def workflow(*, dicom_dir_template=None, files=None, subjs=None,
126133
converter='dcm2niix', outdir='.', locator=None, conv_outdir=None,
127134
anon_cmd=None, heuristic=None, with_prov=False, session=None,

0 commit comments

Comments
 (0)