-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtma_save_to_all_core_png.groovy
36 lines (29 loc) · 1.09 KB
/
tma_save_to_all_core_png.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import qupath.lib.images.servers.ImageServer
import qupath.lib.objects.TMACoreObject
import qupath.lib.regions.RegionRequest
def imageData = getCurrentImageData()
def server = imageData.getServer()
def hierarchy = imageData.getHierarchy()
def tmaGrid = hierarchy.getTMAGrid()
// Check if TMA grid exists
if (tmaGrid == null) {
print "No TMA grid found!"
return
}
// Get all TMA cores
def tmaCores = tmaGrid.getTMACoreList()
// Set export parameters
def outputDir = "C:/Users/rakti/Downloads/qupath/annotation"
// Location Path Has to be Forward Slash
def imageExtension = ".png"
def downsample = 5.0 // Set to 1.0 for full resolution
// Export each core
tmaCores.each { core ->
def name = core.getName()
def region = RegionRequest.createInstance(server.getPath(), downsample, core.getROI())
def outputPath = new File(outputDir, name + imageExtension).getAbsolutePath()
// Export the image
writeImageRegion(server, region, outputPath)
print "Exported " + name + " to " + outputPath
}
print "Export complete! All cores have been exported. Please delete the ones you don't need."