How to convert 3D numpy array to vtk and save the .vtk file?

If you have the array associated to a storable mrml node then you can write it to file as shown here.

To create a volume node out of your numpy array,

  1. Add a volume node: volume_node = slicer.mrmlScene.AddNewNodeByClass("vktMRMLScalarVolumeNode")
  2. Set the values of volume_node's underlying vtkImageData using slicer.util.updateVolumeFromArray described here.
2 Likes