Writing labels out to file

I’m trying to print out a single label image with the following in Slicer 4.7.9-2017-09-10

labelNodes = slicer.util.getNodes(‘vtkMRMLLabelMapVolumeNode*’)
vs = labelNodes.values()
v = vs[0]
sNode = slicer.vtkMRMLVolumeArchetypeStorageNode()
success = sNode.WriteData(v)
print success

I get a all-black image (ALL ZEROS) with the correct size. No actual label data with the value of 1 as I expected. Am I doing something wrong here?

Saving to consumer image formats (tiff, JPEG, png) has been broken for a good while, see https://issues.slicer.org/view.php?id=4091

You can add a note to the issue describing why it is important for you to have this working. Until it is fixed, you may try using an VTK or ITK reader directly.

Ha! I forgot, I’m the one who opened that issue! Tiff’s were working at that point, but they are now also broken.

Saving to “consumer” image formats allows Slicer to interact with a larger community of software and encourages people to use Slicer’s output for further analysis and software development. As far as a note why it should be fixed, I would think this is self-evident.

You lose a lot of information if you use consumer file formats (slice spacing, image position, orientation, other metadata) and you may have image artifacts due to compression, so images saved in these formats are not well suited for further analysis. ScreenCapture module can be used for exporting view contents to image files/videos for presentation. It is clear that it is a nice to be able to export to tiff, but for me it is not self-evident if this is really important.

What would you use the exported files for? How do you manage the lost metadata (image position, orientation, slice spacing, …)? What software you use to further process tiff files? Do these software support standard medical image computing file formats (nrrd, metaimage, nifti) or DICOM?