Export Volume Rendering as stack of PNG's. NOT stl's

You should be able to create a clipping scenario like the one shown in the image below. I’ve done it through the GUI here, but the same thing in python via the model display nodes, clip model node, and slice nodes using code like what’s pasted below. This would need to be scripted and integrated with the corresponding slab generation for the volume rendering.

Cheers,
Steve

m = getNode('tissue')
dn = m.GetDisplayNode()
dn.SetClipping(0)
dn.SetClipping(1)
c = getNode('*ClipModel*')
c.SetClipType(1)
c.SetClipType(0)
c.SetClipType(1)
c.SetYellowSliceClipState(1)
c.SetYellowSliceClipState(0)
c.SetYellowSliceClipState(1)

1 Like

Sorry I hadn’t been paying attention to this thread for a few months, but I’m super happy it got made into an official extension. To see if I can help with the dithering, I’ll share what I did code wise (in R unfortunately, not Python):

Text file with R code

In summary, it takes all the png’s in the folder, then using software from an old Amiga emulator dithers them all and spits them out as new files.
I don’t remember exactly but at the time I don’t believe they had alpha channels. I just set everything that was white to be printed in our clear material. Don’t know if that is different now that I think you said alpha is part of the bitmap generator.

It still ran into the problem nicholas.jacobson mentioned of resolution being squished in the printer back when I did it, but we were able to manually fix that.

On that note, ive uninstalled SlIcerFab, reinstalled it through the extension manager, and i’m running 4.11, and I don’t see any of the options to specify dpi or height or anything. Is that in the GUI or just the python code?

Hi @JoeCrozier - I don’t think anyone has worked on the GUI for this yet, but it’s pretty easy to edit the python code directly to match your printer parameters.

The R code looks fine. Also people could look at Image Magick for dithering and other options.

http://www.imagemagick.org/Usage/quantize/#diy_multi

1 Like

im having issues installing this extension does somebody know what im doing wrong?

We would be happy to help. Please provide more details about what exact steps you do, what you expect to happen, and what happens instead.

Hi Nick,

I’m currently seeing the same issue you described above: I keep getting a stack of the same image repeated. Can you describe the steps that resolved this? I’m running the bitmap generator on just one volume. I’ve also tried converting the labelmap to a scalar volume, but am still having the same issue.

Hi -

I fixed the self test so if you reinstall the extension tomorrow you should be able to test it (turn on developer mode and click the reload and test button). Or if you want to try sooner you can checkout the module and update the code manually.

I tested this with today’s nightly preview version on mac and it worked fine. One thing to note is that if you are using the default settings the slices are very thin (to match the printer needing thin cuts) so you won’t see much change unless you wait quite a while.

Hi Steve,

Thanks for looking into this.
The test passes, but the PNG’s it outputs still look the same. I’m wondering if there might be any other settings I might have set up incorrectly. I was able to use the extension previously (about a month ago) but I don’t recall doing anything differently.

I have been using 100 DPI, 1mm thickness, and 1.00x scale just for testing.

Attached: Slices 0 and 12 from the test

Hi @KTing -

Hmm, not sure what’s different. I just downloaded today’s Slicer preview, installed SlicerFab, clicked the Reload & Test button, and everything worked. I tested this on windows and got the images as shown below. Is it possible you had another volume loaded before running the test? That might interfere somehow.

-Steve

I tried running the test on another machine, and it looks like it’s working- thanks!
Not sure what the issue is on this machine though - I’m also using today’s Slicer preview.

Should this extension work on segmentation files? I’ve first converted them to labelmaps then to scalarVolumes, but haven’t had any luck so far, the PNG’s look like a squashed top-down view of my volume

Great!

I’m not sure either. Are there any other extensions installed? Is there a .slicerrc.py file or something else that modifies the default behavior?

That should work, but I haven’t really tried. Let us know how it goes.

Unfortunately it doesn’t look like it worked, the PNG’s just look like a top-down view of my volume

Segmentations are binary files, you can print them as usual, from an STL file You can “Export to files” section in Segmentations module.

I’m actually using the extension for a different application, (not 3D printing)
The application I’m working on takes a stack of PNG’s to construct a voxel object. My goal is to take my segmentation files of bone, ligament, etc. and export each of them to stacks of PNGs

Would there be another way I can accomplish this?

You can use Screen Capture module to get an image stack of slice views (choose a slice view as “Master view” and use “slice sweep” animation mode).

Thanks for the suggestion!

@pieper @lassoan I’m looking for a way to register CT and MRI and use slicerfab to print both volumes at once. For Cranio Facial work we want to get high res bone and soft tissue represented in one print. The problems I’m running into is that Slicer displays multiple volumes in an unpredicatble way. I’d like to specifiy which volume takes precedence and then be able to slicerfab both of these at once. Any thoughts?

For predictable multi-volume rendering, you need to choose “VTK multi-volume (experimental)” rendering in volume rendering module. It does not support shading (current limitation in VTK), but probably this is not be an issue for you.

Thanks. When I slice this from SlicerFab I can only get one of the volumes. I see in the code on line 241 something about GetSingletonNode. Thinking this is what I can change to add both active volumes but not seeing what to change this to. Any thoughts?

self.threeDViewNode = slicer.mrmlScene.GetSingletonNode(“BitmapGenerator”,“vtkMRMLViewNode”)

I haven’t looked carefully in a while, but I’m pretty sure the BitmapGenerator is hard coded for just one volume, so some amount of code restructuring would be needed to support the new renderer.