@Research_Associate @melvingelbard @petebankhead @iqmmug
hi everyone, these days I have made some reflections and I have come to these conclusions …
Starting from the beginning:

I created an annotation called PBZ (this is because the process should be performed on a megaannotation derived from a pixel classifier, so I created a rectangular one to simplify)

I then ran the following script (read the notes that describe each step)
// Select PBZ Annotation
selectObjectsByClassification("PBZ");
//Create Tiles and Delete PBZ Annotation
runPlugin('qupath.lib.algorithms.TilerPlugin', '{"tileSizeMicrons": 500.0, "trimToROI": true, "makeAnnotations": true, "removeParentAnnotation": true}');
//Set "Tile" class to tile
getAnnotationObjects().each{
it.setPathClass(getPathClass("Tile"))
}
//Positive cell detection and delete positive cell
selectObjectsByClassification("Tile");
runPlugin('qupath.imagej.detect.cells.PositiveCellDetection', '{"detectionImageBrightfield": "Hematoxylin OD", "requestedPixelSizeMicrons": 0.5, "backgroundRadiusMicrons": 8.0, "medianRadiusMicrons": 0.0, "sigmaMicrons": 1.5, "minAreaMicrons": 20.0, "maxAreaMicrons": 400.0, "threshold": 0.08, "maxBackground": 2.0, "watershedPostProcess": true, "excludeDAB": false, "cellExpansionMicrons": 2.0, "includeNuclei": true, "smoothBoundaries": true, "makeMeasurements": true, "thresholdCompartment": "Nucleus: DAB OD mean", "thresholdPositive1": 0.2, "thresholdPositive2": 0.4, "thresholdPositive3": 0.6000000000000001, "singleThreshold": true}');
selectObjectsByClassification("Positive");
clearSelectedObjects();
//Create vessel from Classifier (load it)
selectObjectsByClassification("Tile");
createAnnotationsFromPixelClassifier("vasi ignore", 100.0, 100000.0, "SPLIT")
//Expand Vessels+Remove interior creating Rings. Ring= vessel; Vessel=VesselCenter
vessels = getAnnotationObjects().findAll{it.getPathClass() == getPathClass("Vessel")}
vessels.eachWithIndex{v,i>
v.setName(i.toString())
}
selectObjectsByClassification("Vessel");
runPlugin('qupath.lib.plugins.objects.DilateAnnotationPlugin', '{"radiusMicrons": 20.0, "lineCap": "Round", "removeInterior": true, "constrainToParent": true}');
resolveHierarchy()
vessels.each{it.setPathClass(getPathClass("VesselCenter"))}
The result is the following:
I got the vases (Class VesselCenter) and the ring around them (Class Vessel), related by the same number, contained in the same Tile (Parent)
(Negative) cells respect the hierarchy
 At this point I should look for the ratio between the cell density of the ring and the cell density outside the ring.
Initially I asked you to use the density of the Tile, however it is underestimated as the Area of the tile also includes the area of vessels and vesselcenters.
I therefore thought of eliminating the sum of these areas from the area of the tile in the calculation of the formula (hoping that the areas of the rings do not cross too much, I should get a fairly precise estimate).
An alternative would be to merge (merging) vessel and vessel ceneter annotation, resolve hierarchy (because the annotation obtained, by default, has as Parent: Image, while I want it to be contained in the Tile), Make inverse and I get the yellow area of the figure (it would be very very very nice if it were possible, the calculations would certainly be more precise)
I kindly ask you to help me and create a script that:
a) calculate the cell density of the rings (Class Vessel) in mm2
Formula = Num Cell / Area Ring
b) Calculate the cell density of the yellow area (cell density/ (Area Tile  (Sum of Vessel and Vessel Centers areas))
c) VCO Ratio = Ring Cell density / Yellow Area Cell Density
VCO Ratio should be positioned in a new column at the VesselCenter row corresponding to the Vessel (Ring)
Thank you in advance, I cross my fingers