Plot of size distribution for each slice

Tags: #<Tag:0x00007fa306de99b8> #<Tag:0x00007fa306de9878>



I am trying to write a macro code to output a distribution plot for each slice from an image.
By distribution plot, I mean:

  • Y-Axis = Number of particles
  • X-Axis = Area

To do that, I would like to use the Results table, which I am getting after analysing a stack of images. Here is an example results table:

From this table, I want to get two plots of distribution, one for each slice number.

Do you recommend any macro code/functions, which would be best for this problem?


It’s fairly trivial to use the Plot Functions to make such a graph. There are loads of examples linked from the reference above.

If you can’t catch the values before they hit the results table (by loading them into an Array for example), you can always pull the results back out of the table using getResult.


I have decided to solve the problem, simply by analysing the stack of images, slice by slice, and making the plot using Distribution Plotter available in BAR toolbox.

In the end, I have ended up with such a simple loop:

 n = nSlices;
 for (slice=1; slice<=n; slice++) {
 	 showProgress(slice, n);
     run("Analyze Particles...", "  show=Outlines display summarize slice");
     run("Distribution Plotter", "parameter=Area tabulate=[Number of values] automatic=Freedman-Diaconis bins=24"); // You have to firstly install
     run("Clear Results");