Convert VTK file to NIFTI or DICOM


I have the same issue (trying to convert VTK files to NIFTI or DICOM). However the solution here doesn’t seem to work for me as I’m loading in a VTK file someone else made.

Any solutions to how to convert these file formats without getting the same errors as above would be much appreciated!


VTK files can be anything (surface mesh, volume, volumetric mesh, etc).

If it is a volume file, then load it into Slicer and in the Save data dialog, choose nifti file format. You can also use the DICOM module to export to DICOM format.

If it is a surface mesh, you can import to into a segmentation node and export to a labelmap node using Segmentations module, then save as a volume file as described above.

A post was split to a new topic: Convert unstructured grid model to volume

Hi Andras,
I have this problem. I want to convert a .vtk file to .nrrd or .nifti file. I do following steps in slicer, but it doesn’t convert correctly.

  1. load data (that it dosen’t show anything)
  2. use segmentation module and import model , it make a segmentation node
  3. export as label map and save as nrrd

when I open .nrrd file in slicer, it dosen’t show anything. I would be appreciated if you help me.

As Andras noted, VTK files can specify meshes or they can specify volumes. They can be in a legacy format or a recent (but less popular) XML format.

In the event that your VTK files are volumes in legacy format, you could convert them to NIfTI using the command line i2nii. Alternatively, you could view them with the graphical MRIcroGL and then choose File/SaveNifti.

If they are mesh files in legacy format, you could open these using the graphical interface of Surfice and use Advanced/SaveMesh to save the mesh as obj, ply, gifti format.

If nothing is shown then don’t even continue. Choose the correct content type (Volume for volume; Segmentation or Model for surface meshes) in “Add data” window in “Description” column.

Hi Chris_Rorden,

I am actually working on a medical simulation in OpenFoam where the VTK file is obtained from Paraview. I wanted to show that into 3D Slicer for medical purpose.

I saw this page and tried to go with the procedure given by you. With respect to this, I have installed i2nii and tried to convert the .vtk file to NifTi format. I am getting the following error.

Only able to read binary VTK files, not "ASCII"
Unable to interpret header "simulation_100.vtk"

Here my file name is “simulation_100.vtk” . Could you please help me how to go foward with this?

Thanks and Regards,

Sunag R A.

@ rasunag27 feel free to send me a google drive or dropbox link to my personal email (you can use Discourse to send me a message if you do not know my email). I should be able to extend my software to support ASCII.

In general, when using a tool like Paraview to save data you should always choose to export as “binary” rather than ASCII. ASCII is inefficient in terms of disk space and read/write speed. If your data is floating point, rather than integer, one can experience rounding errors that would not be encountered if you save in the native binary format.

I would not recommend using .vtk file format for medical images. The limitation that instantly disqualifies this file format from serious use for medical imaging that it cannot store image axis directions (it always assumes image IJK axes are the same as patient LPS axes). Also, the format can only store 4D images (so you, cannot store a 3D+t color volume) and there is no way to specify what the 4th dimension contains (color, displacement, etc.). Finally, we already have 3 other widely used file formats (nrrd, nifti, and mha), so you really don’t want to complicate things with bringing in yet another one. ParaView can read/write .mhd and read .nrrd, so if you use ParaView a lot then you may prefer to use .mhd file format.

You can of course convert any image formats to anything else using Slicer using the GUI (load the data set into Slicer then choose a different format when you save the data); or running this Python command:

slicer.util.saveNode(loadVolume('/path/to/input.vtk'), '/path/to/output.nrrd')

but it makes your life simpler if you use the same file format across all software in your workflow.

1 Like