A Python package for simulating and analyzing CT image artifacts.
- Simulate various CT artifacts:
- Metal artifacts
- Streaking artifacts
- Ring artifacts
- Motion artifacts
- And more...
- Calculate image quality metrics
- Visualize artifacts and their effects
- Support for both 2D and 3D images
- Clone the repository:
git clone https://github.com/e040/simmetric.git
cd simmetric- Create and activate a virtual environment (recommended):
Windows: Make sure to have python 3.11 installed.
# Using venv (Python 3.11+)
python -m venv .venv
# To specify python version do:
py -3.11 -m venv .venv
# Activate environment
.venv\Scripts\Activate Ubuntu: Use this command to chek if python 3.11 is installed and install it if neccessary to create the virtual environment.
PYVER=3.11 && command -v python$PYVER >/dev/null || (sudo apt update && sudo apt install -y python$PYVER python$PYVER-venv) && python$PYVER -m venv .venv
source .venv/bin/activate # activate environment- Install the package in development mode with required dependencies:
pip install -e .- (Optional) Install additional development dependencies for testing:
pip install -e ".[test]"Note: The [test] dependencies include pytest and pytest-cov for running tests and generating coverage reports. If you plan to run tests, you should install these additional dependencies.
Note: Works best if run on a local machine and not in a remote session due to visualization tools
from simmetric.core.dataset import Dataset
from simmetric.core.transforms import Transforms
# Load an image
image = Dataset("path/to/image.nii.gz").load()
# Create a transformer
transformer = Transforms()
# Apply a transform
transformed_image = transformer.apply_transform('streaking', image, start_slice=50, end_slice=55)
# Visualize the results
transformer.visualize(source_image=image, transformed_image=transformed_image)rotate: Rotate the imageshift: Shift the imageblur: Apply Gaussian blurnoise: Add noisebreathing: Add breathing artifactsring: Add ring artifactscupping: Add cupping artifactsaliasing: Add aliasing artifactstruncation: Add truncation artifactsmotion: Add motion artifactsshading: Add shading artifactsstreaking: Add streaking artifacts
MAE: Mean Absolute ErrorMSE: Mean Squared ErrorNRMSE: Normalized Root Mean Square ErrorPSNR: Peak Signal-to-Noise RatioSSIM: Structural Similarity IndexMS-SSIM: Multi-Scale Structural Similarity IndexFSIM: Feature Similarity IndexGMSD: Gradient Magnitude Similarity DeviationNMI: Normalized Mutual InformationJSD: Jensen-Shannon DivergenceVIF: Visual Information FidelityNCC: Normalized Cross-Correlation
Run all tests:
pytestRun tests with coverage:
pytest --cov=simmetricThe project follows PEP 8 style guidelines. You can check your code style using:
flake8 simmetric testssimmetric/
├── datasets/
├── simmetric/
│ ├── core/
│ │ ├── transforms.py
│ │ ├── metrics.py
│ │ └── dataset.py
│ │ └── metalartifact_generation.py
│ ├── utils/
│ │ └── config.py
│ └── visualization/
├── tests/
│ ├── test_transforms.py
│ ├── test_metrics.py
│ └── test_dataset.py
├── examples/
│ └── artifact_generation.py
│ └── metric_visualization.py
├── .gitignore
├── .gitlab-ci.yml
├── LICENSE
├── pyproject.toml
└── README.md
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the DKFZ license.
If you use this software in your research, please cite:
@software{simmetric2025,
author = {Cassandra Krause and Goran Stanic},
title = {Simmetric: A Python Package for CT Image Artifact Simulation},
year = {2025},
url = {https://git.dkfz.de/e040/e0401ninjas/projects/simmetric}
}