A Medical Visualisation Add-On for Blender
This project is still in development. The code provided here is still being developed and has not been optimised yet
This Blender add-on is intended to be used to create visulisations of radiation therapy treatment plans including DICOM images, plans, structures and dose. This can be used to create high quality figures for presentations or publications.
This package is intended for research or educational purposes only and should not be used for clinical applications. By using this add-on you accept that this software is provided without warranty and the author will not be held liable for any damages caused by the use of this software.
MedBlend utilises the pydicom module and is installed as a dependancy when you enable the add-on in Blender. The add-on also uses the pyopenvdb module which has recently been added to Blender version 3.5. Other Modules:
- numpy
- pydicom
- platipy
- SimpleITK
To download MedBlend, click the following link and select the latest release. https://github.com/drmichaeldouglass/MedBlend/tags
Download the add-on installation file which will be of the form: "medblend_0.0.1.zip", for MedBlend version 0.0.1 for example.
If you have local administrator rights to run Blender then use these instructions otherwise, use the instructions in the next section.
Open Blender 3.5, ensuring to run Blender using administrator privalidges. From the Edit-->Preferences menu. Select "Add-ons". Then press install and find the medblend_0.0.1.zip file in the file explorer.
Once installed, under the Medical category in the 3D viewport, select MedBlend and then select "Install Python Modules". This will install some additonal python modules to the Blender python installation which are required for MedBlend to function. This process can take up to a few minutes to complete, please be patient. Once complete, you may have to restart Blender for the new DICOM options to appear.
If you don't have administrator rights to your PC, you can use MedBlend by installing the add-on to a portable version of Blender. The portable versions of Blender can be identified by the ".zip" type Blender downloads (shown in the figure below).
Releases of Blender can be downloaded from here: https://www.blender.org/download/
Experimental builds can be downloaded here: https://builder.blender.org/download/daily/
Ensure that the version of Blender that you download is 3.5 or later. Once downloaded, unzip the file and look for the file called Blender.exe. This version of Blender can be run locally without installation or saved to a USB drive.
Blender, by default will try and install add-ons to the directory: C:\Users(username)\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons. If you do not have administrator rights to your PC, you will not be able to install add-ons to this directory. Instead, you will need to manually install the add-on to the portable version of Blender you have just downloaded.
Start by un-zipping the MedBlend add-on (medblend_0.0.1.zip) for example. Once un-zipped, you should have a folder called "medblend" which contains a file called init.py. Copy the folder "medblend" to the directory "D:\Blender3.5\3.5\scripts\addons" so that the directory structure now looks like "D:\Blender3.5\3.5\scripts\addons\medblend\init.py". Your path to Blender 3.5 might look different, so change accordingly.
Load up Blender 3.5 portable by running blender.exe. When you select Edit-->Preferences and Add-Ons, you should find that MedBlend is already installed.
Once installed, under the Medical category in the 3D viewport, select MedBlend and then select "Install Dependancies". This will install some additonal python modules to the Blender python installation which are required for MedBlend to function. This process can take up to a few minutes to complete, please be patient.
Installing the python modules should download a module named "pydicom" to the following location "D:\Blender3.5\3.5\python\lib\site-packages". If pydicom is not in this location, MedBlend will not function correctly.
Once installed, open the 3D viewport and select the Medical category from the sidebar. Press N on the keyboard if it is not visible.
MedBlend currently has 4 main functions: Load DICOM images, Load DICOM Dose, Load DICOM structures and Load Proton Plan. Each of these functions imports a specific DICOM medical file.
-Load DICOM Images, will allow you to load a DICOM image sequence from a specified folder. When you press the load images button, a file dialog will appear. Select a single DICOM image from this folder. MedBlend will search through the same directory and load all DICOM images with the same study ID into Blender automatically. These image slices will be imported and converted to a volume object which can be rendered in Blender.
-Load DICOM Dose will allow you to import radiation therapy DICOM Dose Files from a treatment planning system and display the dose distribution as a volume in Blender.
-Load DICOM structures will import a DICOM structure file from a radiation therapy treatment planning system and import each structure as a separate point cloud.
-Load Proton Plan will import a DICOM RT Ion proton therapy plan file and extract the proton spot positions and weights and display them as spheres with a radius proportional to the relative spot weight.
Some default materials for CT, MRI and Dose volumes have been included in this add-on. When a DICOM image or DICOM dose volume is imported, a default material is automatically created. Select the materials menu from the menu on the right side, and select either Image Material for CT volumes or Dose Material for dose volumes.
With the CT or dose object selected in the outliner (top right), go to the shader/material menu (red icon in lower right) and select either the Image Material or Dose Material depending on what type of volume you have imported.
To change the material properties, select the Shading tab from the top edge and you should see the Material node setup shown in the bottom panel. MedBlend works with both the Eevee and Cycles render engines but Cycles generally produces better results without too many changes. You can change from Eevee to Cycles from the panel on the right. From the material nodes (shown in panel at the bottom), the brightness of the volume can be changed by increasing the "multiply" value. The pixel threshold can be adjusted by moving the slider points in the colour ramp node.
Generally, DICOM CT is not normalised and pixel values (Hounsfield units) can range from -1000 to > 2000 usually. A value of -10000 generally indicates air density, a value of 0 indicates water density and bone and other high density materials have values >1000. To account for this in the shader material, it may be necessary to add a Map Range node after the volume info node and setting the maximum and miniumum input values to suit your specific dataset.
Rather than viewing the DICOM data as a volume, it is possible to convert the CT data into a mesh. This can be performed by apply the volume to mesh modifier in Blender.
Start by creating a place-holder object. From the add menu, add a cube into the scene. This cube object will hold the volume to mesh modifier.
With the cube selected, go to the modifer menu, select Add Modifier and add a Volume to Mesh modifier.
From the object property, select the CT volume. Depending on the normalisation of the volume, you will need to adjust the threshold to visulise the data. For most CT data, a threshold value of 100 is a good starting point
This is what the mesh should look like with a threshold set to 100. You can apply this modifier from the Volume to Mesh modifier panel to bake the mesh which will allow for manual adjustments.
Here are some examples:
A CT scan, structures and dose volumes imported and overlayed.
DICOM structures for a test prostate radiotherapy plan showing organs at risk such as prostate, urethra, bladder, rectum and the external structure.
A test proton therapy plan on a phantom. The CT images, dose distribution and proton spots are shown.
- Not tested on MRI, SPECT, PET or other imaging modalities.
- CT, Dose and Structure locations are not perfectly co-registered yet (user may need to manually align them at the moment).
- After installing the python modules, the DICOM functions sometimes do not appear. This can be fixed by restarting Blender.
Please report any bugs as an issue on this repository
Import radaition therapy DICOM plan files to visulise MLC or proton spot positions in the patient CT
Visulise brachytherapy dwell point positions and dwell times
MedBlend: A Medical Visualisation Add-On for Blender, M.Douglass https://github.com/drmichaeldouglass/MedBlend
DOI: 10.5281/zenodo.10633327