Is it possible to get names/list of selected Rois in RoiManager3D using a macro command

imagej
roimanager3d

#1

Hello,

My macro opens RoiManager3D with some Rois. Next, the user has a chance to select several Rois. I would like to identify selected Rois if any. Saving selected Rois is not an option for me.

Is it possible to get names/list of all selected Rois in RoiManager3D ?

Any suggestion will be appreciated.
Thanks,
Astha


#2

Looking at the list of available macro extension functions for 3D Roi Manager, I didn’t find an obvious way to get such a listing from a macro.

@ThomasBoudier please correct me if this is wrong.


When using any of the more powerful full-fledged scripting languages however, you can access the public Java API of the RoiManager3D_2 class and access its list of objects directly. The following Groovy script illustrates this:

import mcib_plugins.tools.RoiManager3D_2

manager = new RoiManager3D_2()
manager.setVisible(true)

import ij.gui.WaitForUserDialog

new WaitForUserDialog("Add some objects, then press OK").show()

println manager.list.getSelectedValuesList()

Note: because the RoiManager3D doesn’t register with ImageJ’s WindowManager (which should be best practice for plugins that create new dialog windows), I didn’t find a way to access an existing 3D Manager window. Hence I had to start a new plugin instance and use a dialog to wait for user input. If someone knows a more elegant way, please suggest…


#4

Thanks a lot for all your efforts and suggestion! I will try switching the language…


#5

Hi @Astha and @imagejan,

I did not think of this, it is a good idea, it is added to 3DManager functions and will be available soon in the Fiji update. Thanks Jan for the registration to WindonManager, 3DManager should register properly now.

Here an example macro to get the selected objects :

requires("1.46g");
rename("image");
selectWindow("image");
run("3D Manager");
Ext.Manager3D_AddImage();
waitForUser("Select some objects in 3D, you may need to Deselect first to refresh list");
list="";
name="";
Ext.Manager3D_GetSelected(list);
idx=split(list,":");
print("Selected objects:");
for(i=0;i<idx.length;i++) {
     Ext.Manager3D_GetName(idx[i],name);
     print(idx[i]+" "+name);
}

Hope this helps

Thomas


#6

Thanks for the quick fixes, @ThomasBoudier, I believe the Ext.Manager3D_GetSelected(list) will be useful!

For those interested, the relevant commit is here:


As far as I can see from the source code, RoiManager3D_2 implements PlugIn, but doesn’t extend PlugInFrame. I would assume that you therefore have to take care yourself of not only adding, but also removing the window when it gets closed. Similarly, you might want to add:

WindowManager.setWindow(this);

to the windowActivated() method. See the B&C dialog for an example:


#7

Hi Thomas,
Thanks a lot for your time and support!


#8

Thanks @imagejan,

I will add this to the 3DManager.

Best,

Thomas