Issue loading VTK file


I generated a VTK file matlab using vtkwrite from triangle mesh data.

The raw data looks like this:

16.2150000000000	13.2360000000000	126.065000000000
16.1490000000000	14.2370000000000	125.708000000000
16.8430000000000	13.7070000000000	125.851000000000
15.1780000000000	14.2980000000000	127.202000000000
16.7530000000000	14.3570000000000	125.554000000000
17.0650000000000	12.6940000000000	126.724000000000
16.1660000000000	12.0880000000000	126.873000000000

Here’s the VTK exported file: # vtk DataFile Version 2.0VTK from MatlabASCIIDATASET POLYDATAPOINTS 100 -

When I load this into Slicer 5.0.3 it just crashes immediately

So I opened up Slicer 4.11.20210226 and got the following error:

- Error: Loading C:/.../mesh.vtk - ERROR: In D:\D\S\Slicer-1-build\VTK\IO\Legacy\vtkDataReader.cxx, line 3177
vtkPolyDataReader (000001BD00FACD60): Error reading ascii cell data! for file: C:/..../mesh.vtk
- Error: Loading C:/.../mesh.vtk - Failed to read node mesh_1 (vtkMRMLModelNode5) from filename='C:/.../mesh.vtk'

Someone here may be able to help, but this question would be better directed to a matlab forum (or if you really think the file is correct then the vtk forum, but I suspect the issue is how the matlab code created the file).

I opened an issue with the vtkwrite Git here: Issue loading vtkwrite-generated file into 3D Slicer · Issue #5 · joe-of-all-trades/vtkwrite · GitHub

Any other suggestions about how to generate a slicer-compatible VTK given x, y, z vertex coordinate data?

This is solved. It was an issue with the VTK file. I’ve figured it out!

I was using the OpenEP platform to import CARTO data, so the following solution will be how to generate VTK’s from OpenEP using vtkwrite in Matlab.

x = userdata.surface.triRep.X(1:end,1);
y = userdata.surface.triRep.X(1:end,2);
z = userdata.surface.triRep.X(1:end,3);
1 Like