# Cell Neighbor Statistics

Hello!

We are having images like below where we want to do the following steps:

1. Automatically find all nuclei
2. Classify nuclei into dividing (purple numbers) vs. non-dividing (yellow numbers)
3. Measure the probability that a spatial neighbor of dividing nucleus also is dividing

Below manual annotation is not comprehensive, I just marked a few nuclei for illustration.

I think for the tasks (1) and (2) ilastik or Imaris should be very good (data actually is 3D).

My question is whether any of you knows of any standard tools that could be used to address the cell neighbor statistics aspect (3)?

Thanks a lot for your input!

1 Like

can you share the original data so that we can demonstrate potential workflows? (-:

Cheers,
Robert

In fact the issue is a little more complex. We have three channels, and would like to consider nuclei as neighbors, only if they do not have any of the red signal between them.

I thought once we have the center coordinates of the nuclei, we could find the nearest neighbors and then automatically evaluate a line profile connecting the center points for whether it contains intensity in the red channel.

Again, my question would be whether any standard software comes to mind to determine whether or not nuclei are neighbors, maybe employing complex criteria.

Sure, here is the 2d slice: test-slice.tif (1010.9 KB)

1. and 2) are totally up ilastikâ€™s alley. No really good idea for 3) other than some ad hoc heuristicsâ€¦
1 Like

Hello

You can find an example of the 3D data here:

2 Likes

not sure if it is a â€śstandard toolâ€ť but clij(x) focuses a lot on neighbor analysis. For tasks 1 and 2, basic functionaly exists as well but nothing special (thresholding, weka-based object classification, k-means clustering). For 3) the neighbor analysis part, I recommend determining a label-image that only contains the dividing cells and dilating the labels. If you also have a binary image of the other channel, you can invert it, multiply it with the label image and then analyse number of touching neighbors. It is a task I would solve via scripting, but also the assistant allows to do it via the graphical interface. A rough full workflow (including simple segmentation and threshold-based classification) for counting touching neighbors looks like this:

tischi-neighbor-analysis.zip (1.4 KB)

When reloading it (File > Import > CLIJx Image Data Flow ), there is a tiny bug: you need to manually change the lower â€śExtracted channelâ€ť to 2

For applying some of the operations in 3D (e.g. Extend Labels with maximum Radius), the image data needs to be isotropic.

Let us know if this helps!

Cheers,
Robert

5 Likes

@haesleinhuepf
wow! thanks! we will check it out!
so you are saying it the data is isotropic (which we could just make it by resampling) your workflow would also work in 3D?

1 Like

Yes, almost all functions in clij support 2D and 3D data. That was a major goal while developing it

3 Likes

It seems like 1) and 2) are largely covered, so here are some hints for 3):

PS Would your 3rd goal be correctly summarized by saying that you want to first define what is meant by a neighbor, then assign a unique neighbor for each dividing cell, then apply exclusion criteria (red mass between neighbors), then (among retained neighbor pairs) calculate the simple ratio of dividing-neighbors to all-neighbors (dividing and non-dividing) of dividing cells? If yes, that sounds like something you code up in any language and donâ€™t need to spend time searching for specific packages. In MATLAB you calculate all distances in your cell-position matrix with `pdist`, ah you know this already.

If the results depends too sensitively on the threshold on your proposed line-profile through red , this could be a warning sign.

3 Likes

Exactly, and yes, I know I could (and maybe have to) code this in any language, but I was still curious whether other people had similar issues and what kind of solutions they employed.

1 Like

Another aspect is also whether one can find a solution where (1-3) can be conveniently implemented in one platform, because this facilitates deployment and user-friendliness.

I was working on bringing number 3 to Fiji, because I think Fiji is a fantastic platform for combining algorithms and tools from many sources.

2 Likes

Nice talk @haesleinhuepf,

Given your physical location, are you aware on any activity along the lines of this poster: Spatial interaction analysis in QuPath using MOSAICsuite

Or perhaps a #qupath (@Peteâ€™s software) superuser somewhere, e.g. @oburri or @romainGuiet has ideas/knowledge on how to do all in one place or why that isnâ€™t currently possible.

1 Like

To be honest, it is possible. See my screenshot above. Together with StarDist, Weka, MOSAIC & friends, you have everything necessary in Fiji and obviously also in QuPath.

The only thing we need to do is spreading the word (suppl Figure S3), teaching each other and streamlining interoperability.

3 Likes

To be honest, it is possible. See my screenshot above. Together with StarDist, Weka, MOSAIC & friends, you have everything necessary in Fiji and obviously also in QuPath.

The only thing we need to do is spreading the word (suppl Figure S3), teaching each other and streamlining interoperability.

Dang, another must-read paper, sorry to have missed it back in November.

Yes, all of this can clearly be done in one environment and some make it easier than others. However, I now think @Christian_Tischer was hoping for something almost entirely clickable, or at least not requiring any scripting, so that a user with limiting programming and IA skills can use it (or an analyst can prepare a robust pipeline for the user) - you know, along the lines of #cellprofiler when it comes to GUI.

My personal hope and belief is that this (GUIs for spatial statistics questions) will happen in the coming years, simply because users are increasingly graduating from single-cell questions, to the next level of cell-cell interactions and context dependence (not new, but still too demanding to be really common). Your work on CLIJ gives me hope

3 Likes

Exactly my observation! People now come with segmented images and ask what to do with them. And during many projects we realize that someting like a single cell-distance measurement is nice but there is so much more. We do work a lot work with ML-approaches similar to the Toth-paper you linked above. And thatâ€™s the last link I provide today showing how we do this. A master student currently works on this topic, potentially making it even easier to use for everyone

1 Like

In fact, not really, ideally there is a script in the end, which is much more FAIR than a sequence of clicks in a UI. In addition, then playing with different parameters, a script is much more efficient than, over and over, clicking the same sequence in an UI. However, to initially generate the script, clicking in a UI is a good way. Thatâ€™s why IJ Macro recording is such a great mechanism!

3 Likes

@haesleinhuepf is that in Fiji?

I think your idea was to see whether nuclei are neighbors without being separate by the fluid channel, is it? Thatâ€™s why you multiplied the fluid channel onto the dilated nuclei label mask is it?

However in above image some nuclei show a neighbor count of 2 even though they are isolated. I think the issue is that sometimes the label index still occurs â€śon the other side of the fluidâ€ť such that we have spatially split labels.

I guess better could be to conditionally dilate the label mask, stopping the region growing when hitting the fluid (pixel with value !=0, in a binary mask). I think this could be in general a useful algorithm to have, what do you think?