Skip to content

Commit 53cc03f

Browse files
- added qupath script to rename and reclassify annotations
- renamed a script to make it more explicit
1 parent f3a5d6d commit 53cc03f

File tree

4 files changed

+47
-9
lines changed

4 files changed

+47
-9
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "cuisto"
3-
version = "2025.01.07"
3+
version = "2025.01.7"
44
authors = [{ name = "Guillaume Le Goc", email = "g.legoc@posteo.org" }]
55
description = "Quantification of objects in histological slices"
66
readme = "README.md"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* renameAndReclassifyAnnotations.groovy
3+
*
4+
* Set the name and classification of existing annotations based
5+
* on their actual name and classification.
6+
* Assumes the classification AND name is in the form "Name Hemisphere",
7+
* and does not contain blank spaces other than the one separating
8+
* the region name and the hemisphere.
9+
* Hemispheres can be renamed.
10+
* Note that this processes all existing annotations, so proceed with
11+
* caution.
12+
*/
13+
14+
// Parameters
15+
// Hesmishere names : [existing: new]
16+
def hemispheresMap = ["Ipsi": "Left", "Contra": "Right"]
17+
18+
// Get all annotations objects
19+
def annotations = getAnnotationObjects()
20+
21+
// Set classification based on the name
22+
for (annotation in annotations) {
23+
// split name on blank space
24+
oldNameParts = annotation.getName().split()
25+
// get region name which is the first part
26+
regionName = oldNameParts[0]
27+
// get hemisphere name which is the second part
28+
// and convert it to the new name
29+
hemisphereName = hemispheresMap[oldNameParts[1]]
30+
// build the new name as hemisphere: region
31+
newClassification = hemisphereName + ": " + regionName
32+
// set the new classification
33+
annotation.setPathClass(getPathClass(newClassification))
34+
// set the name to the region name only
35+
annotation.setName(regionName)
36+
}

scripts/qupath-utils/tools/setClassificationAsName.groovy

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* setNameAsClassification.groovy
3+
*
4+
* Set all annotations' names to their derived classification.
5+
* Useful to rename the annotations with the region name in the
6+
* case where the classification is in the form "Left: Region name".
7+
*/
8+
9+
getAnnotationObjects().findAll {
10+
it.setName(it.getClassifications()[-1])}

0 commit comments

Comments
 (0)