# How Can I Convert VTK file to nifti format?

**URL:** <https://discourse.slicer.org/t/how-can-i-convert-vtk-file-to-nifti-format/1034>\
**Category:** Support\
**Created:** [September 11, 2017, 11:35am UTC](https://discourse.slicer.org/t/how-can-i-convert-vtk-file-to-nifti-format/1034 "2017-09-11T11:35:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shahrokh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/shahrokh/32/1499_2.png) [@shahrokh](https://discourse.slicer.org/u/shahrokh)\
**Post date:** [September 11, 2017, 11:35am UTC](https://discourse.slicer.org/t/how-can-i-convert-vtk-file-to-nifti-format/1034/1 "2017-09-11T11:35:11Z")

</div>

Hi users and developes of Slicer

For creating surface model from one nifti image file, I used “Grayscale Model Maker” module in the category of “Surface Models”. I can save this surface model in vtk format successfully.

At now, I want to save this surface model in nifti format. How can I do it (convert vtk to nifti or dicom)?

I do not know to do it using Slicer modules. How can do it using Slicer?

I try to do it using applications such as Convert3D (c3d), itksnap or gdcm (gdcm2vtk), but I do not success. I get the following error messages.

**in gdcm:**  
[sn@localhost Documents]$ gdcm2vtk -h  
gdcm2vtk: gdcm 2.8.2 $Date$  
vtk version 6.3.0  
Usage: gdcm2vtk [OPTION] input output  
Convert a vtk-supported file into DICOM.  
…  
[sn@localhost Documents]$ ll -h \*.vtk  
-rw-rw-r–. 1 sn sn 68K Sep 11 08:52 myTest.vtk  
[sn@localhost Documents]$ gdcm2vtk myTest.vtk myTest.dcm  
Warning: In /builddir/build/BUILD/VTK-6.3.0/IO/Legacy/vtkDataReader.cxx, line 490  
vtkStructuredPointsReader (0x2bbb860): Reading file version: 4.1 with older reader version 4.0

could not find no reader to handle file: myTest.vtk  
[sn@localhost Documents]$

**In Convert3D:**  
[sn@localhost Documents]$ c3d myTest.vtk -o myTest.dcm  
Exception caught of type 16ConvertException

[sn@localhost Documents]$

**In itksnap:**  
After select myTest.vtk in the window of “Open Image - ITK-SNAP”, I get this error message: "Error: Wrong Format: The IO library for the format ‘VTK Image’ can not read the image file.’

Please guid me to solve it. How can I convert vtk file to nifti format?  
Please guide me.  
Thanks a lot.  
Shahrokh

---

<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:** [September 11, 2017, 1:37pm UTC](https://discourse.slicer.org/t/how-can-i-convert-vtk-file-to-nifti-format/1034/2 "2017-09-11T13:37:22Z")

</div>

> [@shahrokh](#):
>
> I want to save this surface model in nifti format

I don’t think that current NIfTI ([NIfTI1](https://nifti.nimh.nih.gov/nifti-1/documentation/)), can store surface model.

---

<div class="post-metadata">

**Author:** ![shahrokh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/shahrokh/32/1499_2.png) [@shahrokh](https://discourse.slicer.org/u/shahrokh)\
**Post date:** [September 11, 2017, 3:29pm UTC](https://discourse.slicer.org/t/how-can-i-convert-vtk-file-to-nifti-format/1034/3 "2017-09-11T15:29:57Z")

</div>

Thanks a Andras.  
I think that I solved it. After creating surface model from nifti image file(32_20_24 voxels with spacing 1.5625_1.5625_1.5625 mm) by “Grayscale Model Maker” module, I used “Mesh To Label Map” module. This module was created label map with nrrd format with the same dimensions and spacing such as input nifti image file. I save it with nifti format.

---

<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:** [September 11, 2017, 5:25pm UTC](https://discourse.slicer.org/t/how-can-i-convert-vtk-file-to-nifti-format/1034/4 "2017-09-11T17:25:55Z")

</div>

To edit labelmaps stored in image files, such as NIfTI, I would recommend to import it into a segmentation node (using Segmentations module import/export section), edit using Segment Editor module, then export it to labelmap image node (using Segmentations module import/export section).

---

<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:** [March 15, 2018, 6:21pm UTC](https://discourse.slicer.org/t/how-can-i-convert-vtk-file-to-nifti-format/1034/5 "2018-03-15T18:21:31Z")

</div>

A post was split to a new topic: [Convert VTK file to NIFTI or DICOM](https://discourse.slicer.org/t/convert-vtk-file-to-nifti-or-dicom/2330)
