-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added qupath script to rename and reclassify annotations
- renamed a script to make it more explicit
- Loading branch information
1 parent
f3a5d6d
commit 53cc03f
Showing
4 changed files
with
47 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[project] | ||
name = "cuisto" | ||
version = "2025.01.07" | ||
version = "2025.01.7" | ||
authors = [{ name = "Guillaume Le Goc", email = "[email protected]" }] | ||
description = "Quantification of objects in histological slices" | ||
readme = "README.md" | ||
|
36 changes: 36 additions & 0 deletions
36
scripts/qupath-utils/tools/renameAndReclassifyAnnotations.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* renameAndReclassifyAnnotations.groovy | ||
* | ||
* Set the name and classification of existing annotations based | ||
* on their actual name and classification. | ||
* Assumes the classification AND name is in the form "Name Hemisphere", | ||
* and does not contain blank spaces other than the one separating | ||
* the region name and the hemisphere. | ||
* Hemispheres can be renamed. | ||
* Note that this processes all existing annotations, so proceed with | ||
* caution. | ||
*/ | ||
|
||
// Parameters | ||
// Hesmishere names : [existing: new] | ||
def hemispheresMap = ["Ipsi": "Left", "Contra": "Right"] | ||
|
||
// Get all annotations objects | ||
def annotations = getAnnotationObjects() | ||
|
||
// Set classification based on the name | ||
for (annotation in annotations) { | ||
// split name on blank space | ||
oldNameParts = annotation.getName().split() | ||
// get region name which is the first part | ||
regionName = oldNameParts[0] | ||
// get hemisphere name which is the second part | ||
// and convert it to the new name | ||
hemisphereName = hemispheresMap[oldNameParts[1]] | ||
// build the new name as hemisphere: region | ||
newClassification = hemisphereName + ": " + regionName | ||
// set the new classification | ||
annotation.setPathClass(getPathClass(newClassification)) | ||
// set the name to the region name only | ||
annotation.setName(regionName) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* setNameAsClassification.groovy | ||
* | ||
* Set all annotations' names to their derived classification. | ||
* Useful to rename the annotations with the region name in the | ||
* case where the classification is in the form "Left: Region name". | ||
*/ | ||
|
||
getAnnotationObjects().findAll { | ||
it.setName(it.getClassifications()[-1])} |