Automated Segmentation Editor Macro

Hello !

In order to use the Atlas Toolkit plugin (https://imagej.net/Atlas_Toolkit) to perform a registration on trabecular bone, i am required to register bone labels through the plugin Segmentation Editor (https://imagej.net/Segmentation_Editor).

However, due to trabecular bone architecture, i have to label each slice in the editor. For a sample of 900+ slices, it is impossible to do manually.
That is why i try to write a macro that uses the Segmentation Editor automatically.

Here is my issue
This is the macro i ended up with :
//Open the Segmentation Editor manually
**** Start of script ****

selectWindow("Trial");
setLocation(100, 100);

getDimensions(w, h, channels, s, frames);

for (i = 1; i <= 10; i++) {
	setSlice(i);
	makeRectangle(0, 0, w, h);
	//Click T button
	run("IJ Robot", "order=Left_Click x_point=180 y_point=490 delay=300");
	wait(300);
	//Click OK button in the Adjust threshold window
	run("IJ Robot", "order=Left_Click x_point=1100 y_point=425 delay=300");
	wait(500);
	//Click + button
	run("IJ Robot", "order=Left_Click x_point=130 y_point=430 delay=330");
	wait(500);
} 

**** End of script ****

When i run my script, the software keeps in memory the first selection made and applies it on each slice of the Trial label.

Question : What is missing in the macro in order that the plugin actualises the selection for each slice ?

I am also open for any other solution to obtain the labels necessary to be used in the Atlas Toolkit plugin !

Thank you very much in advance for your help

Kind regards

Hi !

I found a solution to use Atlas Toolkit with complex geometries (which is my original issue) :

  • Segment your geometry - your stack has now pixels of 0 or 255 (in case of 8-bit).
  • Use the segmented stacks with Atlas Toolkit. When selecting the channel, select 255.

Then, the registration is performed properly.

1 Like