CLIJ2 Tribolium embryo morphometry sample macro

Hi @haesleinhuepf,
I’m trying to go through the Tribolium embryo morphometry sample macro but the commands that start with show are not recognised.
image

image

CLIJ and CLIJ2 are installed and up to date.
image

Am I missing something?

Thank you!

1 Like

Hey @LPUoO,

the ‘show’ function is at the end of the macro you were looking at.

I put it there to not confuse the reader at the beginning.

Let us know if this solves your issue!

Cheers,
Robert

1 Like

Ahh, yes thank you,
I was attempting to run small individual fragments of the macro so I could see exactly the effect of the individual commands!

Problem solved!

1 Like

@haesleinhuepf,
I am having some trouble running the end of the " Quantitative analysis of distance between neighbors" section.

For some reason all the outputs are blank (pixel values = NaN). I’m unsure why? The only thing I did was to disable line 150 (exit()).

Also, reading the description I am slightly confused by the diference between the distance map and the neighbor mean distance map.
The distance map is the the averge distance between a node and of all its neighbors while the neighbor mean distance map would be the mean of the averge distance between a node and of all its neighbors?

Thank you

1 Like

Hey @LPUoO,

this bug was discussed earlier here in the forum. The issue was that the parametric 3D stacks contained NaN pixels and a maximum-z-projection of some pixels were any are NaN, is NaN. It was fixed by introducing some lines in the example code:

Apparently, the website wasn’t update after that. Apologies. I’m going to update that asap.

Yes, you got it right. In the first place, you measure distance between neighbors generating a distance matrix. You then average the distance for each cell and visualise it in a map. Afterwards, you compute the mean distance of all neighbors of the neighbors of each cell. If you think about that further, you are averaging distance of first and second order while taking first order into account twice. Thus, this something like a Gaussian Blur or local distances.

Let me know if you want to learn more! This neighbor-part is the interesting part, also for me :wink:

Cheers,
Robert

1 Like

Addendum: In daily routine it might be easier to replace NaNs with zeros before doing the maximum projection.

1 Like

Hey @LPUoO,

I just updated the website. While doing so, I realised that the bug you observed was still there, when running the script on an NVidia GPU, but not on Intel. It’s fixed now on the website and in the example code as well. I need to dig deeper regaring the difference between results on NVidia and Intel. Thanks for pointing me to this issue!

Cheers,
Robert

1 Like

Yes, I am very interested in learning more about this.

Also. a few additional question. I am now trying to apply your macro to my data.

  1. How do I incorporate my voxel dimension in the distance calculations?
    image

  2. In the distance map is it possible to exclude maximas where the average distance between a node and of all its neighbors are superior to a given value X?

  3. How can I export the average distance between a node and of all its neighbors as a simple list?

Thank you very much!

Hey @LPUoO

that’s great questions!

Multiply the point-list with the voxel size as shown here

Yes! After measuring the distance, you have a vector of measurements in a 1d-image. Apply a threshold to that vector, e.g. using the smallerConstant method and you receive a binary vector, which specifies which rows/columns to keep in the distance matrix. Depending on if you want to eliminate rows or columns, you might want to transpose the vector before multiplying the vector with the distance matrix. Use multiplyImages for this operation and not matrix multiplication :wink:

If you have measurements of any kind you can print them out or pull them to the results table

You’re most welcome :slight_smile:

1 Like

Thank you @haesleinhuepf

I’m having some trouble incorporating my voxel dimension in the distance calculations.
I multiply the point_list with the voxel_size matrix and I then use the transformed_pointlist calculate the touch matrix mesh,


but my distance matrix, distance mesh and distance map are blank, so I am not sure where is my mistake? :thinking:



I did attempt to use the smallerConstant function but sadly also failed.
Would thresholding the distance matrix be an alternative to your suggestion?
image

Without thresholding the distance matrix we have this


but this after thresholding, so I assume this is working okay?


I did mange to pull the averageDistanceOfTouchingNeighbors to the results table so :+1:

Thank you very much!

In case touchMatrixToMesh doesn’t work, try printing out the parameters you send to it. I think you should keep the pointlist when calling touchMatrixToMesh because the mesh should be drawn in pixel coordinates, right? Assume your image is 100 pixels wide and your pixel size 0.01: The mesh would then be drawn inside one pixel in the top left corner. :wink:

Can you crop out the top left 10x10 pixels of the distance matrix and print it out? You will then see what numbers are in there and can think about a proper thresholding strategy. Furthermore, if code using smallerConstant doesn’t work, please post it here so that we can take a look :wink:

Keep pushing pixels, I think you’re almost there! :slight_smile:

Cheers,
Robert

1 Like