# Convert Annotation Tiles to Detection with new parameters

Hi all, I need a hand in writing a script for QuPath 0.2.3.
This is my situation:

I have a certain number of Annotation Tiles, in each Tile there are detections.
I would like to transform each Tiles into a detection in order to observe some new parameters in the Measurements Map.

This is the annotations table

This is the detections table

These are the parameters that I would like to calculate for each tile (they therefore refer to the detections contained in each tile. I have almost all the variables used in the formulas, the only variables that are still to be calculated are the Sums):
Tile Density /mm^2 (giĂ  presente);

Total VD=Num Detections/Area Âµm^2*1000000; (itâ€™s already present in the annotation table, I would like to be able to see it also in the detection table once the tiles are converted to detections)

ibcVD=Num irregular big coopted/Area Âµm^2*1000000;

ibuVD=Num irregular big uncoopted/Area Âµm^2*1000000;

ibVD=ibcVD+ibuVD;

rbcVD= Num regular big coopted/Area Âµm^2*1000000;

rbuVD= Num regular big uncoopted/Area Âµm^2*1000000;

rbVD= rbcVD+rbuVD;

scVD=Num small coopted/Area Âµm^2*1000000;

suVD=Num small uncoopted/Area Âµm^2*1000000;

sVD=scVD+suVD;

ibcVA= Sum of â€śirregular big cooptedâ€ť detections areas;

ibcVA percentage= ibcVA /Area Âµm^2*10000;

ibuVA= Sum of â€śirregular big uncooptedâ€ť detections areas;

ibuVA percentage=ibuVA /Area Âµm^2*10000;

ibVA=ibuVA+ibcVA;

ibVA percentage=ibVA /Area Âµm^2*10000;

rbcVA=Sum of â€śregular big cooptedâ€ť detections areas;

rbcVA percentage=rbcVA /Area Âµm^2*10000;

rbuVA=Sum of â€śregular big uncooptedâ€ť detections areas;

rbuVA percentage=rbuVA /Area Âµm^2*10000;

rbVA=rbuVA+rbcVA;

rbVA percentage=rbVA/Area Âµm^2*10000;

bVA=rbVA+ibVA;

bVA percentage=bVA/Area Âµm^2*10000;

scVA=Sum of â€śsmall cooptedâ€ť detections areas;

scVA percentage=scVA/Area Âµm^2*10000;

suVA=Sum of â€śsmall uncooptedâ€ť detections areas;

suVA percentage=suVA/Area Âµm^2*10000;

sVA=scVA+suVA;

sVA percentage=sVA/Area Âµm^2*10000;

Total VA=(sVA+bVA);

Total VA percentage=(sVA percentage+bVA percentage);

total VCO mean (mean of â€śVCOâ€ť parameter of all detection classes, so i think itâ€™sâ€¦) = sum of VCO(of that tile)/Num Detections);

rbVCO mean=(sum of VCO of â€śregular big cooptedâ€ť detections+ sum of VCO of â€śregular big uncooptedâ€ť detections)/(Num regular big coopted+Num regular big uncoopted);

ibVCO mean=(sum of VCO of â€śirregular big cooptedâ€ť detections+ sum of VCO of â€śirregular big uncooptedâ€ť detections)/(Num irregular big coopted+Num irregular big uncoopted);

bVCO mean=(sum of VCO of â€śirregular big cooptedâ€ť detections+sum of VCO of â€śirregular big uncooptedâ€ť detections+sum of VCO of â€śregular big uncoopted+sum of VCO of â€śregular big coopted)/(Num irregular big coopted+Num irregular big uncoopted+Num regular big uncoopted+Num regular big coopted);

sVCO mean=(sum of VCO of â€śsmall cooptedâ€ť detections+ sum of VCO of â€śsmall uncooptedâ€ť detections)/(Num small coopted+Num small uncoopted);

rbVCO percentage=Num regular big coopted/( Num regular big coopted+ Num regular big uncoopted)*100;

ibVCO percentage=Num irregular big coopted/( Num irregular big coopted+ Num irregular big uncoopted)*100;

bVCO percentage=(Num irregular big coopted+Num regular big coopted)/( Num irregular big coopted+ Num irregular big uncoopted+ Num regular big coopted+ Num regular big uncoopted)*100;

sVCO percentage=Num small coopted/(Num small coopted+ Num small uncoopted)*100;

total VCO percentage=(Num irregular big coopted+Num regular big coopted+Num small coopted)/Num detections*100;

So, in summary, I would like to be able to see all these parameters for each Tile converted to detection.
Knowing more or less the functionality of the program, it is possible that the detections inside the tiles will be deleted once the Tiles are converted to detection, but this is not important (although it would be nice to keep seeing them).
I know I am asking for a big effort, but I have to finish the project by November and i canâ€™t write the script

Not going to dig into object names or any other specific calculations, but making detections that are roughly the same as annotations can be done like this:

``````
detections = []
getAnnotationObjects().each{
detections << PathObjects.createDetectionObject(it.getROI(), it.getPathClass(), it.getMeasurementList())
}