Skip to content

Commit 2a42037

Browse files
authored
Merge pull request #11 from nipreps/integration_testing
WIP: Add integration testing and github actions
2 parents caaa0aa + 2017d45 commit 2a42037

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+6241
-685
lines changed

.circleci/config.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: 2.1
2+
3+
orbs:
4+
conda: circleci/[email protected]
5+
6+
jobs:
7+
tests:
8+
executor:
9+
name: conda/default
10+
steps:
11+
- checkout
12+
- conda/update-env:
13+
environment-file: env.yml
14+
environment-name: petprep
15+
- conda/run:
16+
environment-name: petprep
17+
command: |
18+
pip install -e .[tests]
19+
pytest -n auto --junitxml=test-results/junit.xml --cov=petprep --cov-report=xml
20+
- store_test_results:
21+
path: test-results
22+
- store_artifacts:
23+
path: coverage.xml
24+
destination: coverage.xml
25+
26+
workflows:
27+
version: 2
28+
test:
29+
jobs:
30+
- tests

.github/workflows/coverage.yml

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

.github/workflows/tests.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Stable tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
env:
16+
FORCE_COLOR: true
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
test:
27+
runs-on: ${{ matrix.os }}
28+
strategy:
29+
matrix:
30+
os: [ 'ubuntu-latest' ]
31+
python-version: ['3.10', '3.11', '3.12', '3.13']
32+
dependencies: ['latest', 'pre']
33+
include:
34+
- os: ubuntu-latest
35+
python-version: '3.10'
36+
dependencies: 'min'
37+
env:
38+
DEPENDS: ${{ matrix.dependencies }}
39+
steps:
40+
- uses: actions/checkout@v4
41+
with:
42+
submodules: recursive
43+
fetch-depth: 0
44+
- uses: actions/cache@v4
45+
with:
46+
path: ~/.cache/templateflow
47+
key: templateflow-v1
48+
- name: Install dependencies
49+
run: |
50+
sudo apt update
51+
sudo apt install -y --no-install-recommends graphviz
52+
- name: Install the latest version of uv
53+
uses: astral-sh/setup-uv@v6
54+
- name: Set up Python ${{ matrix.python-version }}
55+
uses: actions/setup-python@v5
56+
with:
57+
python-version: ${{ matrix.python-version }}
58+
- name: Display Python version
59+
run: python -c "import sys; print(sys.version)"
60+
- name: Install tox
61+
run: |
62+
uv tool install --with=tox-uv --with=tox-gh-actions tox
63+
- name: Show tox config
64+
run: tox c
65+
- name: Run tox
66+
run: tox -v --exit-and-dump-after 1200
67+
- uses: codecov/codecov-action@v5
68+
with:
69+
token: ${{ secrets.CODECOV_TOKEN }}
70+
if: ${{ always() }}
71+
72+
checks:
73+
runs-on: ubuntu-latest
74+
continue-on-error: true
75+
strategy:
76+
matrix:
77+
check: ['style', 'spellcheck']
78+
steps:
79+
- uses: actions/checkout@v4
80+
with:
81+
persist-credentials: false
82+
- name: Install the latest version of uv
83+
uses: astral-sh/setup-uv@v6
84+
- name: Install tox
85+
run: uv tool install tox --with=tox-uv
86+
- name: Show tox config
87+
run: tox c -e ${{ matrix.check }}
88+
- name: Run check
89+
run: tox -e ${{ matrix.check }}

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Python cache and bytecode files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.pyo
6+
*.pyd
7+
8+
# Coverage reports
9+
.coverage
10+
.coverage.*
11+
htmlcov/
12+
coverage.xml
13+
14+
# Build directories
15+
build/
16+
dist/
17+
.eggs/
18+
*.egg-info/
19+
*.egg
20+
# docs build
21+
/docs/_build/
22+
23+
# Editor and OS artifacts
24+
.DS_Store
25+
*.swp
26+
*~
27+
.vscode/
28+
.idea/
29+
.env
30+
.envrc
31+
32+
# Additional
33+
.ipynb_checkpoints/
34+
_version.py

.tox/.pkg/file.lock

Whitespace-only changes.

NOTICE

Lines changed: 0 additions & 1 deletion
This file was deleted.

NOTICE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
PETPrep
2+
Copyright The NiPreps Developers.
3+
4+
This product includes software developed by
5+
the NiPreps Community (https://nipreps.org/).
6+
7+
Portions of this software were developed at the Department of
8+
Psychology at Stanford University, Stanford, CA, US.
9+
10+
This software is also distributed as a Docker container image.
11+
The bootstrapping file for the image ("Dockerfile") is licensed
12+
under the MIT License.
13+
14+
This software may be distributed through an add-on package called
15+
"Docker Wrapper" that is under the BSD 3-clause License.

docs/faq.rst

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -321,26 +321,4 @@ finer control can be achieved of what files are visible to PETPrep.
321321
Note that any discrepancies between the pre-indexed database and
322322
the BIDS dataset complicate the provenance of PETPrep derivatives.
323323
If ``--bids-database-dir`` is used, the referenced directory should be
324-
preserved for the sake of reporting and reproducibility.
325-
326-
Error in slice timing correction: *insufficient length of BOLD data after discarding nonsteady-states*
327-
------------------------------------------------------------------------------------------------------
328-
Typically, the scanner will be in a *nonsteady state* during a few initial time points of the acquisition,
329-
until it stabilizes.
330-
These *nonsteady states* (also called *dummy* scans) typically show greater T1 contrast and higher average
331-
intensity, and therefore potentially are detrimental if used in the interpolation of slice timing corrections.
332-
Hence, *nonsteady states* are discarded by the slice timing correction tool (in this case, AFNI's ``3dTShift``).
333-
However, ``3dTShift`` requires that at least five (5) time points are present in the target series, after
334-
dismissing the initial *nonsteady states*.
335-
336-
*PETPrep* estimates the number of *nonsteady states* within the pipeline, unless the parameter is provided
337-
by the user with the argument ``--dummy-scans <num>``.
338-
Either way, if the number of *nonsteady states* is, say 4, then the length of the BOLD series must be greater
339-
than 8.
340-
If you encounter this error, first check that the number of *nonsteady states* is not suspiciously large
341-
(it typically ranges from zero to five).
342-
Next, if the number of *nonsteady states* is reasonable, consider why your BOLD time series are so short
343-
and whether slice timing correction is appropriate under these conditions.
344-
Finally, you can either skip the slice-timing correction with the argument ``--ignore slicetiming`` or
345-
enforce a number of *nonsteady states* lower than the maximum for your data with ``--dummy-scans <num>``.
346-
Please note that both strategies will apply to all tasks and runs that are to be processed.
324+
preserved for the sake of reporting and reproducibility.

docs/outputs.rst

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -363,25 +363,6 @@ Then the output will include::
363363
These may then be used independently with multi-echo tools, such as `tedana`_,
364364
to perform more advanced denoising or alternative combination strategies.
365365

366-
.. danger::
367-
Slice timing correction in *PETPrep* is referenced to the middle slice by default,
368-
which leads to a time shift in the volume onsets by 0.5 TR (repetition time).
369-
For example, assuming a TR of 2s, original onsets of 0, 2, and 4s would be shifted
370-
to 1, 3, and 5s, respectively.
371-
In case you did execute slice timing correction, you must check that subsequent
372-
analyses (e.g., general linear modeling) consider the right onset shifts.
373-
For example, when specifying a first-level model, you should set parameters in your
374-
software package or first-level model function accordingly (e.g., select the middle
375-
slice as reference).
376-
Alternatively, you could manually adjust the volume onsets (e.g. as mentioned in
377-
the example above from [0, 2, 4] to [1, 3, 5]) or the event onsets accordingly.
378-
In contrast to volume onsets, event onsets need to be shifted *backward* by half a TR,
379-
for example, from [5, 10, 15] to [4, 9, 14].
380-
381-
Further information on this issue is found at
382-
`this blog post (with thanks to Russell Poldrack and Jeanette Mumford)
383-
<https://reproducibility.stanford.edu/slice-timing-correction-in-petprep-and-linear-modeling/>`__.
384-
385366
Confounds
386367
---------
387368
The :abbr:`BOLD (blood-oxygen level dependent)` signal measured with fMRI is a mixture of fluctuations

docs/workflows.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ Processing pipeline details
55
===========================
66
*PETPrep* adapts its pipeline depending on what data and metadata are
77
available and are used as the input.
8-
For example, slice timing correction will be
9-
performed only if the ``SliceTiming`` metadata field is found for the input
10-
dataset.
8+
Certain processing steps will run only when the required metadata is
9+
available in the input dataset.
1110

1211
A (very) high-level view of the simplest pipeline (for a single-band dataset with only
1312
one task, single-run, with no slice-timing information nor fieldmap acquisitions)
@@ -571,7 +570,6 @@ Confounds estimation
571570
metadata={
572571
"FrameTimesStart": [0, 2, 4, 6],
573572
"FrameDuration": [2, 2, 2, 2],
574-
"SliceTiming": [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
575573
},
576574
regressors_all_comps=False,
577575
regressors_dvars_th=1.5,

0 commit comments

Comments
 (0)