This Python example overlays a medical-image slice with a transparent label map derived from tissue probability maps in NIfTI files. The example assumes isotropic voxel spacing and extracts slices from the ICBM 152 2009a Nonlinear Symmetric template.
This repository demonstrates how to:
- load 3D medical images in NIfTI format
- extract and orient corresponding 2D subarrays
- convert tissue probabilities into a discrete label map
- explicitly define an RGBA color overlay
- save a PNG image overlaid with a transparent label map
The goal is to export square images as an intermediate data representation for more complex example figures.
Install dependencies:
pip install matplotlib nibabel numpyRun the example:
python recipe.pyThis downloads the template and generates a square image overlaid with gray- and white-matter labels (overlay.png).