This repository contains the codes and examples for generating 3D renderings using Napari, a fast, interactive, multi-dimensional image viewer for Python. While Napari is a powerful tool, there is a lack of comprehensive tutorials that provide a systematic approach for visualizing 3D data and creating videos, particularly for scientific papers. This repository aims to fill that gap.
Note: This repository is also used to generate 3D visualizations in the Analytic Fourier Ptychotomography (AFP) paper. Paper link, Project page.
Top-level folder structure:
├── Data # Data used for 3D visualiztion
├── utils.py # Subfunctions
├── Volumerendering_Embryo.ipynb # A demo jupyter notebook code
└── README.md # Documentation (this file)-
This code is designed for 3D rendering in Napari and provides several key functionalities:
-
Add multiple 3D objects with Maximum Intensity Projection (MIP) rendering or other renderings.
-
Customize colormaps for different channels.
-
Add 3D bounding boxes to the volume.
-
Edit axes and the scale bar.
-
Adjust viewing angles and zoom levels.
-
Overlay cross-sectional boxes onto the 3D visualization.
-
Save screenshots of static views.
-
Generate 3D rendering videos for dynamic presentations.
-
-
A demo code is provided in jupyter notebook:
Volumerendering_Embryo.ipynb
-
Follow the installation instructions and then install a few additional required libraries and napari plugins (napari-bbox, napari-animation). For example:
conda create -y -n napari-env -c conda-forge python=3.10 conda activate napari-env pip install "napari[all]" pip install h5py os numpy jupyter matplotlib pip install napari-bbox pip install napari-animation
-
Note: After installing the
napari_bboxplugin, open the fileqt_bounding_box_control.pyin the installation folder, and comment out the lines that import or use theQSlidermodule.
Please download the example data and put them in the 'Data' folder. The data are stored as .h5 file in Data/Reconstruction folder in Data link.
- Fixed mouse embryo (Eight cell stage)
Embryo_Eightcell_demo.mp4
- Fixed mouse embryo (Blasto stage)
Embryo_Blasto_demo.mp4
- 3D Pathology slide
Pathology_demo.mp4
This code is written and maintained by Zhenyu Dong. For any questions or comments about this code, please contact zdong@caltech.edu.
If the code was helpful to your work, please consider citing it (BibTeX):
@software{Dong_napari-3Drendering,
author = {Dong, Zhenyu},
title = {{napari-3Drendering}},
url = {https://github.com/MrDongZhenyu/napari-3Drendering}
}