# Import point cloud data

**URL:** <https://discourse.slicer.org/t/import-point-cloud-data/1382>\
**Category:** Support\
**Created:** [November 5, 2017, 6:21am UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382 "2017-11-05T06:21:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hamburgerfinger](https://avatars.discourse-cdn.com/v4/letter/h/eb9ed0/32.png) [@Hamburgerfinger](https://discourse.slicer.org/u/Hamburgerfinger)\
**Post date:** [November 5, 2017, 6:21am UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/1 "2017-11-05T06:21:50Z")

</div>

I have image data in point cloud format (4 columns: x,y,z,intensity). How can I import this volume, or convert it to a format I can import into Slicer?

Any help would be most appreciated!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 5, 2017, 3:32pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/2 "2017-11-05T15:32:33Z")

</div>

Can you update the software that writes the file to use a standard file format that VTK understands - such as .vtk or .vtp?

For example a .vtk file that contains point coordinates, normals, and a custom scalar (RandomPointScalars) looks like this:

```
# vtk DataFile Version 4.0
vtk output
ASCII
DATASET POLYDATA
POINTS 10 float
15 20 55 15 20 5 36.6506 20 42.5 
36.6506 20 17.5 15 41.6506 42.5 15 41.6506 17.5 
-6.65064 20 42.5 -6.65064 20 17.5 15 -1.65064 42.5 
15 -1.65064 17.5 
POLYGONS 16 64
3 2 4 0 
3 4 6 0 
3 6 8 0 
3 8 2 0 
3 3 1 5 
3 5 1 7 
3 7 1 9 
3 9 1 3 
3 2 3 5 
3 2 5 4 
3 4 5 7 
3 4 7 6 
3 6 7 9 
3 6 9 8 
3 8 9 3 
3 8 3 2 

POINT_DATA 10
SCALARS RandomPointScalars double
LOOKUP_TABLE default
59.2003 48.7194 47.505 35.9199 76.0935 74.2874 67.639 79.0812 38.1966 
40.449 
NORMALS Normals float
0 0 1 0 0 -1 0.866025 0 0.5 
0.866025 0 -0.5 5.30288e-017 0.866025 0.5 5.30288e-017 0.866025 -0.5 
-0.866025 1.06058e-016 0.5 -0.866025 1.06058e-016 -0.5 -1.59086e-016 -0.866025 0.5 
-1.59086e-016 -0.866025 -0.5
```

---

<div class="post-metadata">

**Author:** ![Hamburgerfinger](https://avatars.discourse-cdn.com/v4/letter/h/eb9ed0/32.png) [@Hamburgerfinger](https://discourse.slicer.org/u/Hamburgerfinger)\
**Post date:** [November 5, 2017, 3:56pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/3 "2017-11-05T15:56:44Z")

</div>

Yes; it’s actually data that’s processed in Paraview (voxel data as a rectilinear grid). I can export it from Paraview as .vtk, .vtu, and so on, but once I import that into Slicer, it becomes a “model” with no signal information, and I would like it to import it as a “volume” so I can use Gaussian blur, segmentation, etc.

Best,  
Luke

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 5, 2017, 5:45pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/4 "2017-11-05T17:45:16Z")

</div>

If you have a surface mesh then you can load it into Slicer as a model and import as a segment using Segmentations module. To edit in Segment Editor, you need to select a Master volume to define image resolution and axes. If you don’t have any volume then load any of the sample volumes and resize&resample using Crop volume module.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 5, 2017, 6:03pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/5 "2017-11-05T18:03:28Z")

</div>

If you have volumetric mesh in Paraview, then convert it to an image using `Resample to image` filter and save it as a Meta Image (.mha or .mhd) file.

Note that in general Slicer is much better suited for medical image analysis, processing, and visualization than Paraview, as Slicer is primarily developed for this purpose, while Paraview’s main strength is visualization and processing of large meshes. Let us know if there is any Paraview feature that you would like to use and don’t find in Slicer.

---

<div class="post-metadata">

**Author:** ![Hamburgerfinger](https://avatars.discourse-cdn.com/v4/letter/h/eb9ed0/32.png) [@Hamburgerfinger](https://discourse.slicer.org/u/Hamburgerfinger)\
**Post date:** [November 5, 2017, 9:17pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/6 "2017-11-05T21:17:58Z")

</div>

Can I “resample a model to image” in Slicer? Doing so works in Paraview, but saving the result as a .mhd causes Paraview v5.4 to crash, on both Mac and PC.

The main issue I’m still having with Slicer is that I can’t (or don’t know how to) use the Gaussian blur module in Slicer if my data is imported as a model (the Gaussian blur module with volume data works perfectly).

Alternatively, I’ve tried the “Gaussian resampling” filter in Paraview, but the blurring parameters aren’t well described in the GUI/documentation, particularly for how the input parameters relate to sigma, as used in Slicer.

I really appreciate all your help with this!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 5, 2017, 10:13pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/7 "2017-11-05T22:13:12Z")

</div>

Can you describe what you would like to do overall? Most likely you can do everything in Slicer and then you don’t have to worry about these conversions (Slicer can probably do all processing that you need while keeping your data as image or segmentation).

---

<div class="post-metadata">

**Author:** ![Hamburgerfinger](https://avatars.discourse-cdn.com/v4/letter/h/eb9ed0/32.png) [@Hamburgerfinger](https://discourse.slicer.org/u/Hamburgerfinger)\
**Post date:** [November 5, 2017, 11:01pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/8 "2017-11-05T23:01:19Z")

</div>

Sure; the program I’m using creates voxel data output as cells in a .vtk rectilinear grid. For example:

# vtk DataFile Version 3.0

vtk\_output  
ASCII  
DATASET RECTILINEAR\_GRID  
DIMENSIONS 51 101 41  
X\_COORDINATES 51 float  
-2.0000E+00 -1.9200E+00 -1.8400E+00 …  
Y\_COORDINATES 101 float  
-4.5000E+00 -4.4100E+00 -4.3200E+00 …  
Z\_COORDINATES 41 float  
-1.5000E+00 -1.4250E+00 -1.3500E+00 …

CELL\_DATA 200000  
FIELD FieldData 3  
all 1 200000 float  
0.0000E+00 0.0000E+00 0.0000E+00 …

Specifically, I want to apply a Gaussian blur to the volume, to simulate the same data imaged at different resolutions.

You’re absolutely right, I can ideally do everything I need to do in Slicer. With “normal” image volumes, e.g. DICOM files, I just import as a “volume” and can use the Gaussian blur module to blur the image. However, the problem here, is that since my present data is generated at the source as a .vtk file, I can’t seem to import it as a “volume”. Slicer recognizes it only as a “model”. And the Gaussian blur module in Slicer doesn’t allow one to select a “model” as input.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 5, 2017, 11:45pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/9 "2017-11-05T23:45:37Z")

</div>

> [@Hamburgerfinger](#):
>
> the program I’m using creates voxel data output as cells in a .vtk rectilinear grid

Maybe you could fix that program then. A vtk rectilinear grid is not a volume (vtkImageData), as in a rectilinear grid, spacing along each axis may vary arbitrarily, while in a volume, spacing along each axis is constant. If that programs wants to write a volume then it should create a .vtk file that has `DATASET STRUCTURED_POINTS` inside.

Even better, use .nrrd or .mha file format instead. The problem with .vtk image files is that they cannot store axis orientation (it is assumed that IJK image axes are aligned with XYZ physical axes, which is often not true in medical images).

---

<div class="post-metadata">

**Author:** ![Hamburgerfinger](https://avatars.discourse-cdn.com/v4/letter/h/eb9ed0/32.png) [@Hamburgerfinger](https://discourse.slicer.org/u/Hamburgerfinger)\
**Post date:** [November 6, 2017, 3:57pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/10 "2017-11-06T15:57:44Z")

</div>

Unfortunately I’m not a programmer. But, I can save my file as vtkImageData in Paraview, but it still won’t import as a volume into Slicer. For example:

 0 0 0 0 0 0 0 0 0 0 0 0 ...

Isn’t this the same as “structured points”?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 6, 2017, 4:20pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/12 "2017-11-06T16:20:53Z")

</div>

What software generates that file that contains the volume as.vtk rectilinear grid? Is there a particular reason why that software does not save the volume as an image (.vtk file with DATASET STRUCTURED\_POINTS inside; .vti file; .nrrd or .mha file…)?

You should be able to convert volumetric mesh (such as rectilinear grid) of a model node to vtkImageData of a volume node in Slicer, using [vtkProbeFilter](https://www.vtk.org/doc/nightly/html/classvtkProbeFilter.html), but that requires writing 10-15 lines of Python script.

---

<div class="post-metadata">

**Author:** ![Hamburgerfinger](https://avatars.discourse-cdn.com/v4/letter/h/eb9ed0/32.png) [@Hamburgerfinger](https://discourse.slicer.org/u/Hamburgerfinger)\
**Post date:** [November 6, 2017, 7:44pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/13 "2017-11-06T19:44:12Z")

</div>

Its a monte carlo code called PHITS. It’s advantageous sometimes in MC simulations to use a nonuniform grid size, for example in order to optimize counting statistics in a particular direction, or region of the mesh.

I can convert to .vti, but Slicer isn’t importing my .vti files.

Additionally I’ve saved it as a structured point dataset (below is the header info from my file) but it also won’t import my structured point .vtk into Slicer as a volume. Do you see any errors or incompatibility here?

# vtk DataFile Version 4.1

vtk output  
ASCII  
DATASET STRUCTURED\_POINTS  
DIMENSIONS 52 116 39  
SPACING 0.0784314 0.0782609 0.0789474  
ORIGIN -2 -4.5 -1.5  
CELL\_DATA 222870  
FIELD FieldData 1  
vtkGhostType 1 222870 unsigned\_char  
0 0 0 0 0 0 0 0 0  
…

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 6, 2017, 8:02pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/14 "2017-11-06T20:02:12Z")

</div>

To load volume from VTK file, in the “Add data” dialog choose Volume instead of Model.

---

<div class="post-metadata">

**Author:** ![Hamburgerfinger](https://avatars.discourse-cdn.com/v4/letter/h/eb9ed0/32.png) [@Hamburgerfinger](https://discourse.slicer.org/u/Hamburgerfinger)\
**Post date:** [November 6, 2017, 8:17pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/15 "2017-11-06T20:17:05Z")

</div>

Could I send you the file? I’ve tried this on both Mac and PC, and it won’t load. It loads into Paraview as an image, but not into Slicer.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 6, 2017, 11:31pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/16 "2017-11-06T23:31:33Z")

</div>

Yes, having an example file would help a lot. You can upload it to dropbox, onedrive, gdrive, etc. and post the link here.

---

<div class="post-metadata">

**Author:** ![Hamburgerfinger](https://avatars.discourse-cdn.com/v4/letter/h/eb9ed0/32.png) [@Hamburgerfinger](https://discourse.slicer.org/u/Hamburgerfinger)\
**Post date:** [November 8, 2017, 5:00pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/17 "2017-11-08T17:00:36Z")

</div>

Perfect, thanks!

The .vti file is here:

[https://drive.google.com/open?id=1sryack8W\_0iYvbwzniu\_S7tYgYqATIg7](https://drive.google.com/open?id=1sryack8W_0iYvbwzniu_S7tYgYqATIg7)

The .vtk file is here:

[https://drive.google.com/open?id=1qBVl7VNlQcfXOoXsacJCswV9S74iep5Q](https://drive.google.com/open?id=1qBVl7VNlQcfXOoXsacJCswV9S74iep5Q)

When attempting to load in the GUI, nothing happens, and when doing so with the Python interactor, it returns (False, None).

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 8, 2017, 6:26pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/18 "2017-11-08T18:26:11Z")

</div>

Slicer could not load the .vtk file, as no SCALAR data was specified for point data. You can load the data manually using the Python console like this:

```
# Read data set
reader=vtk.vtkStructuredPointsReader()
reader.SetFileName("test14.vtk")
reader.Update()
img=reader.GetOutput()
# Set active point scalar attribute
img.GetPointData().SetActiveAttribute("all",vtk.vtkDataSetAttributes.SCALARS)
# Convert to volume node
volumeNode=slicer.mrmlScene.AddNewNodeByClass("vtkMRMLScalarVolumeNode")
spacing = img.GetSpacing()
origin = img.GetOrigin()
img.SetSpacing(1,1,1)
img.SetOrigin(0,0,0)
volumeNode.SetAndObserveImageData(img)
volumeNode.SetSpacing(spacing)
volumeNode.SetOrigin(origin)
# Show in slice views
volumeNode.CreateDefaultDisplayNodes()
slicer.util.setSliceViewerLayers(background=volumeNode)
```

---

<div class="post-metadata">

**Author:** ![Hamburgerfinger](https://avatars.discourse-cdn.com/v4/letter/h/eb9ed0/32.png) [@Hamburgerfinger](https://discourse.slicer.org/u/Hamburgerfinger)\
**Post date:** [November 8, 2017, 10:31pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/19 "2017-11-08T22:31:18Z")

</div>

This works perfectly!!!

Thanks so much!!  
Luke

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 22, 2021, 3:40am UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/20 "2021-12-22T03:40:49Z")

</div>

A post was split to a new topic: [Convert point cloud to surface model](https://discourse.slicer.org/t/convert-point-cloud-to-surface-model/21175)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 29, 2023, 2:57pm UTC](https://discourse.slicer.org/t/import-point-cloud-data/1382/21 "2023-07-29T14:57:18Z")

</div>

A post was split to a new topic: [Import point cloud](https://discourse.slicer.org/t/import-point-cloud/30867)
