Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring up to date with fMRIPrep 24.1.1 #455

Merged
merged 30 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
832703b
Update fMRIPrep version.
tsalo Oct 31, 2024
75393ad
Merge remote-tracking branch 'upstream/main' into fmriprep-24
tsalo Oct 31, 2024
436dd19
Update linting rules.
tsalo Oct 31, 2024
1d4eaaf
Run ruff --fix.
tsalo Oct 31, 2024
ecc4901
Fix some style issues.
tsalo Oct 31, 2024
42c8602
Fix remaining ruff issues.
tsalo Oct 31, 2024
b43b72f
Update more stuff.
tsalo Oct 31, 2024
6fdd6ad
Update test_cli.py
tsalo Oct 31, 2024
dba9ff7
Run ruff format.
tsalo Oct 31, 2024
ca1aa05
Fix stuff.
tsalo Oct 31, 2024
6527acb
Merge remote-tracking branch 'upstream/main' into fmriprep-24
tsalo Nov 1, 2024
aa2e888
Keep bringing it up to date.
tsalo Nov 1, 2024
8cb0a66
Fix things up some more.
tsalo Nov 1, 2024
704e4e0
Keep working.
tsalo Nov 1, 2024
71b96fc
Update config.py
tsalo Nov 1, 2024
2fcaabf
Fix.
tsalo Nov 1, 2024
1004366
Update base.py
tsalo Nov 1, 2024
84109c4
Update bids.py
tsalo Nov 1, 2024
67db5a3
Update.
tsalo Nov 1, 2024
42a6671
Update run.py
tsalo Nov 1, 2024
3fd084f
Use init_bold_fsLR_resampling_wf from fMRIPrep.
tsalo Nov 1, 2024
c444764
Fix generate_reports calls.
tsalo Nov 1, 2024
2fa774a
Don't try to invert.
tsalo Nov 1, 2024
10bc7ab
Use internal copy of generate_reports.
tsalo Nov 1, 2024
4f604ba
Add `--aggregate-session-reports`.
tsalo Nov 1, 2024
1046735
Update report specs.
tsalo Nov 1, 2024
c2d489c
Update asl.py
tsalo Nov 1, 2024
f88baf2
Fix a couple of things.
tsalo Nov 2, 2024
7c5b1d9
Update io_spec.json
tsalo Nov 4, 2024
9b4d5d8
Reproduce nipreps/fmriprep#3369.
tsalo Nov 4, 2024
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
3 changes: 2 additions & 1 deletion .circleci/get_data.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python3
"""Download test data."""

import sys

from aslprep.tests.utils import download_test_data

if __name__ == "__main__":
if __name__ == '__main__':
data_dir = sys.argv[1]
dset = sys.argv[2]
download_test_data(dset, data_dir)
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ skip = .git,*.pdf,*.svg,*.html,dataset_description.json
# te - TE
# Weill - name
# reson - Reson. abbreviation in citation
ignore-words-list = te,weill,reson
ignore-words-list = te,weill,reson,ND
43 changes: 22 additions & 21 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint code
name: Contribution checks

on:
push:
Expand All @@ -12,26 +12,27 @@ defaults:
run:
shell: bash

jobs:
stable:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-latest']
python-version: ['3.10']
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install flake8 and related packages
run: python -m pip install \
flake8 flake8-absolute-import flake8-black flake8-docstrings \
flake8-isort flake8-pyproject flake8-unused-arguments \
flake8-use-fstring pep8-naming
- name: Check aslprep
run: python -m flake8 aslprep
- run: pipx run ruff check .
- run: pipx run ruff format --diff .

codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Codespell
uses: codespell-project/actions-codespell@v2
135 changes: 72 additions & 63 deletions .maint/update_authors.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""Update and sort the creators list of the zenodo record."""

import json
import sys
from pathlib import Path
Expand Down Expand Up @@ -36,30 +37,30 @@ def read_md_table(md_text):
keys = None
retval = []
for line in md_text.splitlines():
if line.strip().startswith("| --- |"):
keys = (k.replace("*", "").strip() for k in prev.split("|"))
if line.strip().startswith('| --- |'):
keys = (k.replace('*', '').strip() for k in prev.split('|'))
keys = [k.lower() for k in keys if k]
continue
elif not keys:
prev = line
continue

if not line or not line.strip().startswith("|"):
if not line or not line.strip().startswith('|'):
break

values = [v.strip() or None for v in line.split("|")][1:-1]
retval.append({k: v for k, v in zip(keys, values) if v})
values = [v.strip() or None for v in line.split('|')][1:-1]
retval.append({k: v for k, v in zip(keys, values, strict=False) if v})

return retval


def sort_contributors(entries, git_lines, exclude=None, last=None):
"""Return a list of author dictionaries, ordered by contribution."""
last = last or []
sorted_authors = sorted(entries, key=lambda i: i["name"])
sorted_authors = sorted(entries, key=lambda i: i['name'])

first_last = [" ".join(val["name"].split(",")[::-1]).strip() for val in sorted_authors]
first_last_excl = [" ".join(val["name"].split(",")[::-1]).strip() for val in exclude or []]
first_last = [' '.join(val['name'].split(',')[::-1]).strip() for val in sorted_authors]
first_last_excl = [' '.join(val['name'].split(',')[::-1]).strip() for val in exclude or []]

unmatched = []
author_matches = []
Expand All @@ -77,15 +78,15 @@ def sort_contributors(entries, git_lines, exclude=None, last=None):
if val not in author_matches:
author_matches.append(val)

names = {" ".join(val["name"].split(",")[::-1]).strip() for val in author_matches}
names = {' '.join(val['name'].split(',')[::-1]).strip() for val in author_matches}
for missing_name in first_last:
if missing_name not in names:
missing = sorted_authors[first_last.index(missing_name)]
author_matches.append(missing)

position_matches = []
for i, item in enumerate(author_matches):
pos = item.pop("position", None)
pos = item.pop('position', None)
if pos is not None:
position_matches.append((i, int(pos)))

Expand All @@ -97,7 +98,7 @@ def sort_contributors(entries, git_lines, exclude=None, last=None):
return author_matches, unmatched


def get_git_lines(fname="line-contributors.txt"):
def get_git_lines(fname='line-contributors.txt'):
"""Run git-line-summary."""
import shutil
import subprocess as sp
Expand All @@ -106,31 +107,32 @@ def get_git_lines(fname="line-contributors.txt"):

lines = []
if contrib_file.exists():
print("WARNING: Reusing existing line-contributors.txt file.", file=sys.stderr)
print('WARNING: Reusing existing line-contributors.txt file.', file=sys.stderr)
lines = contrib_file.read_text().splitlines()

git_line_summary_path = shutil.which("git-line-summary")
git_line_summary_path = shutil.which('git-line-summary')
if not lines and git_line_summary_path:
print("Running git-line-summary on repo")
print('Running git-line-summary on repo')
lines = sp.check_output([git_line_summary_path]).decode().splitlines()
lines = [l for l in lines if "Not Committed Yet" not in l]
contrib_file.write_text("\n".join(lines))
lines = [line for line in lines if 'Not Committed Yet' not in line]
contrib_file.write_text('\n'.join(lines))

if not lines:
raise RuntimeError(
"""\
Could not find line-contributors from git repository.%s"""
% """ \
Could not find line-contributors from git repository.{}""".format(
""" \
git-line-summary not found, please install git-extras. """
* (git_line_summary_path is None)
* (git_line_summary_path is None)
)
)
return [" ".join(line.strip().split()[1:-1]) for line in lines if "%" in line]
return [' '.join(line.strip().split()[1:-1]) for line in lines if '%' in line]


def _namelast(inlist):
retval = []
for i in inlist:
i["name"] = (f"{i.pop('name', '')} {i.pop('lastname', '')}").strip()
i['name'] = (f"{i.pop('name', '')} {i.pop('lastname', '')}").strip()
retval.append(i)
return retval

Expand All @@ -142,13 +144,13 @@ def cli():


@cli.command()
@click.option("-z", "--zenodo-file", type=click.Path(exists=True), default=".zenodo.json")
@click.option("-m", "--maintainers", type=click.Path(exists=True), default=".maint/MAINTAINERS.md")
@click.option('-z', '--zenodo-file', type=click.Path(exists=True), default='.zenodo.json')
@click.option('-m', '--maintainers', type=click.Path(exists=True), default='.maint/MAINTAINERS.md')
@click.option(
"-c", "--contributors", type=click.Path(exists=True), default=".maint/CONTRIBUTORS.md"
'-c', '--contributors', type=click.Path(exists=True), default='.maint/CONTRIBUTORS.md'
)
@click.option("--pi", type=click.Path(exists=True), default=".maint/PIs.md")
@click.option("-f", "--former-file", type=click.Path(exists=True), default=".maint/FORMER.md")
@click.option('--pi', type=click.Path(exists=True), default='.maint/PIs.md')
@click.option('-f', '--former-file', type=click.Path(exists=True), default='.maint/FORMER.md')
def zenodo(
zenodo_file,
maintainers,
Expand All @@ -175,45 +177,45 @@ def zenodo(
zen_pi = _namelast(
sorted(
read_md_table(Path(pi).read_text()),
key=lambda v: (int(v.get("position", -1)), v.get("lastname")),
key=lambda v: (int(v.get('position', -1)), v.get('lastname')),
)
)

zenodo["creators"] = zen_creators
zenodo["contributors"] = zen_contributors + zen_pi
zenodo['creators'] = zen_creators
zenodo['contributors'] = zen_contributors + zen_pi

misses = set(miss_creators).intersection(miss_contributors)
if misses:
print(
"Some people made commits, but are missing in .maint/ " f"files: {', '.join(misses)}",
f"Some people made commits, but are missing in .maint/ files: {', '.join(misses)}",
file=sys.stderr,
)

# Remove position
for creator in zenodo["creators"]:
creator.pop("position", None)
creator.pop("handle", None)
if isinstance(creator["affiliation"], list):
creator["affiliation"] = creator["affiliation"][0]
for creator in zenodo['creators']:
creator.pop('position', None)
creator.pop('handle', None)
if isinstance(creator['affiliation'], list):
creator['affiliation'] = creator['affiliation'][0]

for creator in zenodo["contributors"]:
creator.pop("handle", None)
creator["type"] = "Researcher"
creator.pop("position", None)
for creator in zenodo['contributors']:
creator.pop('handle', None)
creator['type'] = 'Researcher'
creator.pop('position', None)

if isinstance(creator["affiliation"], list):
creator["affiliation"] = creator["affiliation"][0]
if isinstance(creator['affiliation'], list):
creator['affiliation'] = creator['affiliation'][0]

Path(zenodo_file).write_text("%s\n" % json.dumps(zenodo, indent=2))
Path(zenodo_file).write_text(f'{json.dumps(zenodo, indent=2)}\n')


@cli.command()
@click.option("-m", "--maintainers", type=click.Path(exists=True), default=".maint/MAINTAINERS.md")
@click.option('-m', '--maintainers', type=click.Path(exists=True), default='.maint/MAINTAINERS.md')
@click.option(
"-c", "--contributors", type=click.Path(exists=True), default=".maint/CONTRIBUTORS.md"
'-c', '--contributors', type=click.Path(exists=True), default='.maint/CONTRIBUTORS.md'
)
@click.option("--pi", type=click.Path(exists=True), default=".maint/PIs.md")
@click.option("-f", "--former-file", type=click.Path(exists=True), default=".maint/FORMER.md")
@click.option('--pi', type=click.Path(exists=True), default='.maint/PIs.md')
@click.option('-f', '--former-file', type=click.Path(exists=True), default='.maint/FORMER.md')
def publication(
maintainers,
contributors,
Expand All @@ -234,54 +236,61 @@ def publication(
pi_hits = _namelast(
sorted(
read_md_table(Path(pi).read_text()),
key=lambda v: (int(v.get("position", -1)), v.get("lastname")),
key=lambda v: (int(v.get('position', -1)), v.get('lastname')),
)
)

pi_names = [pi["name"] for pi in pi_hits]
hits = [hit for hit in hits if hit["name"] not in pi_names] + pi_hits
pi_names = [pi['name'] for pi in pi_hits]
hits = [hit for hit in hits if hit['name'] not in pi_names] + pi_hits

def _aslist(value):
if isinstance(value, (list, tuple)):
if isinstance(value, list | tuple):
return value
return [value]

# Remove position
affiliations = []
for item in hits:
item.pop("position", None)
for a in _aslist(item.get("affiliation", "Unaffiliated")):
item.pop('position', None)
for a in _aslist(item.get('affiliation', 'Unaffiliated')):
if a not in affiliations:
affiliations.append(a)

aff_indexes = [
", ".join(
', '.join(
[
"%d" % (affiliations.index(a) + 1)
for a in _aslist(author.get("affiliation", "Unaffiliated"))
'%d' % (affiliations.index(a) + 1)
for a in _aslist(author.get('affiliation', 'Unaffiliated'))
]
)
for author in hits
]

if misses:
print(
"Some people made commits, but are missing in .maint/ " f"files: {', '.join(misses)}",
f"Some people made commits, but are missing in .maint/ files: {', '.join(misses)}",
file=sys.stderr,
)

print("Authors (%d):" % len(hits))
print('Authors (%d):' % len(hits))
print(
"%s."
% "; ".join(["%s \\ :sup:`%s`\\ " % (i["name"], idx) for i, idx in zip(hits, aff_indexes)])
'{}.'.format(
'; '.join(
[
rf'{i["name"]} \ :sup:`{idx}`\ '
for i, idx in zip(hits, aff_indexes, strict=False)
]
)
)
)

print(
"\n\nAffiliations:\n%s"
% "\n".join(["{0: >2}. {1}".format(i + 1, a) for i, a in enumerate(affiliations)])
'\n\nAffiliations:\n{}'.format(
'\n'.join([f'{i + 1: >2}. {a}' for i, a in enumerate(affiliations)])
)
)


if __name__ == "__main__":
"""Install entry-point"""
if __name__ == '__main__':
""" Install entry-point """
cli()
29 changes: 17 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
exclude: ".*/data/.*"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 23.1.0
- id: trailing-whitespace
exclude: '.*\.svg'
- id: end-of-file-fixer
exclude: '.*\.svg'
- id: check-yaml
- id: check-json
- id: check-toml
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.2
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- id: ruff
args: [ --fix ]
- id: ruff-format
- id: ruff
args: [ --select, ISC001, --fix ]
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,6 @@ Bids validation

ENH - Add GE SCAN processing with deltam or cbf

ENH - supressed freesurfer processing, FSL FLIRT with BBR for registration
ENH - suppressed freesurfer processing, FSL FLIRT with BBR for registration

ENH - basil and scorescrub as options, cbf computation is only default
Loading