Load back 3D objects with 3D Manager

Hi all,

I’m building a multi step workflow using the 3D ROI Manager.

The 1st step consists in finding 3D objects in batch, and saving the objects for each image. I got this to work.

The 2nd step would be opening back those 3D objects and the images linked to allow for manual curation in case the objects are not correct. I found the function pop.loadObjects(path) working but I can’t find how to display the manager side by side with the image.

Any help would be welcome, scripting is done in Python btw.

Thanks

cc @ThomasBoudier

Hi @lguerard,

The Objects3DPopulation class will save each objects as the list of voxels comprising it, it does not save the original image used to create these objects. The function drawPopulation will create an image with all the objects inside, but the size of this image is not necessarily the size of the original image, it is just using the maximum bounding box of all objects.

Best,

Thomas

Hi,

Thanks for the answer ! :slight_smile:

I understand that the objects are separate from the image. The thing that I’m doing right now is opening the image via script, and I wanted to show the 3D Manager GUI with the 3D objects inside. The loadObjects() should be the function to use for that no ?

But where I couldn’t find the method is to show the 3D Manager GUI to the user. Is there a way to do that ?

Thanks a lot !

Hi again,

I found this which manage to show the GUI but I can’t find how to load the 3D objects in that GUI. Any ideas ? :slight_smile:

Hi @lguerard,

Ok you want to open the 3DManager with some objects inside, here some code that shoud do the job :

from mcib3d.geom import Objects3DPopulation,Object3DVoxels
from mcib3d.image3d import ImageInt,ImageByte,ImageShort
from ij import IJ,WindowManager
from mcib_plugins.tools import RoiManager3D_2

# open 3D Manager
manager = RoiManager3D_2()
# create empty population and load objects
pop = Objects3DPopulation()
pop.loadObjects("/home/boudier/Roi3D.zip")
manager.addObjects3DPopulation(pop)

Best,

Thomas

1 Like

Hi @ThomasBoudier,

Thanks for your help ! It indeed works ! Thanks a lot :slight_smile:

If I want to open a new image and new 3D objects, should I delete the current ones first or

pop = Objects3DPopulation()
pop.loadObjects("/home/boudier/Roi3D.zip")
manager.addObjects3DPopulation(pop)

that would be enough ?

Hi @lguerard,

Glad to see it is working ! The function loadObjects will add the loaded objects to the population, so if you want a new population just create it, it will be empty.

Best,

Thomas

Hi @ThomasBoudier

Sorry for reviving this topic but I tried to do the exact same thing today and I’m getting java.lang.NullPointerException. Has there been any change to the code ?

I tried multiple solutions but they all fail with the same exception, am I doing anything off ?

Here is part of the code with the different tests done commented out:


obj_to_remove = []
obj_to_keep = []
# pop_to_keep = Objects3DPopulation()
manager = RoiManager3D_2()
# loop over the objects
for i in range(0, nb):
    obj = pop.getObject(i)
    if(obj.getPixMeanValue(IH_imp_C3) >= min_intensity_C3) and (obj.getVolumePixels() >= min_volume_pos) and (obj.getIntegratedDensity(IH_imp_C3) >= min_int_dens_pos):
        print("Here")
        # obj_to_keep.append(obj)
        # pop_to_keep.addObject(obj)
        # manager.addObject3D(obj)
        continue
    else:
        obj_to_remove.append(obj)

for obj in obj_to_remove:
    pop.removeObject(obj)

# pop_pos = Objects3DPopulation(obj_to_keep)
# manager.addObjects3DPopulation(pop)

pop.saveObjects(pos_zip_out_path)

# open 3D Manager
# manager = RoiManager3D_2()
# create empty population and load objects
pop = Objects3DPopulation()
pop.loadObjects(pos_zip_out_path)
manager.addObjects3DPopulation(pop)

Hi @lguerard,

There was a minor change on the Manager3D plugin, so it can be used as single or multiple instances.

You now need to run the plugin after creating it :

manager = RoiManager3D_2()
manager.run("")

Best

Thomas

1 Like

Hi,

Thanks a lot, that indeed fixes it !

Great to know that we can have multiple instances of it, that could be helpful for my project ! :slight_smile:

Best
Laurent