Save the tile number in the name

Hello,

I am using the following script to generate and save patches from annotations. However, the sequential number (i), it’s not enough since I can’t keep track of the patches.

for (annotation in getAnnotationObjects()) {
    roi = annotation.getROI()
    
    def request = RegionRequest.createInstance(imageData.getServerPath(), 
        1, roi)
    
    String tiletype = annotation.getPathClass()
    
    
    if (tiletype != null) {
    
        print(tiletype)
        
       
        String tilename = String.format("%s_%s_%f_%f_%d.png", final_name, tiletype, i)
    
        ImageWriterTools.writeImageRegion(server, request, path + "/" + tilename);
    
        print("wrote " + tilename)
    
        i++
        
    }

}

Is there anyway to get the tile number? For example, in this case, save the 3589 number.

imagem

kind regards