Primary Author: Kristen Browne
Contact: [email protected]
Released: July 19th, 2024
License: Public Domain
A collection of Python scripts presented at the Association of Medical Illustrators Conference 2024, demonstrating how Python can be used to automate certain tasks in medical visualization. These scripts culminate in dicom2glb.py
, which processes nrrd files through Total Segmentator for segmentation, converts segmentations into VTK meshes, exports them as STLs, and finally imports them into Blender. Here, materials are assigned, objects grouped and centered, and the result is exported as a single GLB file per nrrd file.
These scripts were developed for illustrative purposes and have not been extensively tested. They work well on the limited test cases done to develop the presentation.
- Blender: Must be installed and accessible for script execution.
- Python: Required for running the scripts using Blender's Python API.
- bpy module: Installable as a Python module for script execution outside Blender (bpy on PyPI, Blender as bpy).
dicom2glb.py
converts DICOM files to GLB format for detailed 3D rendering and visualization, targeting professionals in medical imaging and 3D visualization.
- Material Creation: Defines materials for different anatomical structures.
- Segmentation: Employs advanced techniques for precise 3D representations.
- NIfTI to STL Conversion: Essential for 3D modeling and printing.
- Mesh Processing: Prepares meshes for 3D printing or digital rendering.
- Scene Management: Manages Blender scenes for ready-to-use 3D models.
- Blender: For 3D modeling and scene management.
- VTK: For medical imaging data processing.
- TotalSegmentator: For segmentation of anatomical structures.
Execute within Blender, using Blender's Python API and VTK for image processing. Requires specifying input and output directories.
Scripts contributing to the development of dicom2glb.py
:
Converts STL files to GLB format in batch using Blender, organizing output by subdirectories.
Automates DICOM to GLB conversion for 3D visualization, creating custom materials and processing STL files in subdirectories.
Converts between GLB, FBX, and DAE formats in batch, excluding the original format, facilitating cross-format 3D model conversion.
Converts NIfTI files (.nii or .nii.gz) to 3D printable STL files, utilizing VTK for processing and Blender for mesh repair.
Segments medical images using TotalSegmentator, processing all NIfTI files in an input directory and saving segmented images.