Coder Social home page Coder Social logo

dicom2stl's Introduction

dicom2stl

Binder Python application

Tutorial: Binder

dicom2stl.py is a script that takes a Dicom series and generates a STL surface mesh.

Written by David T. Chen from the National Institute of Allergy & Infectious Diseases (NIAID), [email protected] It is covered by the Apache License, Version 2.0:

http://www.apache.org/licenses/LICENSE-2.0

Getting Started

The script is written in Python and uses 4 external packages, SimpleITK, SimpleITKUtilities, VTK, and pydicom.

The dependencies can be installed using pip:

pip install -r requirements.txt

The options for the main script, dicom2stl.py, can be seen by running it:

python dicom2stl.py --help

How dicom2stl.py works

The script starts by reading in a series of 2-d images or a simple 3-d image. It can read any format supported by ITK. If the input name is a zip file or a directory name, the script expects a single series of DCM images, all with the ".dcm" suffix.

Note: if this script is run with the individual Dicom slices provided on the command line, the slices might not be ordered in the correct order. It is better to provide a zip file or a directory, so ITK can determine the proper slice ordering. Dicom slices are not necessarily ordered the same alphabetically as they are physically. In the case of a zip file or directory, the script loads using the SimpleITK ImageSeriesReader class, which orders the slices by their physical layout, not their alphabetical names.

The primary image processing pipeline is as follows:

The script has built in double threshold values for the 4 different tissue types (bone, skin, muscle, soft). These values assume the input is DICOM with standard CT Hounsfield units. I determined these values experimentally on a few DICOM test sets, so the values might not work as well on other images.

The volume is shrunk to 256 cubed or less for speed and polygon count reasons.

After all the image processing is finished, the volume is converted to a VTK image using sitk2vtk.py.

Then the following VTK pipeline is executed:

The amount of smoothing and mesh reduction can be adjusted via command line options. By default 25 iterations of smoothing is applied and the number of vertices is reduced by 90%.

Examples

To extract the bone from a zip of dicom images:

python dicom2stl.py -t bone -o bone.stl dicom.zip

To extract the skin from a NRRD volume:

python dicom2stl.py -t skin -o skin.stl volume.nrrd

To extract a specific iso-value from a VTK volume:

python dicom2stl.py -i 128 -o iso.stl volume.vtk

To extract soft tissue from a dicom series in directory and apply a 180 degree Y axis rotation:

python dicom2stl.py --enable rotation -t soft_tissue -o soft.stl dicom_dir

The options for the script can be seen by running it:

python dicom2stl.py --help

You can try out an interactive Jupyter notebook via Binder: Binder

dicom2stl's People

Contributors

dave3d avatar pjaol avatar paulin1c avatar

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.