Display vtkMarchingCubes in 3d view

Hi I’m at slicer develoment and i got a basic question:

I’m reading in dicom data and after some processing I convert it to vtk using the vtkImageImport.
Then I create a mesh via the vtkMarchingCubes and save it to a .stl file.

So, my question is, how can i display my vtkMarchingCube or volume in the 3d view of slicer?

You can use Models module logic to create a model node from vtkPolyData object:

slicer.modules.models.logic().AddModel(myPolyData)

Note that you don’t need to implement low-level features such as loading image from DICOM or model generation using marching cubes. If you tell us know what the end goal of your project is then we can give you specific advice about how to achieve that in Slicer.

Hi, thanks for your helping me out.

I’m working on an automatic breast cancer segmenation module from dce-mri, using the same method as the Segment CAD module (https://www.slicer.org/wiki/Documentation/Nightly/Modules/SegmentCAD), but my plan is to segment the tumor instead of giving a label map.

So, i have to read in the dicom data manually because of some problems with the files. The files are from the cancerwiki (https://wiki.cancerimagingarchive.net/display/Public/Breast-MRI-NACT-Pilot) and i dont think there is another way then read in all the dcm files manually because they are not in correct order and not sort by timepoint.

Now I’m running into some trouble with the segmentation as you can see on my appended picture. You can see the tumor on the left part, but there is a big chest part showing up and all the blood vessels.
My idea is to remove the chest part with the by removing the largest part with vtkPolyDataConnectivityFilter and use the itk Hessian3DToVesselnessMeasureImageFilter, but i dont know how to remove one polydata from another polydata and how i can use my vtkPolyData with itk.

image

I’ve successfully loaded UCSF-BR-01 using DICOM module:

  • drag-and-drop the folder to Slicer application window
  • click OK to import as DICOM
  • open DICOM browser module to load the imported data
  • choose which data sets to show using Data module

image

It loaded everything perfectly, even segmentations and time sequences (Sagittal-IR_3DFGRE volume). After adjusting segment colors and making 3D display semi-transparent:

image

You can very easily segment the tumor yourself, using Segment editor module. While simple thresholding is available in the module (Threshold effect), you probably want to use Grow from seeds effect for tumor segmentation. Just paint inside and outside the tumor with different segments and use Grow from seeds to create a complete segmentation.

2 Likes

Thank you once again.

Further, how can i change the time point in the slice view when i’ve loaded in the 4-dimensional data?
(drag and drop is only supported at version 4.9)

As I mentioned, i want to implement an automatic segmentation module, so i dont want to place a seed. Can you please explain to me how i can cut vktPolyData out of vtkPolydata.

Boolean operations on meshes are extremely difficult to implement. Maybe not even possible to implement in a way that is guaranteed to work for any geometry, within reasonable time. VTK has some Boolean mesh filters, but of course they very often fail for complex geometries (and unfortunately, randomly fail even for simple ones). I would not recommend to use them.

Fortunately, you don’t need to implement vtkPolyData cutting, as your inputs are volumes, and segmentation can be represented as labelmaps. Implementing Boolean operations on labelmaps is quick and guaranteed to work correctly all the time.

You can use the Logical operators effect of Segment Editor as described here.

I guess you mean you don’t want to place a seed manually. You can create seeds automatically. For example, in some cases you can create seeds by thresholding (using Thresholding effect), followed by splitting of islands to segments (using Islands effect). Or, you may defining seeds for an atlas and then registering that atlas to your patient image and generate seeds by applying the computed transform to the atlas seeds. Of course, there are many approaches to automatic segmentation - not all of them are based on region growing.

If you use Slicer 4.8 or older then 4D DICOM files are always loaded as MultiVolume and you can browse time points using MultiVolumeExplorer module.

If you use a recent nightly build then in menu: Edit/Application settings/DICOM you can choose between loading 4D volumes as Multivolume nodes or as Volume Sequence nodes. Loading as Volume Sequence node requires installation of Sequences extension and you may find it slightly easier to browse the time points, as you can use the Sequence browser toolbar instead of switching between modules.

Hi @TTrambi

I saw in your first post, that you usefully saved to .stl , using vtkMarchingCubes.
I would like to know what method you used ?

because, I’m tried to do the same thing, just to save as vtk file.

@lassoan, any idea ?

Thank you for your time

You can choose file format in the Save data dialog.

Hi @lassoan

it’s working with vtkPolyDataWriter :ok_hand:

now, I’m looking for another way, so I can get a small file size.

Thanks

Typically you can reduce the number of points to 10-20% of the original number by applying decimation, without negligible visible difference. You can apply decimation in Segmentations module when you create the closed surface representation from binary labelmap representation (click Update button in Closed surface representation row in Representations section in Segmentations module); or if you already have a model node then you can use Surface Toolbox module.