Measuring distribution of object diameters in different stripes using Sholl plugin

Dear all,

Please look at the attached images. I have some selections with circle selections as an output from the Sholl Analysis plugin (below is binary mask):

What I need is, for each circular selection I would like to get the “list of diameters” of white objects. ShollPoints already provide the coordinates with the beginnings of these white segments. The question is how to get ends, and how to calculate distance on the arc (or even pixel distance would be OK). One additional difficulty is that selections are in subpixel resolution.

One hack that can do work for me is getting all pixels along with the circular selection. Something like “straighten selection”, but working with circular selections.

I would know how to solve it in Python, but maybe some easy trick in ImageJ macro can do it?

Any ideas? Thanks a lot!

PS @tferr do you have any ideas or insight?

I guess there are multiple ways to tackle this. The “straighten selection” option sounds reasonable. However, shells are stored as area ROIs that cannot be straightened by default, so a way to ‘fool’ the straighten command would be to create a nick on the perimeter of each shell, effectively creating line-based ROIs. Here is a python example that exploits this hack to display all of the rasterized shells in a single image (smallest radius on top, largest at the bottom):

#@UIService uiService
from ij import IJ, ImagePlus
from ij.gui import Overlay, Roi
from ij.plugin import ImagesToStack, Straightener

def error():
  uiService.showDialog("No 'shell' ROIs found in frontmost image.\
  Make sure image has '2D Sholl Shells' in its overlay.")

shell_width = 10
imp = IJ.getImage()
overlay = imp.getOverlay()
raster_shells = []

if imp and overlay:
  for i in range(overlay.size()):
    roi = overlay.get(i)
    if roi.getName() and "Shell" in roi.getName():
      imp.setRoi(roi), "Area to Line", "")
      raster = ImagePlus(roi.getName(), Straightener().straighten(imp, roi, shell_width))
  if raster_shells:
    holding_imp =, "Make Montage...", "columns=1 rows={} scale=1".format(holding_imp.getNSlices()))
    measurable_imp = IJ.getImage()
    measurable_imp.setTitle("Rasterized Shells")
    IJ.setAutoThreshold(measurable_imp, "Default dark");, "Analyze Particles...", "  show=[Overlay Masks] display clear overlay");

Each straightened row is separated from the next by a row of empty pixels so that each shell can be analyzed separately (e.g., using IJ’s Analyze Particles command, or some other alternative). This is how it looks like for the ddaC sample image:

1 Like

This is perfect. I really like how you use overlays to simplify things. I was always finding them little esoteric and confusing (I used ROIs and I kept complaining), but now I see the some advantages. Anyway, perfect with this I know how to get the distributions.

It is great that you posted the whole code here, I am sure it will help somebody to play with ROIs. :wink: