Histograms from area lists in trakem

How I can recieve the histograms of only the areas defined with the brush tool in trakem?

I tried it with python scripting like this:

for layer in arealist.getLayerRange():
  area = arealist.getAreaAt(layer)
  if area is not None and not area.isEmpty():
    roi = ShapeRoi(area)
    patches = layer.getDisplayables(Patch)
    for patch in patches:
      imp = patch.getImagePlus()
      imp.setRoi(roi)
      ip = imp.getProcessor()
      Roihist = ip.getHistogram()

In principle it works, but seemingly it gives only the histogram of the roi’s rectangular bounding box, not the roi itself.

In ImageJ, you have to use the ImageProcessor setMask/getMask methods to be able to properly only process the inside of a non-rectangular ROI.

https://imagej.nih.gov/ij/developer/api/ij/process/ImageProcessor.html#getMask--

Then, create a new image from the ROI, mask out the outside or copy only the inside, then run the analysis on that.

That works, thank you!