Extract skull from Dicom

Hi:

I am trying to extract the skull model from series of Dicom files.
I used vtkDICOMImageReader and vtkMarchingCubes.

Here is the result

I wish only get the skull model like the example Headbone
https://kitware.github.io/vtk-examples/site/Python/VisualizationAlgorithms/HeadBone/

  1. I tried to tune the parameters in
    marchingCubes.SetValue(0, 10)
    but there is no good result.
  2. I do not know why there is abnormal particles flying around.

The dicom files are download from 3D-slicer and the link is attached.

Here is my code

#!/usr/bin/env python

# noinspection PyUnresolvedReferences
import vtkmodules.vtkInteractionStyle
# noinspection PyUnresolvedReferences
import vtkmodules.vtkRenderingOpenGL2
from vtkmodules.vtkCommonColor import vtkNamedColors
from vtkmodules.vtkCommonCore import (
    VTK_VERSION_NUMBER,
    vtkVersion
)
from vtkmodules.vtkCommonDataModel import vtkImageData
from vtkmodules.vtkFiltersCore import (
    vtkFlyingEdges3D,
    vtkMarchingCubes,
    vtkStripper
)
from vtkmodules.vtkFiltersSources import vtkSphereSource
from vtkmodules.vtkIOImage import vtkDICOMImageReader
from vtkmodules.vtkImagingHybrid import vtkVoxelModeller
from vtkmodules.vtkRenderingCore import (
    vtkActor,
    vtkPolyDataMapper,
    vtkRenderWindow,
    vtkRenderWindowInteractor,
    vtkRenderer,
    vtkCamera,
    vtkInteractorStyle
)

from vtkmodules.util.numpy_support import vtk_to_numpy
import numpy as np

# the dicom files directory
dicom_dir = "C:\\Users\\perph\\PycharmProjects\\vtk\\MR-head\\Dicom"


reader = vtkDICOMImageReader()
reader.SetDirectoryName(dicom_dir)
reader.Update()

marchingCubes = vtkMarchingCubes()
marchingCubes.SetInputConnection(reader.GetOutputPort())
marchingCubes.SetValue(0, 10)

Stripper = vtkStripper()
Stripper.SetInputConnection(marchingCubes.GetOutputPort())

mapper = vtkPolyDataMapper()
mapper.SetInputConnection(Stripper.GetOutputPort())

actor = vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetDiffuseColor(1, .90, .25)
actor.GetProperty().SetSpecular(.1)
actor.GetProperty().SetSpecularPower(100)

renderer = vtkRenderer()

aCamera = vtkCamera()
aCamera.SetViewUp(0, 0, -1)
aCamera.SetPosition(0, 1, 0)
aCamera.SetFocalPoint(0, 0, 0)
aCamera.ComputeViewPlaneNormal()

rewin = vtkRenderWindow()

interactor = vtkRenderWindowInteractor()

renderer.SetActiveCamera(aCamera)
aCamera.Dolly(1.5)

# style = vtkInteractorStyleTrackballCamera()
# interactor.SetInteractorStyle(style)

rewin.AddRenderer(renderer)
interactor.SetRenderWindow(rewin)

renderer.AddActor(actor)

renderer.ResetCamera()

interactor.Initialize()
interactor.Start()

Thanks very much

This is a T1 head MRI. There is no (or some very low) signal where there is bone, very similarly to air. Therefore, you won’t be able to extract the skull from such images. You can easily extract high-quality skin surface though, you just need to select the right threshold (around 22). For lower-quality images you can apply a median filter on the image before thresholding.

If you want to extract the skull bone then get a CT or CBCT image instead. I see that you got this image from the Slicer sample data sets (it is Steve Pieper’s head). You can find head CTs there: the best is probably CBCT-MR Head, but you may also find CBCTDentalSurgery or CT-MR Brain data sets useful.

Thanks, Mr. Lassoan.
Here I get a good result now.

Would you do me another favor?
Is there any place to download thousands or tens of thousands of CT head?

Thanks!

There are many image collections online. I don’t have any specific recommendation for head CTs.