Measure area/perimeter of bone/implant using weka segmentation

Hi everyone!!

I am new on Fiji. I want to measure area and perimeter of bone and implant using weka segmentation. I trainned a sucessful clasifier, generated probability maps and created a 8 bits mask for each of the classifiers but… I’m not sure the way for the analysis. I know that it is a very simple question for all of you :flushed:, however, if run analyze particles (as @etadobson pointed out in this thread) it generates a lot of ROIs wich don’t seem the areas that I want to measure. Please, could anyone help me?

I guess the results of implant mask it could be ok

But, honestly I don’t understand the ROIs of the mineralized bone masks

Thank you very much.

Hi
@0Enjuto0

On software measurement issues
You will find a lot of answers by reading this
https://imagej.nih.gov/ij/docs/guide/index.html
more precisely
https://imagej.nih.gov/ij/docs/guide/146-30.html#toc-Section-30

Regarding your images:
Can you be more specific in your question.

What are you looking for: the goal.
We would need two identical unprocessed images:

  • one annotated
  • the other not annotated
    Remember that we are not all biologists.

You only want area and perimeter measurements.
Greetings

1 Like

Thanks Mathew,

So sorry, I should have been clearer with my needs.

Ok, let’s. It will be so easy for all of you.

Here is the original image:
bone-implant.tif (3.5 MB)
brown: mineralized bone
black: implant
the rest is background

GOAL: I would measure:

  • Total brown area
  • Total black area and black area perimeter
  • An automatic way for measure black/brown contact
    For this last item I use higher magnification image:
    BIC.tif (4.2 MB)
    Classified:
    BIC Classified image.tif (1.4 MB)
    Masks:
    BIC mask.tif (4.2 MB)

So, I am agree with the ROIs obtained with Implant Masks, although I don’t understand why I need to use the wand tool for select the ROIs, I thought creating masks the roi is automated (ROI=red):

But the mineralized bone mask ROI it has been a weird work for me, I don’t understand how the wand tool is selecting the areas. I just want to analyze the total red area :sweat_smile:

Thanks in advance

Hi
@0Enjuto0

Units are in pixels
Done quickly. Does that make sense to you?

Image 1

This text will be hidden

Macro

selectWindow("Classified image-1.jpg");
run("Set Measurements...", "area perimeter redirect=None decimal=3");
run("Analyze Particles...", "size=150.00-Infinity add");
selectWindow("bone-implant.tif");
run("Duplicate...", " ");
roiManager("Show All with labels");
roiManager("Measure");
Image 2

Results

Label Area Perim.
1 6991 374.250
2 1332 283.706
3 3272 380.902
4 11238 763.578
5 7341 654.465
6 3056 286.534
7 3685 344.333
8 176 52.426
9 1111 150.167
10 371 173.037

text will be hidden

Greetings

Aweson @Mathew,

I modified a little bit your script, only with the idea for using my image which is calibrated.

The results for implant analysis is PERFECT!!!:

But sadly, I still do not understand the analysis of the mineralized bone (=Brown areas), the masks and the ROIs are not ok. In the image below, this is the results of the ROIs, for example, the ROI number 20 (blue marked) is clearly not a brown area (mineralized bone) is a black area (implant). And it is including white areas (background).
mineralized bone mask.tif (1.4 MB)

Thanks!!!

Hi
@0Enjuto0

I suggest you change the size of your image by cutting it slightly.

Image

This text will be hidden

//setTool(“rectangle”);
makeRectangle(0, 0, 1128, 1058);
run(“Crop”);
After a fairly standard thresholding we can obtain this.

Greetings

Hi
This could help you:
Can you tell me about your results, if you don’t mind.
Regards

Image

run("Scale...", "x=0.5 y=0.5 width=565 height=549 interpolation=Bilinear fill average create");
setAutoThreshold("Default");
//run("Threshold...");
run("Create Selection");
run("Measure");
Roi.setFillColor("blue");
roiManager("Add");
roiManager("Show All without labels");

Hi Mathew,

So sorry for my late answer!

Thanks for your suggestion, but let me make you a question. If I have a mask, in a binary mode, the threshold is not necessary isn’t it? So, I don’t understand how FIJI is doing the measures of this image:mineralized bone mask.tif (1.4 MB)

I am new on the image analysis field, perhaps my questions are so obvious for all of you. :upside_down_face:

Dear @0Enjuto0,
If you already have a binary mask you don’t have to threshold again because you only have 0 and 1 (0 and 255) in your image.
You should use

  1. Analyze > set measurements…
  2. Analyze > Set Scale if it’s not set your result will be in pixel²
  3. Analyze > Analyze particles…

If I am not mistaken, the particle analyzer works on the threshold set on the image. If the image is already binary, it is a good idea to make sure that the threshold has been set to the phase you want to analyse (and it appears red) otherwise you risk analysing the “other” phase.
Some other plugins might accept binary images and consider the object as the white or the black regions. The Particles8 plugin does not require a threshold but the user needs to specify whether to analyse the black or the white phase.

Exactly,

Maybe I don’t need to run Analyze particles, because I only need one measure (total white area).

Thanks

It’s ok! the red area is the area that I want to measure.

Thanks @gabriel

Ok, Finally a a way for obtain that all I need with this is:

Total mineralized area in pixels is the 255 value when run Histogram of the mask image isn’t it?

Hi
Do you want to measure the blue area of ​​the attached image?
If yes then use the macro.

Image

Yes you can use the histogram of the binary image to find out how many pixels are “the object”, but be aware that there are various definitions of “area” in the discrete domain. Pixel counts is one of such estimates.

Thanks @Mathew

When I run your macro, the blue area is not the area that I want to measure. I need to analyze the white one :thinking:

Hi
@0Enjuto0
My first macro works with my image deposited in my previous message.
This macro works for your image.
The macros are identical in form, only change of thresholding.
Greetings

run("Duplicate...", "title=1 ");
close("\\Others");
run("Duplicate...", "title=2 ");
run("Duplicate...", "title=3");
setAutoThreshold("Yen dark");
//run("Threshold...");
run("Create Selection");
run("Measure");
roiManager("Add");
selectImage("2");
roiManager("Select", 0);
Roi.setFillColor("blue");
run("Tile");

run("Duplicate...", "title=1 ");
close("\\Others");
run("Duplicate...", "title=2 ");
run("Duplicate...", "title=3");
setAutoThreshold("Yen");
//run("Threshold...");
run("Create Selection");
run("Measure");
roiManager("Add");
selectWindow("2");
roiManager("Select", 0);
Roi.setFillColor("blue");
run("Tile");

Do another test with this other macro: compare the results and the thresholding.
The threshold allows, in my macro proposal, to visualize your selection

@gabriel
Gabriel said it here:

Unless I am mistaken, I understand it this way.
Greetings

Thanks Mathew,

Perfect Mathew!!! This is just what I needed.

If your image is already binarised and you want to count the white pixels, you only need to call the histogram and get the counts for bin size 255:

getHistogram(values, counts, 256); 
print(counts[255]);

Yes, it was the first way to resolve the measure that I propused, anyway I need the area in microns so @Mathew 's Macro provides the measure in these units.

But… the final question is… how can I measure the contact between implant and bone?, in other words, brown and black contact areas in the original image.