Skip to content

Commit 8b25733

Browse files
committed
MAINT: Add authorship
1 parent 32b276f commit 8b25733

File tree

8 files changed

+230
-1
lines changed

8 files changed

+230
-1
lines changed

.mailmap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Christopher J. Markiewicz <[email protected]>
2+
Christopher J. Markiewicz <[email protected]> <[email protected]>
3+
Christopher J. Markiewicz <[email protected]> <[email protected]>
4+
Mathias Goncalves <[email protected]>
5+
6+
7+
Oscar Esteban <[email protected]>
8+

.maint/contributors.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

.maint/developers.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[
2+
{
3+
"affiliation": "Department of Psychology, Stanford University",
4+
"name": "Goncalves, Mathias",
5+
"orcid": "0000-0002-7252-7771"
6+
},
7+
{
8+
"affiliation": "Department of Psychology, Stanford University",
9+
"name": "Markiewicz, Christopher J.",
10+
"orcid": "0000-0002-6533-164X"
11+
},
12+
{
13+
"affiliation": "Department of Psychology, Stanford University",
14+
"name": "Poldrack, Russell A.",
15+
"orcid": "0000-0001-6755-0259"
16+
},
17+
{
18+
"affiliation": "Lausanne University Hospital and University of Lausanne, Lausanne, Switzerland",
19+
"name": "Esteban, Oscar",
20+
"orcid": "0000-0001-8435-6191"
21+
},
22+
{
23+
"affiliation": "University of Minnesota",
24+
"name": "Feczko, Eric"
25+
},
26+
{
27+
"affiliation": "University of Minnesota",
28+
"name": "Fair, Damien A."
29+
}
30+
]

.maint/former.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

.maint/update_zenodo.py

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/usr/bin/env python3
2+
"""Update and sort the creators list of the zenodo record."""
3+
import sys
4+
from pathlib import Path
5+
import json
6+
from fuzzywuzzy import fuzz, process
7+
8+
# These ORCIDs should go last
9+
CREATORS_LAST = ['Poldrack, Russell A.', 'Fair, Damien A.']
10+
CONTRIBUTORS_LAST = []
11+
12+
13+
def sort_contributors(entries, git_lines, exclude=None, last=None):
14+
"""Return a list of author dictionaries, ordered by contribution."""
15+
last = last or []
16+
sorted_authors = sorted(entries, key=lambda i: i['name'])
17+
18+
first_last = [' '.join(val['name'].split(',')[::-1]).strip()
19+
for val in sorted_authors]
20+
first_last_excl = [' '.join(val['name'].split(',')[::-1]).strip()
21+
for val in exclude or []]
22+
23+
unmatched = []
24+
author_matches = []
25+
position = 1
26+
for ele in git_lines:
27+
matches = process.extract(ele, first_last, scorer=fuzz.token_sort_ratio,
28+
limit=2)
29+
if not matches:
30+
return [], []
31+
# matches is a list [('First match', % Match), ('Second match', % Match)]
32+
if matches[0][1] > 80:
33+
val = sorted_authors[first_last.index(matches[0][0])]
34+
else:
35+
# skip unmatched names
36+
if ele not in first_last_excl:
37+
unmatched.append(ele)
38+
continue
39+
40+
if val not in author_matches:
41+
val['position'] = position
42+
author_matches.append(val)
43+
position += 1
44+
45+
names = {' '.join(val['name'].split(',')[::-1]).strip() for val in author_matches}
46+
for missing_name in first_last:
47+
if missing_name not in names:
48+
missing = sorted_authors[first_last.index(missing_name)]
49+
missing['position'] = position
50+
author_matches.append(missing)
51+
position += 1
52+
53+
all_names = [val['name'] for val in author_matches]
54+
for last_author in last:
55+
author_matches[all_names.index(last_author)]['position'] = position
56+
position += 1
57+
58+
author_matches = sorted(author_matches, key=lambda k: k['position'])
59+
60+
return author_matches, unmatched
61+
62+
63+
def get_git_lines(fname='line-contributors.txt'):
64+
"""Run git-line-summary."""
65+
import shutil
66+
import subprocess as sp
67+
contrib_file = Path(fname)
68+
69+
lines = []
70+
if contrib_file.exists():
71+
print('WARNING: Reusing existing line-contributors.txt file.', file=sys.stderr)
72+
lines = contrib_file.read_text().splitlines()
73+
74+
cmd = [shutil.which('git-line-summary')]
75+
if cmd == [None]:
76+
cmd = [shutil.which('git-summary'), "--line"]
77+
if not lines and cmd[0]:
78+
print(f"Running {' '.join(cmd)!r} on repo")
79+
lines = sp.check_output(cmd).decode().splitlines()
80+
lines = [l for l in lines if "Not Committed Yet" not in l]
81+
contrib_file.write_text('\n'.join(lines))
82+
83+
if not lines:
84+
raise RuntimeError("""\
85+
Could not find line-contributors from git repository.%s""" % """ \
86+
git-(line-)summary not found, please install git-extras. """ * (cmd[0] is None))
87+
return [' '.join(line.strip().split()[1:-1]) for line in lines if '%' in line]
88+
89+
90+
if __name__ == '__main__':
91+
data = get_git_lines()
92+
93+
zenodo_file = Path('.zenodo.json')
94+
zenodo = json.loads(zenodo_file.read_text())
95+
96+
creators = json.loads(Path('.maint/developers.json').read_text())
97+
zen_creators, miss_creators = sort_contributors(
98+
creators, data,
99+
exclude=json.loads(Path('.maint/former.json').read_text()),
100+
last=CREATORS_LAST)
101+
contributors = json.loads(Path('.maint/contributors.json').read_text())
102+
zen_contributors, miss_contributors = sort_contributors(
103+
contributors, data,
104+
exclude=json.loads(Path('.maint/former.json').read_text()),
105+
last=CONTRIBUTORS_LAST)
106+
zenodo['creators'] = zen_creators
107+
zenodo['contributors'] = zen_contributors
108+
109+
print("Some people made commits, but are missing in .maint/ "
110+
"files: %s." % ', '.join(set(miss_creators).intersection(miss_contributors)),
111+
file=sys.stderr)
112+
113+
# Remove position
114+
for creator in zenodo['creators']:
115+
del creator['position']
116+
if isinstance(creator['affiliation'], list):
117+
creator['affiliation'] = creator['affiliation'][0]
118+
119+
for creator in zenodo['contributors']:
120+
creator['type'] = 'Researcher'
121+
del creator['position']
122+
if isinstance(creator['affiliation'], list):
123+
creator['affiliation'] = creator['affiliation'][0]
124+
125+
zenodo_file.write_text('%s\n' % json.dumps(zenodo, indent=2))

.pre-commit-config.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ repos:
1010
rev: 22.3.0
1111
hooks:
1212
- id: black
13+
files: ^nibabies/
1314
- repo: https://github.com/pycqa/isort
1415
rev: 5.10.1
1516
hooks:
16-
- id: isort
17+
- id: isort
18+
files: ^nibabies/

.zenodo.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"title": "NiBabies: a robust preprocessing pipeline for infant functional MRI",
3+
"description": "<p>NiBabies is a robust and easy-to-use pipeline for preprocessing of diverse infant and neonate fMRI data. The transparent workflow dispenses of manual intervention, thereby ensuring the reproducibility of the results.</p>",
4+
"contributors": [],
5+
"creators": [
6+
{
7+
"affiliation": "Department of Psychology, Stanford University",
8+
"name": "Goncalves, Mathias",
9+
"orcid": "0000-0002-7252-7771"
10+
},
11+
{
12+
"affiliation": "Department of Psychology, Stanford University",
13+
"name": "Markiewicz, Christopher J.",
14+
"orcid": "0000-0002-6533-164X"
15+
},
16+
{
17+
"affiliation": "Lausanne University Hospital and University of Lausanne, Lausanne, Switzerland",
18+
"name": "Esteban, Oscar",
19+
"orcid": "0000-0001-8435-6191"
20+
},
21+
{
22+
"affiliation": "University of Minnesota",
23+
"name": "Feczko, Eric"
24+
},
25+
{
26+
"affiliation": "Department of Psychology, Stanford University",
27+
"name": "Poldrack, Russell A.",
28+
"orcid": "0000-0001-6755-0259"
29+
},
30+
{
31+
"affiliation": "University of Minnesota",
32+
"name": "Fair, Damien A."
33+
}
34+
],
35+
"keywords": [
36+
"neuroimaging",
37+
"workflow",
38+
"pipeline",
39+
"preprocessing",
40+
"fMRI",
41+
"BIDS",
42+
"infant"
43+
],
44+
"license": "Apache-2.0",
45+
"related_identifiers": [
46+
{
47+
"identifier": "https://github.com/nipreps/nibabies",
48+
"relation": "documents",
49+
"scheme": "url"
50+
},
51+
{
52+
"identifier": "10.5281/zenodo.6418986",
53+
"relation": "isPartOf",
54+
"scheme": "doi"
55+
}
56+
],
57+
"upload_type": "software"
58+
}

setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ docs =
7474
duecredit =
7575
duecredit
7676
citeproc-py != 0.5.0
77+
maint =
78+
fuzzywuzzy
79+
python-Levenshtein
7780
pointclouds =
7881
pyntcloud
7982
style =
@@ -90,6 +93,7 @@ all =
9093
%(aroma)s
9194
%(doc)s
9295
%(duecredit)s
96+
%(maint)s
9397
%(pointclouds)s
9498
%(style)s
9599
%(test)s

0 commit comments

Comments
 (0)