Make: Projects

3D Print Your Medical Scan

Prep CT images to print, using open-source software.

Mike-3d-print-skull

This skull with a broken nose of Make: executive editor Mike Senese was printed by Hawk Ridge Systems using a 3D Systems ProJet 660.

 

For more on 3D printing, check out Make: Volume 42. Don't have this issue? Get it in the Maker Shed.

For more on 3D printing, check out Make: Volume 42.
Don’t have this issue? Get it in the Maker Shed.

3D printing is all around us, opening possibilities for us to do in our garages what traditionally could only be done by large organizations. It’s now possible to 3D-print a model of your own bones, innards, and other anatomical structures starting from a CT scan 3D image, and using only open source software tools. I’ll show you how to do it using a couple of common desktop 3D printers; if you don’t have access to a 3D printer, check out makezine.com/where-to-get-digital-fabrication-tool-access to find a machine or service near you.

The Data Is Yours

So you broke your arm, got send to the emergency room, and while you were there the doctor recommended to acquire a CT scan for good measure. While you wait in the emergency room, it occurs to you that it will be interesting to see a 3D printed model of your broken bone, so you kindly ask the nurse for a copy of the CT Scan.

In the United States, you have the right to this data and the health care provider is required to give it to you within 30 days. They can charge you a reasonable fee for the process of reproduction and mailing.

U.S. laws give patients the right to access their own personal records. More specifically:

The Health Insurance Portability and Accountability Act (HIPAA) Privacy Rule gives you, with few exceptions, the right to inspect, review, and receive a copy of your medical records and billing records that are held by health plans and health care providers covered by the Privacy Rule. If you want a copy, you may need to pay for copies and mailing.

or if you are in the state of New York, the following rules apply.

In the case of a CT scan, you want to ask for the digital data, not printouts in film. This will typically be delivered to you in a DVD containing files that are encoded using the DICOM format.

Image Processing Software

Probably the most commonly used Open Source software applications for processing medical images are OsiriX and 3D Slicer (not to be confused with Slic3r, the G-code generator for 3D printers).

Both of these applications are open source. Both OsiriX and Slicer are built upon the open source toolkits ITK and VTK. However, OsiriX is only available in Mac, while Slicer is available for Windows, Mac, and Linux, which is the reason we’ll focus on it for the rest of this article.

Let’s start by getting Slicer from its download page.

Steps

Advertisement

Step #1: Read the DICOM images

PrevNext
3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan
  • The images of a 3D scan are typically saved as individual slices, using one file per slice. To enable you to reproduce the demonstration in this article, we use a DICOM dataset that's publicly available, from the OsiriX sample images page. We chose the PELVIX dataset, that contains a fractured pelvis and part of the adjacent femur bones.
  • Download the images from the OsiriX page and extract the content of the zip file into a directory.
  • To load the images, launch Slicer and go to the File menu in the top bar, then select DICOM. This opens a new dialog window, exposing the options for loading DICOM images. In this new window, select from the top menu the Import button.

Step #2: Read the DICOM images (cont’d)

PrevNext
3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan
  • Then select the folder where your images are stored and click the Import button on the lower right corner of the dialog. A progress bar will indicate the loading of the images, and a new window will appear, showing the organized content of the input data files.
  • Finally, click the Load Selection into Slider button to load the full set of images into memory. It will be displayed in the 4-quadrant window. Three of the quadrants show the X, Y, and Z slice cuts respectively, while the fourth one shows a 3D view of the dataset.

Step #3: Segment the bones

PrevNext
3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan
  • The process of extracting an anatomical structure from a 3D volumetric image is called “image segmentation”. The 3D Slicer application provides a set of segmentation tools, based on the Insight Toolkit ITK, an open source library for image analysis sponsored by the U.S. National Library of Medicine.
  • Probably the easiest segmentation tool to use in 3D Slicer is the “region growing” segmentation tool. You select "seed points" on the image, and from those seed points the tool connects pixels that have intensity values very similar to the points you chose.
  • Click on the Modules drop-down menu, and select the Segmentation group. You want the Simple Region Growing Segmentation tool.
  • Under the Segmentation Parameters, select Seeds-->Create new MarkupsFiducial. Now select your seed points. (What does MarkupsFiducial mean? The seed points you're selecting as input to the region growing method are provided to Slicer through the “Fiducial” markers interface. Don't worry about it.)

Step #4: Segment the bones (cont'd)

PrevNext
3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan
  • To create a new Volume for saving the results of the segmentation, select IO-->Output Volume-->Create new volume.
  • Finally, execute the segmentation module by clicking on the Apply button.
  • The resulting segmented structure will appear as a label map, in a separate color. You can see it by selecting the 3D View Controllers menu.

Step #5: Generate a surface mesh

PrevNext
3D Print Your Medical Scan
  • Up to this point, the segmentation is still a volumetric image, made of 3D pixels (or voxels). We need now to extract the surface around it, in the form of a mesh composed of points and triangles connecting them.
  • Go back up to the Modules list and select the Model Maker module. Now point to the label volume from which you want to create the surface.
  • Fun fact: The functionalities of visualization and surface extraction in 3D Slicer are provided by the Visualization Toolkit (VTK), and open source C++ library for 3D computer graphics, image processing, and visualization.

Step #6: Save the surface in STL format

PrevNext
3D Print Your Medical Scan
  • You can now save the resulting mesh surface into an STL file, which is what you'll use as input for 3D printing. To save the surface, select File-->Save (or use the Ctrl+S shortcut). This prompts a detailed menu with all the pieces of data that can be saved at this point. You're only concerned with saving the surface, so first unselect all the rows, then select only the row with the filename FemurBone.
  • In the second column, click on the dropdown menu to select the STL file format. Finally, click the Save button on the lower-right corner of this window.
  • NOTE: The third column indicates the directory where the file will be saved. If you wish, you can change that directory by clicking on it, before saving the file.

Step #7: Inspect your mesh

PrevNext
3D Print Your Medical Scan

As a way of inspecting the quality of the resulting surface mesh, load the same STL file into Meshlab (also open source) to make sure that the mesh is properly constructed.

Step #8: Refining

PrevNext
3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan
  • Image segmentation is a mixture of art, science, and a bit of black magic (read “parameter tuning”). Our segmentation process was not perfect, since we obviously didn’t get the full femur bone, nor the hip bone.
  • To correct this, go back to the Region Growing module and increase the Multiplier parameter. This number tells the software to accept into the new region those pixels whose intensity values are within a range of x standard deviations away from the intensity values of your seed points, where x is that multiplier factor. The larger this multiplier is, the bigger will be the extracted region, since it will include pixels that have lesser similarity with the seed points.
  • By using a Multiplier value of 3.0 we get the second image here. Much better.
  • Here's why: Bones are magnificent mechanical structures. They continuously remodels themselves in order to provide support in the specific locations where mechanical stress is being applied. This is elegantly done by cells that are sensitive to mechanical pressure, and that are also involved in the process of producing the calcium crystals that give rigidity to the bone. Curiously, we can think of bone as a biological structure that is continuously 3D-printing itself from the inside. Because this adaptability, bone structures have different levels of calcification in different locations, and correspondingly, they appear brighter or darker in the CT images.
  • When we increase our multiplier factor, what we are doing is accepting regions of the bone that are less and less calcified.
  • With a 3.5 multiplier value, we get the entire femur attached to the pelvis.
  • You can get a better view of the model by using the 3D Only view mode, as seen in the third image here.

Step #9:

PrevNext
3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan
  • This time we save that file as FemurBoneAndHip.stl and we import it into Meshlab for verification.
  • Note that the hip here is fractured; that is, after all, the reason why we got to the emergency room in the first place. The rupture is not an artifact of the segmentation, but the actual state of the bone in the dataset.

Step #10: Post-processing

PrevNext
3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan
  • Now that you have the STL model of the structure, we'll clean it up in ParaView, an open-source, multi-platform data analysis and visualization application that's also based on VTK.
  • Load the STL file by selecting File-->Open, and then clicking on the Apply button. ParaView won't apply operations until you click Apply. This is intended to prevent long waits when dealing with very large datasets, and reflect the fact that ParaView is very commonly used in computer clusters and supercomputer applications, typically to inspect the output of large-scale simulations.
  • When extracting surfaces from 3D images, the resulting meshes tend to have a very large number of triangles. It's usually a good idea to decimate the surface to replace many of these triangles with larger ones, while still preserving the general shape of the object.
  • In ParaView, select the Decimate filter and set your Target Reduction to 0.5. The software will attempt to reduce the number of triangles by 50%.
  • Now that you have a less dense mesh, it's time to rotate your 3D model to put it in a more convenient position on the 3D printer bed. Typically, it's useful to lay the model as flat as possible on the bed surface. This cannot be done perfectly with a bone structure, but we can still make the job of the 3D printer a bit easier by rotating the structure.
  • To perform this transformation, select the Transform filter in ParaView, and put the bone "on its side" to make it lie better on the printer bed. You also need to apply a scale factor, to produce a smaller model for the printer. Remember that your 3D model comes from a real CT scan dataset and therefore is has the typical size of a human pelvis — which is a bit too large for the volume of the 3D printer, and certainly too big for a first printing test.
  • Finally, save the new, decimated, rotated, and scaled surface into a new file, by selecting File-->Save Data, providing a filename, and selecting the STL file format.

Step #11: Printing — with Printrbot Simple

PrevNext
3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan
  • You can now take this STL file and load it in RepetierHost, proceed to slice it with Slic3r to generate G-code, and give it a try at printing it.
  • At this point, we are fully in 3D printing territory, where selections such as supports, “rafts,” and infill will be critical for properly printing the model. To print the bones on our Printrbot Simple, we enabled both supports and raft, in order to provide a base to hold the pieces of the fractured pelvis along with the top part of the femur bone.
  • After about 1 hour of printing, you can see the result of the model with 0.3mm layers in PLA plastic (second image here) and after removing the supports we get our bone model (third image).

Step #12: Printing — with Makerbot Replicator 2X

PrevNext
3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan
  • We loaded the same STL file into MakerWare, to print it with the Makerbot Replicator 2X. Again, enable supports and a raft.
  • Here's the resulting model, printed in natural-color ABS. Note that one of the supports broke off during the printing process due to the raft lifting a bit from the printer bed.
  • After we remove the supports and the raft, we get the final model (third image).

Step #13: Share your data

PrevNext
3D Print Your Medical Scan3D Print Your Medical Scan3D Print Your Medical Scan
  • And since you've made it this far, why not share your data? DICOM images can be publicly shared in the MIDAS platform, along with the segmentations and the STL files containing the mesh surfaces.
  • Here's the shared folder with the STL files resulting from our image segmentation and post-processing.
  • I hope you enjoy replicating this process with your favorite medical datasets and your favorite 3D printer!
Luis Ibáñez

Luis Ibáñez

Luis Ibáñez (luis.ibanez[at]gmail[dot]com) is a software engineer at Google and previously worked on an open-source platform for medical image analysis at Kitware.


  • satrajit

    hi luis – do you know what the laws are for biomedical research data? do they fall in the same category as personal medical data.

    • Satrajit,

      Are you referring to animal research data ? or to microscopy data from human subjects ?

      Maybe data acquired from human subjects under informed consent for research purposes ?

  • Mike

    Hey Luis. Great article. I have actually been trying everywhere to find a 3D sonogram provider that is willing to give me the digital data and everyone I spoke with said they can only provide me pictures. Any chance do you know if this law applies to 3D sonograms as well? Or even a route I could take to obtain the digital data? I’m having twins and I would really like to print them out before they are born. (A little creepy, I agree).

    • I had similar difficulty getting a sonogram technician to give me the DICOM data. Spent a while hunting for one that would, and then the baby came and it’s become less pressing. I’d still love to get those files though…

    • Mike,

      The regulations certainly apply to Ultrasound the same way that they do to CT and MRI images, so the challenge here is not a legal one.

      The difficulty might be that the equipment (and its software) mat not be well set for exporting DICOM data. It is certainly possible, but it may take a collaborative clinician and technician to go over the hurdles of the software.

      As opposed to CT and MRI, where the image is acquired by a technician, and the analysis is down downstream by a radiologist, hence requiring images to be exported and moved through the network; in ultrasound, as you may have see, the image evaluation is done by the clinician, right away in front of the patient. Therefore, they are less accustomed to images in digital format.

      Beware also, that ultrasound data tends to be very noisy, and some pre-processing may be required before going for a segmentation. A good 3D image filter to apply in this case is the Median filter (it is a simple but very effective one).

      Here are some publicly shared ultrasound datasets
      http://midas3.kitware.com/midas/search/index?q=ultrasound

      used for segmenting blood vessels.

    • Mark Cicero

      Hi Mike,

      Check out this site: inveevobaby.com. They create 3D prints from 3D ultrasound scans. You don’t need the 3D data either, just an image. Good luck!

  • Kathleen Moriarty

    Hi Luis- I am having trouble with selecting the seeds for the segmenting step. How can I tell which seed points I am selecting?
    Thank you !

    • Kathleen Moriarty

      OK now I am using the little red circle with an upwards arrow(top toolbar) to place fiducial points, is this how you did it, and if so, about how many seeds to you recommend placing ? Thanks!

      • Kathleen,

        Thanks for sharing your progress.

        I would use at least ten seed points. In principle, one can get lucky by using less, but, for complex shapes, it is safer to go for placing a good number of seed points (20 is a reasonable value).

        The counterpoint here is that a single poorly placed seed point can derail the segmentation, specially if it goes into a region with a very different intensity level.

        I have found convenient to add one seed point at a time, and run the segmentation before adding more seed points. It is laborious, but it is also a safer way to get a clean result. In this way, one can get to 20 or more seed points, but having good confidence on each one of them.

        Note also that you can place fiducials (seed points) by placing the cursor on top of the slices and pressing the “p” key. I found this useful, because, even being very careful, the effort of clicking in the mouse, tends to move the mouse position a little bit.

        Please share if you run into any difficulties.

  • As with others, I’m having problems selecting seeds. I have a CT scan of my head and I’ve placed multiple points but the little red circle with the arrow but when I create a volume and then apply, I don’t get a 3D model in the 3D viewing quadrant.

    • Al,

      Yes, placing the seed points is probably the trickiest part of the process.

      The following tutorial may be helpful here:
      http://www.slicer.org/slicerWiki/images/1/1f/DiffusionMRIanalysis_Tutorial_SoniaPujol_2013.pdf

      Search for the section “Fiducial Seeding”. It shows a bit more detail on how to set the seed points (also known as Fiducial Marks).

      Note that, it might be that your seed points are in the correct location, and it is the Region Growing Segmentation what needs more parameter tuning. One way to know, is to go for a very large multiplier factor (something like 10 or 20). With such a large multiplier, a region should be created (a very large and deformed one, but certainly a visible one).

      It may also be helpful to practice first with the same data set that we used in this article. You can get this PELVIS dataset from: http://www.osirix-viewer.com/datasets/DATA/PELVIX.zip

      Please share with us any progress or difficulties (either way).

      Thanks

  • mark_reh

    An excellent tutorial, especially the post-processing stuff! I did this stuff a year ago (http://mark.rehorst.com/ct_scan/index.html and http://www.thingiverse.com/thing:203856using DeVide, ) with another freebie from google code (https://code.google.com/p/devide/wiki/Downloads). There is a video tutorial on how to extract bones here: https://www.youtube.com/watch?v=_PtTpRz3aU8
    I had the file in and out of Meshlab and Blender several times to get a printable stl. It was a PITA!

    • Mark,

      Thanks for pointing out to DeVIDE [https://code.google.com/p/devide/]. This is yet another application built on top of ITK [http://www.itk.org] for image processing and VTK [http://www.vtk.org] for 3D visualization. Definitely a good option for the Image Segmentation work.

  • mark_reh

    One of the problems with all this is getting CT/MRI scan data. It’s fine if you have data of your own scans, but what if you want a skull or other part that you haven’t had scanned? The data is protected by HIPAA so it isn’t readily available anywhere that I’ve been able to find. I posted my own CT scan dicom multifile data on my web site (http://mark.rehorst.com/ct_scan/Rehorst,%20Mark%208_31_2007.xstd.zip) and I uploaded it to Thingiverse (http://www.thingiverse.com/thing:203856/#files), but what is really needed is a single place to put such scans where they can be indexed and publicly accessed and of course, more people who are willing to share their scans.

    When a CT/MRI scan is done it is typically high resolution but the radiology tech will often reduce the size of the data set by reducing the resolution/cropping/deleting layers so the data you get long after the scan was done is often disappointing. What you really need to do is hand the radiology tech a blank DVD disk and ask them to put the scan on the disk for you at the time the scan is done so you get all the data.

    You can get some data to play with here: http://www.osirix-viewer.com/datasets/

    • Mark,

      Thanks for sharing your CT scan data. You bring up several good points. It is indeed important to let the radiology tech know that you are interested in getting the full resolution dataset, and not a sub-sampled version of it. It may indeed be helpful to mention that you intend to 3D print the data set.

      Also, as you pointed out, a person has the right to obtain her/his own medical data, and distribute it; while medical personnel are strongly forbidden from doing the same (via the HIPAA regulations). This is actually a great challenge for performing medical research, since data is so hard to obtain.

      A good place to share (and find) medical data online, is described in Step 13 “Sharing Data” of the article. In particular, it points to the MIDAS platform: http://midas3.kitware.com/midas/

      Here is the folder where the datasets used in this article were shared: http://midas3.kitware.com/midas/folder/11333

      There is a need for growing a community of people willing to share their medical data. Ideally, it should evolved into something similar to what “Patient Like Me” [http://www.patientslikeme.com/] is doing.

  • Great story Luis. In the event that your readers are interested, embodi3D.com is a website dedicated to promoting 3D printing of medical scans. There are a variety of resources to help people with 3D printing including a library of 3D printable models created from medical scans that can be downloaded for free. If you are interested you can even share your 3D printable model with others. Here is an example of a human heart model created from a CT scan that was recently made available.

    http://youtu.be/g39bcyDpg4s

    3D printing of medical scans is an amazing advance, and I hope more people will take an interest in learning how to do it.

    • Thanks for sharing the links to Embodi3D. This is very interesting, specially the File Vault [http://www.embodi3d.com/files/] for data sharing.

  • Hi Luis, you will be hearing from Occipital as well , but now that I know who is behind Kitware, but I would love for you to come on ‘All Things 3D’ and talk about your process and the incredible work you are doing with the Occipital Structure Sensor. Email at [email protected] so we can talk further. By the way, excellent tutorial, when did this come out?

  • Dave

    Hi Luis, take a look at what i printed from a CT scan. I used Osirix and Maya.
    http://www.davefarnham.co.uk

  • John A Thompson

    Hello Luis,

    Thank you for the information and tutorial. I am still not clear on the best way to select Fiducial points. Could you provide a little more detail on the best strategy to use to obtain the result you did in the tutorial.

    Thanks,
    John

  • Brad Beeson

    Awesome! check out 3dprintedart.weebly.com

  • dnaman

    Every time I try this I get stuck at the same point. In Step-3 it says “now select your seed points”. How do I do this?

  • neilwang0913

    Hello Luis:

    I just follow your instruction to do the process but I am difficulty to find out how to show the blue 3D view bone even the tool has highlight the labbed part. Could you give me more clear instruction from step 3 to 4.

    Many thanks.

  • Ravi

    Hi Luis,
    The mark of a good article is when it is in use many many months later.
    I went through all your steps. But, am unable to find .stl format in the output. Can you help?

  • C DeG

    Do you have any idea how to go from DICOM to stereoscopic images for Google Cardboard viewer app

  • Christi

    Thank you for this post, it contains extremely useful information and you did a wonderful job of explaining the process.