Parametric CAD models for medical imaging phantoms using build123d.
- NEMA IEC Body Phantom (
nema_wagi.py) - IEC 61675-1 standard body phantom with:- Hollow spheres (10-37mm) with filling tubing
- Lung insert
- Mounting plate with screws
- Material assignments via pymat
- Python 3.12+
- uv package manager
- VS Code with OCP CAD Viewer extension
git clone https://github.com/MorePET/cad-phantoms.git
cd cad-phantoms
uv sync- Open the project in VS Code
- Press
Cmd+Shift+P(Mac) orCtrl+Shift+P(Windows/Linux) - Type "Python: Select Interpreter"
- Choose the
.venvinterpreter from this project (e.g.,./.venv/bin/python)
- Press
Cmd+Shift+P/Ctrl+Shift+P - Type "OCP CAD Viewer: Open Viewer"
- A viewer panel will open (usually on the right side)
- Open
nema_wagi.py - Run the first cell (
#%%) - this imports the libraries- VS Code will start a Jupyter kernel
- Check the terminal for the viewer port (e.g., "Using port 3939")
- Run subsequent cells to build the geometry
- Each
show()call updates the 3D viewer
- Run cells individually: Click the "Run Cell" button or use
Shift+Enter - Viewer not updating?: Check the terminal for connection messages
- Clipping planes: Use
clip_slider_0/1/2parameters inshow()to cut through the model - Colors: Set
clip_object_colors=Trueto see material colors in cross-sections
cad-phantoms/
├── nema_wagi.py # NEMA IEC Body Phantom model
├── pyproject.toml # Project dependencies
├── uv.lock # Locked dependencies
└── *.step # Exported CAD files (optional)
build123d- Parametric CAD modelingocp-vscode- VS Code viewer integrationpymat- Material library for CAD applications
MIT
