ScreenCapture - PNG stack looks flattened


When I re-load images from the Screen Capture module back into Slicer, my volume appears flattened. Attached is an example using the MRHead sample data and generating 50 PNGs. All of the slices are generated but the volume rendering does not look correct

This is fixed by using a larger number of PNG’s, but I’m wondering if it’s possible to scale this automatically such that I can generate 50 PNG’s and just get a smaller but correctly-scaled model?

Thank you.

You lost the correct z spacing, when you saved the volume as PNG stack. PNG doesn’t retain this information. You can manually enter the correct spacing (I think it is 1.3mm for the original MRHead.NRRD) using the Volumes module

1 Like

Note that screen capture is a lossy operation (you lose dynamic range, window/level settings are burnt in, etc), so do not use it for data export. It is for presentations, testing, etc.

Thanks! 1.3mm looks about right for MRHead.

Is there another method you would recommend for data export?
I’m working with segmentations which I’ve exported to labelmaps, then volumeNodes.

I also tried using SlicerFab bitmap generator but kept getting copies of one layer rather than slices throughout the whole volume.

Why aren’t you saving them NRRD? It is not clear to me what you are trying to accomplish. The cross-sections above seems like regular slices from the sample data, not an output SlicerFab. So, the best would be use the default volume format, NRRD which will retain slice spacing.

The application I’m working on creates voxel objects by loading in stacks of PNG’s. I have some segmentation files (NRRD) in Slicer and the goal is to export them to PNGs so I can load them into my application

I think all you need to do is to convert your segmentation to label map and then save it NRRD. I don’t think slicer output a volume as sequence of PNG files through the save dialog box, and using the screen capture has the potential issues @lassoan pointed out (although I am not sure how relevant they are for label maps). You can use Fiji to convert your NRRD to PNG sequence…

1 Like

You can write out a 3D numpy array as a png sequence using a few lines of Python code (you can find examples by web search; you can use pip_install command in Slicer to install any additional packages for png writing).