Thank you for your interest in contributing to mri-toolkit! We welcome contributions from the community, whether it's reporting bugs, suggesting features, or submitting code changes.
This document outlines the guidelines for contributing to ensure a smooth process for everyone involved.
If you encounter a bug or have a feature request, please use the GitHub Issues tracker.
- Bugs: Please provide a detailed description of the issue, including the steps to reproduce it, the expected behavior, and the actual behavior.
- Feature Requests: Describe the feature you would like to see and why it would be useful.
To start contributing, you'll need to set up a local development environment. mri-toolkit supports Python versions 3.10 and above.
-
Fork and Clone the Repository:
git clone [https://github.com/](https://github.com/)<your-username>/mri-toolkit.git cd mri-toolkit
-
Create a Virtual Environment: It is recommended to use a virtual environment to manage dependencies.
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies: Install the package in editable mode along with the test dependencies.
pip install -e ".[test]" -
Install Pre-commit Hooks: We use pre-commit to ensure code quality before commits are made.
pip install pre-commit pre-commit install
We strictly enforce code style and quality standards to maintain a clean codebase. Our CI pipeline will fail if these checks are not met.
- Linter & Formatter: We use Ruff for both linting and formatting. It is configured in
pyproject.tomlto enforce specific rules (e.g., line length of 100). - Type Checking: We use Mypy for static type checking.
- Pre-commit Hooks: The following checks are run automatically on every commit via
pre-commit:- Trailing whitespace removal
- End-of-file fixing
- YAML and TOML syntax checks
- Ruff (linting and formatting)
- Mypy (type checking)
To run these checks manually on all files:
pre-commit run --all-filesNote that these hooks will run automatically on the staged files when you commit, so you don't need to run them manually every time.
- Create a New Branch:
git checkout -b feature/your-feature-name
- Make Your Changes: Implement your changes and ensure that they adhere to the code style guidelines.
- Run Tests: Make sure all tests pass before submitting your pull request.
pytest
- Commit Your Changes:
git add . git commit -m "Add a descriptive commit message"
- Push Your Branch:
git push origin feature/your-feature-name
- Create a Pull Request: Go to the original repository on GitHub and create a pull request from your branch. Provide a clear description of the changes you made and any relevant information.
We use pytest for testing. Before submitting a PR, ensure all tests pass locally.
-
Download Test Data: Some tests require specific data. You can download this using the CLI included in the toolkit.
# Downloads data to the 'test_data' folder (or your preferred location) python -m mritk datasets download test-data -o test_dataNote: You may need to set the
MRITK_TEST_DATA_FOLDERenvironment variable if you download the data to a custom location. -
Run the Test Suite:
python -m pytest
To generate a coverage report:
python -m pytest --cov=mritk --cov-report html --cov-report term-missing
- Create a Branch: Create a new branch for your feature or bug fix.
git checkout -b feature/my-new-feature
- Make Changes: Implement your changes. Ensure you write tests for new features or bug fixes.
- Commit Changes: Commit your changes with a descriptive message. The
pre-commithooks will run automatically to fix style issues. - Push: Push your branch to your fork.
git push origin feature/my-new-feature
- Open a PR: Go to the original repository and open a Pull Request.
- The CI pipeline (GitHub Actions) will automatically run tests on Ubuntu, Windows, and macOS across Python versions 3.10–3.14.
- Ensure all checks pass.
By contributing to mri-toolkit, you agree that your contributions will be licensed under the MIT License.