How to improve SlicerWeb extension with python?

Hello there, I’m new with Slicer and this is my first topic, so I hope I get it to make it clear and straightforward.

I’ve been trying to create a comunication between a Django server and Slicer. The Django server then would have a button that would be used to export opened segmentation files.

My main option was to use SlicerWeb extension, but I find that it can’t export segmentation files, though it can export volume files opened in Slicer perfectly well.

Is there any advice on how I could do that? I’ve been looking into the code of SlicerWeb but I couldn’t figure it out how to start. I guess that I could create a new function into SlicerWeb for a purpose like that.

Thanks
Pedro

Hi Pedro -

The SlicerWeb code should probably be refactored at some point, but for now it can be extended by adding a branch in this set of if statements to create a new rest endpoint, for example <root>/slicer/segmentations that would map to a request handler like this one for volumes through which you can either download or upload via nrrd format. It would just need to be call some of the segmentation api in the request handler.

Hope that helps.

1 Like

Hey Steve, thanks for the solution!

I’ll take a look at these codes you indicated. Definitely it’s gonna help me.

Thanks again!
Pedro