How to see the commands of what I manually do


Is there a way to see the commands that I execute while segmenting an image? For example, if I select a specific module or if I add a segment, I would like to know what would be the commands to introduce to automate the process (i.e, in a macro). I thought it would be in the Python console, but that’s is not what I’m looking for.

Thank you in advance!


1 Like

No, unfortunately there’s nothing like that.

1 Like

The best I can recommend would be looking into how the segmentation is stored in slicer. For volumes with no overlapping segments, this is pretty straightforward. It’s pretty much a 3 dimensional color-by-number. For example: I am presently segmenting volumes containing Blood Vessel trees and the solution that worked well for me was using a Breadth First Search algorithm on each non-zero point that would paint 1’s on the first vessel, 2’s on the second, etc. until it ran out of un-painted areas to check. At the end of this, I was able to put the colored in segmentation into a labelmapNode and from there I was able to convert that labelmap into a segmentationNode. I don’t know precisely what you are trying to segment, but if you approach it from a “what does the data look like” angle, you may find more efficient methods to achieve your endgoal.

1 Like

Slicer does not offer GUI task automation like macros. What you can do is to get yourself familiar with python script to accomplish the same tasks through python console (this is often less complicated than trying to build the same automation through GUI, because all those button clicks and options quickly add up).

you can start reviewing the segmentation script samples, Script repository — 3D Slicer documentation

We have some annotated examples in SlicerMorph script tutorials as well:

e.g., GitHub - SlicerMorph/Scripts

1 Like

Thank you for your response! I will check it out!

But if I undestood correctly, using this approach is not possible to automate the whole segmentation process right? Because although you can create a script with task such as importing and exporting files, the necessary manouvres performed to segment an element (such as moving through different slices) can not implemented.

I just want to make sure this is not a possibility, so I can explore other approaches.

Thank you again!

I mean in general if you are going to interact with data, you can’t fully automate things anyways.

What are you expecting to do when you are moving through the slices? Explain what you want to do so that we can make better suggestions.