Giter VIP home page Giter VIP logo

medblend's Introduction

MedBlend Github

MedBlend

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

GitHub all releases GitHub Repo stars GitHub User's stars

Introduction

Intended Use

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.

Disclaimer

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.

Requirements

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

Installation

Download MedBlend

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.

Install MedBlend (If you have administrator rights to your PC)

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.

Install_1 add_on_install

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.

install_python

Install MedBlend (If you don't have administrator rights to your PC)

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/

blender_portable

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.

add_on_install

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.

install_python

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.

How to use MedBlend

Once installed, open the 3D viewport and select the Medical category from the sidebar. Press N on the keyboard if it is not visible.

medBlendFunctions

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.

How to add Materials to the CT and dose volumes

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.

materials

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.

materials3

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.

MapRange

Converting CT volumes into a mesh

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.

add_cube

With the cube selected, go to the modifer menu, select Add Modifier and add a Volume to Mesh modifier. volume_to_mesh

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

volume_to_mesh_select_CT

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.

CT_Mesh

Here are some examples:

A CT scan, structures and dose volumes imported and overlayed.

Dose

DICOM structures for a test prostate radiotherapy plan showing organs at risk such as prostate, urethra, bladder, rectum and the external structure.

Structure

A test proton therapy plan on a phantom. The CT images, dose distribution and proton spots are shown.

Proton

Known Issues

  • 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

Future Updates

Import Radaition Therapy Plan Files

Import radaition therapy DICOM plan files to visulise MLC or proton spot positions in the patient CT

Import Brachytherapy Dwell Points

Visulise brachytherapy dwell point positions and dwell times

Treatment simulation with Linac model.

How to Cite

MedBlend: A Medical Visualisation Add-On for Blender, M.Douglass https://github.com/drmichaeldouglass/MedBlend

DOI: 10.5281/zenodo.10633327

References

medblend's People

Contributors

drmichaeldouglass avatar

Stargazers

Philipp Schlegel avatar R. Häcker avatar Joachim Pfefferkorn avatar Samm avatar  avatar  avatar  avatar Rafe McBeth avatar Aditya Panchal avatar dongwiki avatar RANIELE COSTA avatar Young Wang avatar  avatar  avatar Alexandre Gauvin avatar Andrew Helsley avatar IsoAnalytics avatar  avatar ZhouD avatar Andrew Kary avatar Stephanie Platz avatar Sarah Cartwright avatar sewon jeon avatar Jan-Hendrik Müller avatar  avatar  avatar  avatar Paul Mulvaney avatar Anders avatar  avatar  avatar AFP avatar  avatar  avatar Reijaff avatar Dr. Atul Tiwari avatar Thomas Olausson avatar PLRexter avatar  avatar  avatar fre3Darchi avatar joaulo avatar tyoc213 avatar  avatar Kaio Barbosa Gama avatar Tom Sparrow avatar Yusuf Alibrahim avatar Daniel Pett avatar GTS avatar Pedro Martinez avatar Terrie Simmons-Ehrhardt avatar Unat T avatar Billary avatar Phil Chlap avatar Matthew Jennings avatar James Ledger avatar Simon Biggs avatar Brady Johnston avatar

Watchers

Tom Sparrow avatar Lynton Graetz avatar Andrew Kary avatar Brady Johnston avatar  avatar

medblend's Issues

Can't install

I can't seem to get this to install. I have tried with both 3.5 alpha and beta. When I try to install the first version, I get the message that it's installing but it never pops up in my add-ons list. When I try to install the newest version, it shows up but when I check it to enable, I get the following message.
2023-03-10_7-45-57

Sequence support

Hi,

Thank you for the open release!

Is there support for sequence data? 4D?

blender 3.5 medblend 0.0.5 error

Python: Traceback (most recent call last):
File "C:\Users\ekfgo\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\medblend_init_.py", line 614, in execute
dicom_data = pydicom.dcmread(file_name_struct)
File "C:\Users\ekfgo\Downloads\blender-3.5.0-windows-x64\blender-3.5.0-windows-x64\3.5\python\lib\site-packages\pydicom\filereader.py", line 1002, in dcmread
fp = open(fp, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'C:\ct\ms\'

help me

Cannot activate add-on v.1.02 in Blender 4.0.2

After installing the v.1.0.2 Add-on in Blender 4.0.2, I cannot activate it in Blender because it gives me the following error:

  File "/home/algo/software/blender-4.0.2-linux-x64/4.0/scripts/modules/addon_utils.py", line 364, in enable
    mod = importlib.import_module(module_name)
  File "/home/algo/software/blender-4.0.2-linux-x64/4.0/python/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'MedBlend-1'

DICOM to mesh

Is there a way to convert the visualized volume render into a mesh in blender that can be exported?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.