Using 3D object counter data to find slice and export

Hello everyone!

First off! Thank you so much for the help in the past at answering my questions and queries. You’ve really helped me and given this lowly undergraduate a lot to do and enough hopefully to get a summer internship in my lab.

My question today is an idea I’ve had for building a classification machine learning system, I just need some help getting images from imageJ as output data.

Having used the 3D object counter and the 3D object Manager - Is there a method I can use that will:

  1. for each object find it’s centre
  2. Locate the slide it is in
  3. Jump to that slice
  4. Export slice as a flat image with a specific name i.e. “object4.png”

Many thanks if anyone is able to help! Will make my life so much easier when I hit process for my 1000 or so images.

Nahtan.

Dear @SirSharpest,

That’s a matter of definition, since the centroid could lie in between two slices. You’d have to extract the coordinate in Z dimension and round to the closest slice in general. The 3D Manager, however, seems to extract the centroid in such a way, that it is located on a slice.

You can run the following macro on an image that you have segmented via 3D Manager’s 3D Segmentation functionality:

id = getImageID();
run("3D Manager"); // Enable extensions
Ext.Manager3D_AddImage(); // Add segmented image to 3D Manager
Ext.Manager3D_Count(nb); // Count objects for iterating
for(i=1;i<nb;i++) {
  Ext.Manager3D_Select(i);
  Ext.Manager3D_Centroid3D(i,cx,cy,cz); // Compute centroid 
  selectImage(id); // Get input image
  Stack.setSlice(cz); // Set slice accordingly -- might be problematic if the input image is a hyper stack
  run("Duplicate...", "use"); // Duplicate from stack
  Ext.Manager3D_GetName(i, name); // Get object name from 3D Manager
  saveAs("/Users/stefan/Desktop/test/"+name+".tif"); // Save to folder -- redefined folder
  close();
}

If you need additional information, feel free to post again :wink:

Best,
Stefan

2 Likes

Hey!

Thanks so much for the reply. Can’t wait to give this a try when I’m back in the office.
Will let you know, seems to be exactly what I want :slight_smile:

Thank you so much,
Nathan