Thanks for helping improve this codebase. The following overview will help you as guide to contribute.
- Line length: 140 characters
- Formatter: Ruff (Black-compatible, double quotes)
- Target Python: 3.10+ syntax, but the package supports 3.9–3.14
- Naming: Ruff N-rules are largely ignored — mixed-case class/method names are acceptable in this codebase (medical domain conventions)
- Complexity: McCabe max=20; research code legitimately has deep branching
from __future__ import annotationsis used widely for forward references
Ready to contribute?
1) Create an issue on the GitHub repository
git clone https://github.com/<your-username>/TPTBox.git
cd TPTBoxMake a venv (in whatever fashion you like), then:
pip install -e .pre-commit installThis pre-commit hook will automatically fix some linting issues and block your commits so that every commit is clean in terms of formatting
Before pushing, make sure all unit tests and ruff pass. Tests live in unit_tests/ (not TPTBox/tests/). TPTBox/tests/ contains test utilities and sample data (CT/MRI NIfTIs) used by the unit tests. Some test files are very large.
# All tests
pytest unit_tests/
# Single test file
pytest unit_tests/test_nii.py
# Single test function
pytest unit_tests/test_nii.py::test_function_name
# With coverage
coverage run --source=TPTBox -m pytest unit_tests/Linting & Formatting:
# Lint (auto-fix where possible)
ruff check . --fix
# Format
ruff format .
# Both (mirrors pre-commit behavior)
pre-commit run --all-files-
Create a feature branch from
main:git checkout -b my-feature
-
Make your changes and commit with a clear, descriptive message.
-
Push your branch and open a pull request against
main. -
CI runs on all pull requests — ensure all checks are green before requesting review.