-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelaunay Clusters.groovy
More file actions
56 lines (46 loc) · 1.8 KB
/
Delaunay Clusters.groovy
File metadata and controls
56 lines (46 loc) · 1.8 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
clearCellMeasurements()
import qupath.lib.analysis.DelaunayTools
import static java.lang.Math.*
// Define cell variables
def cells = getCellObjects()
def tumourCells = cells.findAll { cell -> cell.getPathClass() == getPathClass("EGFP:mCher") }
// Set cluster parameters
double distanceMicrons = 25
double minClusterSize = 0
// Translate microns into pixels
def server = getCurrentServer()
def cal = server.getPixelCalibration()
def height = cal.getPixelHeight()
def distancePixels = distanceMicrons.div(height)
def numPixels = distancePixels.round(0)
// Define clusters
//def clusters = new DelaunayTools()
// .newBuilder(tumourCells)
// .calibration(cal)
// .centroids()
// .build()
//.getClusters(DelaunayTools.centroidDistancePredicate(numPixels, true) )
// Remove small clusters
//clusters.removeAll { it.size() < minClusterSize }
def subdivision = new DelaunayTools()
.newBuilder(tumourCells)
.calibration(cal)
.centroids()
.build()
def clusters = subdivision.getClusters(DelaunayTools.centroidDistancePredicate(numPixels, true) )
// Other code kept identical .............
def tumourAnnotation = DelaunayTools.createAnnotationsFromSubdivision(subdivision, null)
addObjects( tumourAnnotation )
// Classify clusters and count them
//def annotateClusters = new DelaunayTools().nameObjectsByCluster(clusters)
//def tumourAnnotation = new DelaunayTools.Subdivision().createAnnotationsFromSubdivision(clusters)
//
//def numClusters = clusters.size()
//println("Number of clusters: " + numClusters )
//getAnnotationObjects().each {
// it.getMeasurementList().putMeasurement("Number of Tumour Clusters", numClusters)
// }
//
// Finished
fireHierarchyUpdate()
println("Done!")