Proximity threshold for detecting neighboring objects on separate channels

Hello,

I have two images (A and B), each a separate fluorescent signal of the same area/sample. I want to detect objects within each image (A and B) and count how many objects in A are withing a given distance of objects in B. In other words, I’m interested in objects that are in proximity/juxtaposition, not necessarily co-localized/overlapping. How do I set the distance of interest between the centroids of objects on two channels, and create a composite image only objects that satisfy this criteria?

I suspect there isn’t a built-in solution, but consider using a workaround
where you expand the original objects by a bit more than half the distance
of interest, using Identify Secondary modules. If there is overlap in those
expanded objects, you want to keep the original versions of each object,
right?

To carry out the process of checking for overlap then keeping the original
versions of the object will require some fussing with modules. One option
is to measure the “intensity” of objects A within objects B. If it’s
anything other than zero, you have overlap.

Perhaps others have ideas that are not so kludgy.

Anne

1 Like

My workaround is only slightly less kludgy- my suggestion would be to run “ExpandObjects” on B (using the setting to expand by a defined number of pixels) then “Relate Objects” setting A as children and “ExpandedB” as parents- you could then measure the number of A’s near each B (by the ExpandedB_Children_Count or the average properties of the A’s near each B if you put your RelateObjects module downstream of any measurement modules you may be using.
Does that help at all? Good luck!

1 Like

Thank you both. Expanding the objects and relating them (as parent/child) seems to be giving me an answer. I also discovered a module called “measure object neighbors”, which looks like exactly what I need (you can even specify the radius to search over) but this module crashes my pipeline. Maybe it’s not doing what I think?..

On a related note, I’d like to visualize my parent-child positive cells to confirm the module is working; ideally as an image showing each expanded object as a separate color. I’m new to the software, but there doesn’t seem to be an easy way to merge generated images into one. I suppose I could do this manually in image J but it would be a nice feature if it doesn’t exist.

Any advice on this front?

Cheers

Feel free to post the images and pipeline that are crashing and we could take a look at settings that might be causing issues.

Take a look at OverlayOutlines and SaveImages to solve your visualization needs, should be feasible.

Unfortunately the issue with MeasureObjectNeighbors on two different objects is a known bug; I’ve filed an issue before but I’ll try to ping again about getting it fixed.

Seconding Anne about using OverlayOutlines.

1 Like

“OverlayOutlines” worked fairly well but you are limited in the number of images (not objects) you can use. Similarly, in “SaveImages” you are restricted to one channel as far as I can tell. Not to get too off subject, but it would be nice if cell profiler could compile any number of objects or images at your choice (and allow you to pick the color of each) into a single exported image. Anyway, the software is really useful, so thanks guys!

Ah, it does! You’re looking for GrayToColor :slight_smile: . To add in objects you may have to run “ConvertObjectsToImage”, or just do a GrayToColor step to add all the images together you want followed by an OverlayOutlines to put the outlines of the objects on your new multicolor image. Sorry for the confusion.

1 Like

Hello,
Another method that could be useful is using the Morph module with the distance operation (make sure that you set Rescale values from 0 to 1? to No; default is: Yes).
As an input image you would use one segmented image, e.g. A.
This gives you a new image in which the gray-value represents the distance to the closest A object; such an image is called: “distance-transform”.
Then you would measure the Mean_Intensity of all the B objects in this distance-transform image.
Like this, for each object in B you know the distance to the closest object in A.
Cheers, Christian

2 Likes

I missed it! Thanks. Works like a charm now.