Last active
March 19, 2021 19:54
-
-
Save petebankhead/3dd03008570ee3e4ae6c449aba209a5d to your computer and use it in GitHub Desktop.
Set a MeasurementMapper in QuPath v0.1.2 to control detection object display in a script
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
/** | |
* Set a MeasurementMapper in QuPath v0.2 to control the display in a script. | |
* | |
* Revised version of a script for v0.1.2. | |
* | |
* @author Pete Bankhead | |
*/ | |
import qupath.lib.gui.tools.MeasurementMapper | |
// Define the color map name | |
String colorMapName = 'Viridis' | |
// Load a color mapper | |
def colorMapper = MeasurementMapper.loadColorMappers().find {it.name == colorMapName} | |
// Define measurement name & display range | |
def name = "Nucleus: Circularity" // Set to null to reset | |
double minValue = 0.0 | |
double maxValue = 1.0 | |
// Request current viewer & objects | |
def viewer = getCurrentViewer() | |
def options = viewer.getOverlayOptions() | |
def detections = getDetectionObjects() | |
// Update the display | |
if (name) { | |
print String.format('Setting measurement map: %s (%.2f - %.2f)', name, minValue, maxValue) | |
def mapper = new MeasurementMapper(colorMapper, name, detections) | |
mapper.setDisplayMinValue(minValue) | |
mapper.setDisplayMaxValue(maxValue) | |
options.setMeasurementMapper(mapper) | |
} else { | |
print 'Resetting measurement map' | |
options.setMeasurementMapper(null) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment