Skip to content

Commit

Permalink
Merge branch 'main' into update-canon-phantoms
Browse files Browse the repository at this point in the history
  • Loading branch information
bendhouseart committed Jun 4, 2024
2 parents f6d4993 + 1ff4023 commit 47b4085
Show file tree
Hide file tree
Showing 70 changed files with 9,935 additions and 3,360 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/phantoms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- switch-phantoms-to-s3
pull_request:
branches:
- main
Expand Down Expand Up @@ -66,6 +67,18 @@ jobs:
brew install dcm2niix
fi
- name: Debug
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
timeout-minutes: 15
with:
limit-access-to-actor: true

- name: Check dcm2niix is installed and on path
if: runner.os != 'Windows'
run:
dcm2niix -h

- name: Install dcm2niix windows
if: runner.os == 'Windows'
run: |
Expand All @@ -84,7 +97,6 @@ jobs:
run: |
cd pypet2bids
pip install .
pip install gdown
- name: Install Poetry Build Package
run: |
Expand All @@ -99,9 +111,9 @@ jobs:
- name: Install BIDS Validator
run: npm install -g bids-validator

- name: Collect Phantoms from Google Drive
- name: Collect Phantoms
if: ${{ steps.cache-phantoms.outputs.cache-hit != 'true' }} && ${{ !env.ACT }}
run: gdown ${{ secrets.ZIPPED_OPEN_NEURO_PET_PHANTOMS_URL }} -O PHANTOMS.zip
run: wget -O PHANTOMS.zip https://openneuropet.s3.amazonaws.com/US-sourced-OpenNeuroPET-Phantoms.zip

- name: Decompress phantoms windows
if: steps.cache-phantoms.outputs.cache-hit != 'true' && !env.ACT && runner.os == 'Windows'
Expand Down
44 changes: 26 additions & 18 deletions .github/workflows/python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- main
- switch-phantoms-to-s3
workflow_call:
workflow_dispatch:
inputs:
Expand All @@ -18,8 +19,7 @@ jobs:
runs-on: ${{ matrix.os }}

env:
ECAT_TEST_FOLDER: "cimbi36"
REAL_TEST_ECAT_PATH: cimbi36/Gris_102_19_2skan-2019.04.30.13.04.41_em_3d.v
REAL_ECAT_TEST_PATH: ${{ github.workspace }}/OpenNeuroPET-Phantoms/sourcedata/SiemensHRRT-JHU/Hoffman.v
SMALLER_ECAT_PATH: ${{ github.workspace }}/ecat_validation/ECAT7_multiframe.v.gz
TEST_ECAT_PATH: ${{ github.workspace }}/ecat_validation/ECAT7_multiframe.v
OUTPUT_NIFTI_PATH: ${{ github.workspace}}/pypet2bids/tests/ECAT7_multiframe.nii
Expand All @@ -36,41 +36,49 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v2

- name: Cache ECAT
id: cache-ecat
- name: Cache Phantoms
id: cache-phantoms
uses: actions/cache@v2
with:
path: cimbi36
key: ${{ runner.os }}-ecats
path: US-sourced-OpenNeuroPET-Phantoms.zip
key: ${{ runner.os }}-phantoms

- name: Set up python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
cd pypet2bids
pip3 install .
python -m pip install --upgrade pip
pip install poetry
poetry install --with dev
- name: Install gdown and collect Ecat from Google Drive
if: steps.cache-ecat.outputs.cache-hit != 'true'
run: "python3 -m pip install gdown && gdown ${{ secrets.CIMBI_ECAT_ON_GOOGLE_DRIVE }} -O ecat_test"
- name: Collect ECAT and other phantoms
if: steps.cache-phantoms.outputs.cache-hit != 'true'
run: "wget https://openneuropet.s3.amazonaws.com/US-sourced-OpenNeuroPET-Phantoms.zip"

- name: Decompress dataset
if: steps.cache-ecat.outputs.cache-hit != 'true'
run: "tar xvzf ecat_test && rm ecat_test"
- name: Decompress ECAT and other phantoms
run: "unzip US-sourced-OpenNeuroPET-Phantoms.zip"

- name: Debug
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
timeout-minutes: 15
with:
limit-access-to-actor: true

- name: Test CLI --help
run: |
cd pypet2bids/
python3 -m pypet2bids.ecat_cli --help
poetry run python3 -m pypet2bids.ecat_cli --help
- name: Test CLI Ecat Dump
run: |
cd pypet2bids/
python3 -m pypet2bids.ecat_cli ../${{ env.REAL_TEST_ECAT_PATH }} --dump
poetry run python3 -m pypet2bids.ecat_cli ${{ env.REAL_ECAT_TEST_PATH }} --dump
# the larger real data file uses too much ram for the github runner, we use the small file for
# heavy io operations instead
Expand All @@ -79,9 +87,9 @@ jobs:
gzip -d ${{ env.SMALLER_ECAT_PATH }}
- name: Test ecatread
run: "cd pypet2bids/ && python3 -m tests.test_ecatread"
run: "cd pypet2bids/ && poetry run python3 -m tests.test_ecatread"

- name: Run All Other Python Tests w/ Pytest
run: |
cd pypet2bids
pytest -k 'not write_pixel_data' -k 'not test_convert_pmod_to_blood' tests/
poetry run pytest -k 'not write_pixel_data' -k 'not test_convert_pmod_to_blood' tests/
23 changes: 23 additions & 0 deletions .github/workflows/readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: readthedocs/actions
on:
pull_request_target:
types: [opened, synchronize, reopened]
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false

permissions:
pull-requests: write

jobs:
pull-request-links:
runs-on: ubuntu-latest
steps:
- name: Preview RTD
uses: readthedocs/actions/preview@v1
with:
project-slug: "pet2bids"
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,13 @@ D:\\BIDS*
# test data
*OpenNeuroPET-Phantoms*
**PHANTOMS.zip
ecat_validation/ECAT7_multiframe.v
variables.env
ecat_testing/matlab/
ecat_testing/steps/
ecat_testing/**/*.nii*
*osem*
*fbp*

matlab/SiemensHRRTparameters.txt

17 changes: 6 additions & 11 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,22 @@ submodules:

# Set the version of Python and other tools you might need
build:
os: ubuntu-20.04
os: ubuntu-22.04
tools:
python: "3.9"
python: "3.11"
jobs:
post_create_environment:
- cp -r metadata pypet2bids/pypet2bids/
# install poetry
# https://python-poetry.org/docs/#osx--linux--bashonwindows-install-instructions
- curl -sSL https://install.python-poetry.org | python3 -
# Tell poetry to not use a virtual environment
- $HOME/.local/bin/poetry config virtualenvs.create false
- pip install poetry
- poetry config virtualenvs.create false
# just use poetry to export a requirements.txt as that worked much better than the previous attempts
- cd pypet2bids && $HOME/.local/bin/poetry export --with dev --without-hashes -o requirements.txt
- cd pypet2bids && poetry lock && poetry export --without-hashes --with dev --format=requirements.txt > requirements.txt

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# If using Sphinx, optionally build your docs in additional formats such as PDF
# formats:
# - pdf

# Optionally declare the Python requirements required to build your docs
python:
install:
Expand Down
8 changes: 7 additions & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ authors:
- family-names: "Ganz-Benjaminsen"
given-names: "Melanie"
orcid: "https://orcid.org/0000-0002-9120-8098"
- family-names: "Bilgel"
given-names: "Murat"
orcid: "https://orcid.org/0000-0001-5042-7422"
- family-names: "Eierud"
given-names: "Cyrus"
orcid: "https://orcid.org/0000-0002-9942-676X"
- family-names: "Pernet"
given-names: "Cyril"
orcid: "https://orcid.org/0000-0003-4010-4632"
title: "PET2BIDS"
version: 1.0.0
version: 1.3.20240502
url: "https://github.com/openneuropet/PET2BIDS"
date-released: 2022-10-01
license: MIT
2 changes: 2 additions & 0 deletions JOSS_metadata/persons_info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
0000-0002-9120-8098 Melanie Ganz-Benjaminse Department of Computer Science, University of Copenhagen, Copenhagen, Denmark

0000-0003-4010-4632 Cyril Pernet Neurobiology Research Unit, Rigshospitalet, Copenhagen, Denmark

0000-0001-5042-7422 Murat Bilgel National Institute on Aging Intramural Research Program, Baltimore, MD, USA
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,47 @@ installpackage:

testphantoms:
@scripts/testphantoms

html:
@cd docs && make html

installdependencies:
@cd pypet2bids; \
python -m pip install --upgrade pip; \
pip install poetry; \
poetry install --with dev

collectphantoms:
ifeq (, $(wildcard ./PHANTOMS.zip))
@wget -O PHANTOMS.zip https://openneuropet.s3.amazonaws.com/US-sourced-OpenNeuroPET-Phantoms.zip
else
@echo "PHANTOMS.zip already exists"
endif

decompressphantoms:
@unzip -o PHANTOMS.zip

testecatcli:
@cd pypet2bids; \
poetry run python -m pypet2bids.ecat_cli --help; \
poetry run python -m pypet2bids.ecat_cli ../OpenNeuroPET-Phantoms/sourcedata/SiemensHRRT-JHU/Hoffman.v --dump

testecatread:
@cd pypet2bids; \
export TEST_ECAT_PATH="../OpenNeuroPET-Phantoms/sourcedata/SiemensHRRT-JHU/Hoffman.v"; \
export READ_ECAT_SAVE_AS_MATLAB="$$PWD/tests/ECAT7_multiframe.mat"; \
export NIBABEL_READ_ECAT_SAVE_AS_MATLAB="$$PWD/tests/ECAT7_multiframe.nibabel.mat"; \
poetry run python3 -m tests.test_ecatread

testotherpython:
cd pypet2bids; \
export TEST_DICOM_IMAGE_FOLDER="../OpenNeuroPET-Phantoms/sourcedata/SiemensBiographPETMR-NIMH/AC_TOF"; \
poetry run pytest --ignore=tests/test_write_ecat.py tests/ -vvv

pythongithubworkflow: installdependencies collectphantoms decompressphantoms testecatread testecatcli testotherpython
@echo finished running python tests

black:
@for file in `find pypet2bids/ -name "*.py"`; do \
black $$file; \
done
Loading

0 comments on commit 47b4085

Please sign in to comment.