Last active
December 9, 2016 16:10
-
-
Save petebankhead/34bfd59546cd8e6a46ecf0c600b5bf45 to your computer and use it in GitHub Desktop.
Simple script to assign metadata values to TMA cores according to row in QuPath
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
/** | |
* Simple script to assign metadata values to TMA cores according to row. | |
* | |
* @author Pete Bankhead | |
*/ | |
import qupath.lib.scripting.QP | |
// Define the metadata values required | |
def metadataKey = "Region" | |
def rowValues = [ | |
"Center", | |
"Center", | |
"Center", | |
"Margin", | |
"Margin", | |
"Margin" | |
] | |
// Get the grid & dimensions | |
def grid = QP.getCurrentHierarchy().getTMAGrid() | |
int h = grid.getGridHeight() | |
int w = grid.getGridWidth() | |
// Loop through entries | |
for (row in 0..h-1) { | |
if (row >= rowValues.size()) | |
break | |
for (col in 0..w-1) { | |
def core = grid.getTMACore(row, col) | |
core.putMetadataValue(metadataKey, rowValues[row]) | |
} | |
} | |
// Fire update | |
QP.fireHierarchyUpdate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment