How Can I Convert VTK file to nifti format?

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

I don’t think that current NIfTI (NIfTI1), can store surface model.

Thanks a Andras.
I think that I solved it. After creating surface model from nifti image file(322024 voxels with spacing 1.56251.56251.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.

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).

A post was split to a new topic: Convert VTK file to NIFTI or DICOM