Variable: measurementTargetFilters
constmeasurementTargetFilters:object
Ready made filters for the measurement target selection configuration. The selection has two composable halves:
targetsFilter- a MeasurementTargetsFilter chooser deciding the cardinality (first vs all): firstPixelData, allPixelData and the raw first/all.targetPredicate- a MeasurementTargetPredicate deciding whether an individual candidate is eligible: isPixelData (the default), forModality and forId.
Splitting the decision keeps each half a simple function: the predicate
decides one candidate and the chooser decides how many, so the same
forModality('PT') predicate means "the first PT" under firstPixelData
and "every PT" under allPixelData.
The chooser receives the viewport's candidate display sets in viewport order and the MeasurementTargetOptions (the viewport and the tool configuration), and returns the subset to measure. A configured chooser's result is authoritative: when it returns no candidates, no statistics are computed or displayed for the viewport.
These are plain functions, defined here once rather than per tool, so they
can be composed or referenced externally - including from a customization
layer that generates the executable predicate with a closure (eg
forModality('PT')) instead of embedding logic in serialized config.
Example configurations:
import { measurementTargetFilters } from '@cornerstonejs/tools';
// Every display set containing pixel values (skips SEG etc) - this is the
// default for the ROI tools
toolGroup.addTool(CircleROITool.toolName, {
targetsFilter: measurementTargetFilters.allPixelData,
});
// CT statistics only - shows nothing on viewports without a CT
toolGroup.addTool(CircleROITool.toolName, {
targetsFilter: measurementTargetFilters.allPixelData,
targetPredicate: measurementTargetFilters.forModality('CT'),
});
// Just the first pixel-data display set
toolGroup.addTool(CircleROITool.toolName, {
targetsFilter: measurementTargetFilters.firstPixelData,
});
// The first PT display set only
toolGroup.addTool(CircleROITool.toolName, {
targetsFilter: measurementTargetFilters.firstPixelData,
targetPredicate: measurementTargetFilters.forModality('PT'),
});
Type declaration
all
allPixelData
allPixelData:
MeasurementTargetsFilter
first
first:
MeasurementTargetsFilter
firstPixelData
firstPixelData:
MeasurementTargetsFilter
forId()
forId: (
id) =>MeasurementTargetPredicate
Creates a MeasurementTargetPredicate keeping the display sets
referencing the given display set, volume or image id. This is a substring
match, so partial identifiers such as a series UID contained in the id may
also be used. Configure it as targetPredicate.
Parameters
• id: string
Returns
forModality()
forModality: (...
modalities) =>MeasurementTargetPredicate
Creates a MeasurementTargetPredicate keeping the display sets whose
modality is one of the given modalities, eg forModality('PT') or
forModality('CT', 'PT'). Candidates with an unknown display set/modality
are excluded. Configure it as targetPredicate; combine with the
firstPixelData/allPixelData chooser to take the first or all matches.
Parameters
• ...modalities: string[]
Returns
isPixelData
isPixelData:
MeasurementTargetPredicate