Skip to content

Commit 050ca83

Browse files
authored
Merge pull request #1 from aylward/transfer
ENH: Initial commit to transfer files
2 parents b9553b4 + 653aa5e commit 050ca83

134 files changed

Lines changed: 32237 additions & 0 deletions

File tree

Some content is hidden

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

.flake8

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[flake8]
2+
max-line-length = 88
3+
extend-ignore = E203, E501, W503
4+
exclude =
5+
.git,
6+
__pycache__,
7+
build,
8+
dist,
9+
.eggs,
10+
*.egg-info,
11+
.venv,
12+
venv,
13+
.mypy_cache,
14+
.pytest_cache
15+
per-file-ignores =
16+
__init__.py:F401

.github/workflows/docs.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
build-docs:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.11'
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install uv
28+
uv pip install --system torch torchvision --index-url https://download.pytorch.org/whl/cpu
29+
uv pip install --system -e ".[docs]"
30+
31+
- name: Build documentation
32+
run: |
33+
cd docs
34+
make html
35+
36+
- name: Check for warnings
37+
run: |
38+
cd docs
39+
make html SPHINXOPTS="-W --keep-going"
40+
41+
- name: Upload documentation artifacts
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: documentation
45+
path: docs/_build/html/
46+
47+
- name: Deploy to GitHub Pages (main branch only)
48+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
49+
uses: peaceiris/actions-gh-pages@v3
50+
with:
51+
github_token: ${{ secrets.GITHUB_TOKEN }}
52+
publish_dir: ./docs/_build/html
53+
cname: physiomotion4d.readthedocs.io # Optional: if using custom domain
54+

.github/workflows/tests.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Tests
2+
3+
# Test organization:
4+
# - Unit tests: Run on all PRs and pushes, no external data required
5+
# - Integration tests with data: Run on PRs, download and cache test data
6+
# - GPU tests (segmentation): Excluded from CI (requires CUDA), run locally
7+
#
8+
# Test markers:
9+
# - requires_data: Tests that need external data downloads
10+
# - slow: Tests that are computationally intensive or require GPU
11+
12+
on:
13+
pull_request:
14+
branches: [ main ]
15+
push:
16+
branches: [ main ]
17+
18+
jobs:
19+
test:
20+
runs-on: ${{ matrix.os }}
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
os: [ubuntu-latest, windows-latest, macos-latest]
25+
python-version: ['3.10', '3.11', '3.12']
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Set up Python ${{ matrix.python-version }}
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
pip install -e .
39+
pip install pytest pytest-cov
40+
41+
- name: Run unit tests (no data required)
42+
run: |
43+
pytest tests/ -v -m "not requires_data and not slow" --cov=src/physiomotion4d --cov-report=xml
44+
45+
- name: Upload coverage to Codecov
46+
uses: codecov/codecov-action@v4
47+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
48+
with:
49+
file: ./coverage.xml
50+
flags: unittests
51+
name: codecov-umbrella
52+
fail_ci_if_error: false
53+
54+
test-with-data:
55+
runs-on: ubuntu-latest
56+
if: github.event_name == 'pull_request'
57+
58+
steps:
59+
- uses: actions/checkout@v4
60+
61+
- name: Set up Python 3.10
62+
uses: actions/setup-python@v5
63+
with:
64+
python-version: '3.10'
65+
66+
- name: Install dependencies
67+
run: |
68+
python -m pip install --upgrade pip
69+
pip install -e .
70+
pip install pytest pytest-cov
71+
72+
- name: Cache test data
73+
uses: actions/cache@v4
74+
with:
75+
path: |
76+
tests/data/
77+
tests/results/
78+
key: test-data-${{ hashFiles('tests/test_*.py') }}-v2
79+
restore-keys: |
80+
test-data-
81+
82+
- name: Run data download tests
83+
run: |
84+
pytest tests/test_download_heart_data.py -v --cov=src/physiomotion4d --cov-report=xml
85+
continue-on-error: true
86+
87+
- name: Run data conversion tests
88+
run: |
89+
pytest tests/test_convert_nrrd_4d_to_3d.py -v --cov=src/physiomotion4d --cov-append --cov-report=xml
90+
continue-on-error: true
91+
92+
- name: Run contour tools tests
93+
run: |
94+
pytest tests/test_contour_tools.py -v -m "not slow" --cov=src/physiomotion4d --cov-append --cov-report=xml
95+
continue-on-error: true
96+
97+
- name: Run USD conversion tests
98+
run: |
99+
pytest tests/test_convert_vtk_4d_to_usd_polymesh.py -v -m "not slow" --cov=src/physiomotion4d --cov-append --cov-report=xml
100+
continue-on-error: true
101+
102+
- name: Run existing USD tests
103+
run: |
104+
pytest tests/test_usd_merge.py tests/test_usd_time_preservation.py -v --cov=src/physiomotion4d --cov-append --cov-report=xml
105+
continue-on-error: true
106+
107+
- name: Upload coverage
108+
uses: codecov/codecov-action@v4
109+
with:
110+
file: ./coverage.xml
111+
flags: integration-tests
112+
fail_ci_if_error: false
113+
114+
# Note: Slow and GPU-dependent tests are excluded from CI
115+
# These tests should be run locally:
116+
# - tests/test_register_images_ants.py (slow, computationally intensive)
117+
# - tests/test_register_images_icon.py (requires CUDA for ICON)
118+
# - tests/test_transform_tools.py (depends on slow registration tests)
119+
# - tests/test_segment_chest_total_segmentator.py (requires CUDA for TotalSegmentator)
120+
# - tests/test_segment_chest_vista_3d.py (requires CUDA for VISTA-3D)
121+
#
122+
# To run slow/GPU tests locally:
123+
# pytest tests/ -v -m "slow" # Run all slow tests
124+
# pytest tests/test_register_images_ants.py -v -s
125+
# pytest tests/test_register_images_icon.py -v -s
126+
# pytest tests/test_transform_tools.py -v -s
127+
# pytest tests/test_segment_chest_total_segmentator.py -v -s
128+
# pytest tests/test_segment_chest_vista_3d.py -v -s

.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Project files
2+
.claude
3+
.coverage
4+
coverage.xml
5+
*~
6+
venv*
7+
.venv
8+
build
9+
*.egg-info
10+
*.log
11+
__pycache__
12+
_version.py
13+
htmlcov
14+
15+
# Network weights
16+
network_weights
17+
18+
# Data files
19+
*.gz
20+
*.mha
21+
*.mhd
22+
*.zip
23+
*.nii
24+
*.tfm
25+
*.vtp
26+
*.vtk
27+
*.vtu
28+
*.usd
29+
*.usda
30+
*.usdc
31+
*.nrrd
32+
33+
# Archive and Output Directories
34+
archive
35+
old
36+
output
37+
save
38+
results*
39+
40+
# Test data and outputs
41+
tests/data/
42+
tests/results/
43+
tests/baseline_staging/
44+
test_output.txt

.pre-commit-config.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Example pre-commit configuration for PhysioMotion4D
2+
# Copy to .pre-commit-config.yaml to enable pre-commit hooks
3+
4+
repos:
5+
# Code formatting
6+
- repo: https://github.com/psf/black
7+
rev: 24.1.1
8+
hooks:
9+
- id: black
10+
args: [--line-length=88]
11+
12+
# Import sorting
13+
- repo: https://github.com/pycqa/isort
14+
rev: 5.13.2
15+
hooks:
16+
- id: isort
17+
args: [--profile=black, --line-length=88]
18+
19+
# Linting
20+
- repo: https://github.com/pycqa/flake8
21+
rev: 7.0.0
22+
hooks:
23+
- id: flake8
24+
args: [--max-line-length=88]
25+
26+
# Local tests
27+
- repo: local
28+
hooks:
29+
- id: test-heart-ct-cli
30+
name: Test Heart CT CLI Pipeline
31+
entry: pytest tests/test_process_heart_gated_ct_cli.py -v
32+
language: system
33+
pass_filenames: false
34+
always_run: false
35+
files: ^(src/physiomotion4d/|cli/process_heart_gated_ct.py)
36+
stages: [pre-commit]
37+
38+
- id: fast-unit-tests
39+
name: Run Fast Unit Tests
40+
entry: pytest tests/ -m "not slow" -v
41+
language: system
42+
pass_filenames: false
43+
always_run: false
44+
files: ^(src/physiomotion4d/|tests/)
45+
stages: [pre-push]

.readthedocs.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Read the Docs configuration file for PhysioMotion4D
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
version: 2
5+
6+
# Build documentation in the docs/ directory with Sphinx
7+
build:
8+
os: ubuntu-22.04
9+
tools:
10+
python: "3.11"
11+
jobs:
12+
post_create_environment:
13+
# Install uv for faster dependency installation
14+
- pip install uv
15+
post_install:
16+
# Install torch with CUDA support (CPU version for docs build)
17+
- uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
18+
19+
# Sphinx configuration
20+
sphinx:
21+
builder: html
22+
configuration: docs/conf.py
23+
fail_on_warning: false
24+
25+
# Python configuration
26+
python:
27+
install:
28+
- method: pip
29+
path: .
30+
extra_requirements:
31+
- docs
32+
33+
# Formats to build (PDF, ePub, HTML)
34+
formats:
35+
- pdf
36+
- epub
37+

.vscode/settings.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
// Python formatting
3+
"python.formatting.provider": "black",
4+
"python.formatting.blackArgs": [
5+
"--line-length=88"
6+
],
7+
// Editor settings
8+
"editor.rulers": [
9+
88
10+
],
11+
"editor.wordWrapColumn": 88,
12+
// Python linting
13+
"python.linting.enabled": true,
14+
"python.linting.flake8Enabled": true,
15+
"python.linting.flake8Args": [
16+
"--max-line-length=88"
17+
],
18+
"python.linting.pylintEnabled": true,
19+
"python.linting.pylintArgs": [
20+
"--max-line-length=88"
21+
],
22+
// Format on save
23+
"editor.formatOnSave": true,
24+
"editor.formatOnPaste": false,
25+
// Python-specific editor settings
26+
"[python]": {
27+
"editor.rulers": [
28+
88
29+
],
30+
"editor.tabSize": 4,
31+
"editor.insertSpaces": true,
32+
"editor.formatOnSave": true,
33+
"editor.codeActionsOnSave": {
34+
"source.organizeImports": "explicit"
35+
}
36+
},
37+
// isort settings
38+
"isort.args": [
39+
"--profile",
40+
"black",
41+
"--line-length",
42+
"88"
43+
],
44+
// Pylance diagnostic settings for Jupyter notebooks
45+
"python.analysis.diagnosticSeverityOverrides": {
46+
"reportUndefinedVariable": "warning",
47+
"reportMissingImports": "warning"
48+
},
49+
"jupyter.pylanceHandlesNotebooks": true,
50+
"python.analysis.typeCheckingMode": "basic",
51+
"ruff.configuration": ""
52+
}

0 commit comments

Comments
 (0)