Thickness Histogram and SEM

Hi y’all,

I’m trying to generate histograms of trabecular thickness and spacing. The goal is to see the distribution of thinner and thicker trabeculae beyond just the average and max values BoneJ calculates.

I’m able to display a histogram from the thickness maps which I gives me values as below.

It appears that the bin start corresponds to thickness values. Can anyone give more insight onto what “count” specifically means? Are these the number of points that the software measured at a particular thickness?

Also, is there anyway to adjust how many decimal places are included in bin start? I have multiple values of .001, .002, and others.

Lastly, is there any way to display trabecular thickness/spacing variability as SEM? The software automatically gives me the SD (in addition to the average and max values), but I’d prefer SEM.

10%20AM 36%20AM

Thanks,

Emily

1 Like

Hi Emily

It appears that the bin start corresponds to thickness values. Can anyone give more insight onto what “count” specifically means? Are these the number of points that the software measured at a particular thickness?

Yes - to be more precise, it is the number of foreground (i.e. trabecular) pixels that belong to a trabecula of thickness somewhere between (bin start) and (bin start + bin width). You can see your bin width on the lower right below your histogram.

Also, is there anyway to adjust how many decimal places are included in bin start? I have multiple values of .001, .002, and others.

Not that I know. A workaround would be to paste the list on the left into an excel (or other) file and then create a third more accurate column for the bin start by specifying the first bin start (i.e. 9.074e-4) and then adding bin width for the second, and another bin width for the third bin start etc (automate this by dragging and filling in excel). Then you can use the excel data to plot your graphs in excel, R, Python or whatever you like.

Lastly, is there any way to display trabecular thickness/spacing variability as SEM? The software automatically gives me the SD (in addition to the average and max values), but I’d prefer SEM.

This is not a built-in feature, no. Maybe easiest to calculate SEM from the values below your histogram, I would think? SEM = StdDev/sqrt(Count) i.e. SEM = 0.00134/sqrt(2875560) in the example above

Hope this helps!

1 Like

How does Bone J determine the bin width value? Is there a way that I can change this value?

If bin width varies between my stacks, will I be masking variability between samples with different size widths?

BoneJ gives you values for mean, std deviation and maximum thickness.

These are the same independent of what you do with the histogram command, which part is ImageJ. In the ImageJ histogram, you can change the bin width by the “Bins” parameter (100 in the example below). This will create 100 bins in the range between X min and X max

image

This is what the histogram looks like for the same thickness map with 50 (top right) and 100 (bottom right)

So in practice, you want the same X max , X min and Bins to easily compare histograms between samples. But the mean, std dev, and max calculated in BoneJ, and the descriptive statistics below the histogram in ImageJ will be independent of bin width, as they are calculated on the actual data.

Does this help?

Yes. Before you run Analyze>Histogram run Analyze>Set Measurements... and set Decimal places to your desired number of decimal places (max 9).

You have to do it in that order due to the way the program runs. If you change the number of decimal places while the Histogram window is open, the change won’t be applied when you hit the List button.

Perfect! Thanks so much for that information.

I spent the weekend generating histograms and the default number of bins was 256, which I’m assuming corresponds to each pixel value (0-255) of the thickness map? Is 256 the maximum value of bins I can choose or can I accurate get thickness values at a greater number of bins?

I don’t want to mask any differences in my histograms by choosing too large a bin width. So how low can bin width be set/how high can my number of bins be?

The thickness map pixel values are double precision, which means for practical purposes thickness is a continuous variable (although, that is complicated slightly by the way the algorithm converts distances in numbers of pixels to the calibrated real units). For now just consider thickness as continuous.

The colours (LUT) of the thickness map have 256 values for historical reasons - it’s 28 so maps an 8-bit byte pixel value to a 3-byte (24-bit) RGB pixel. But they are just colours for your human eyes that are only loosely bound to the underlying pixel values which represent the thickness at each point.

The number of bins being set at 256 was a design choice, but it’s essentially arbitrary. It’s often OK, but often you can choose something else that suits your data better.

I’ll take a semi-informed guess and suggest 1 (which is not very helpful) to Integer.MAX_VALUE = 2147483647.

Hello,

first of all thank you very much for providing support to users! I’m in a similar situation to Emily, I’d like to plot the distribution of the thickness of a porous structure in a histogram, rather than just presenting the average value. The input file is a stack of 400 images. I’m currently having issues displaying the data in an external software (Matlab 2020b) in an histogram plot, these are the screenshots of what I’m doing:

untitled

Basically when I use the histogram function on the bins and counts, I get a very weird graph (attached). Do you think it has to do with the way I’m importing the data from BoneJ? Thank you very much for your help!

Lorenzo

Looks super weird - just use the data from the table. You should have 100 bins with heights the same as count in the table (or you could make a frequency histogram by dividing each count by sum(all the counts).

Notice that your histogram is not smooth - that is a discretisation artefact; spheres can have only integer radii in this implementation, meaning that not all thickness values are able to be represented. It would be worth making a histogram with max thickness in pixels (or fewer) bins.

Is there a reason you need to use Matlab to make the histogram?

1 Like

Hello,

yeah it appears there’s something weird with the histogram function in MATLAB, I figured it might have been something already encountered in your experience. I’m using that software as a default for publications. Thanks for the advice!

Lorenzo