Skip to main content

Type Alias: MeasurementTargetsFilter()

MeasurementTargetsFilter: (candidates, options) => MeasurementTargetCandidate[]

A configurable chooser deciding which of the display sets shown in a viewport an annotation tool computes and displays statistics for. Set it on the tool configuration as targetsFilter, using one of the ready made measurementTargetFilters (eg targetsFilter: measurementTargetFilters.firstPixelData) or any function with the same signature.

The chooser receives the viewport's candidate display sets in viewport order (see MeasurementTargetCandidate) and the MeasurementTargetOptions, and returns the subset to measure - normally the input array narrowed (and, if wanted, reordered) with the standard array methods. A chooser is responsible only for the cardinality (first vs all); the eligibility of an individual candidate is delegated to the configured MeasurementTargetPredicate (targetPredicate), so the two decisions compose independently.

Every returned candidate becomes a measurement target: the first one is the primary target returned by getTargetId, and each of them has its statistics computed and displayed - even on a single fusion viewport where the other targets have not been computed elsewhere yet. Returning an empty array means no statistics are computed or displayed for the viewport.

See measurementTargetFilters for ready made choosers:

import { measurementTargetFilters } from '@cornerstonejs/tools';

// Every display set with pixel values (skips SEG etc) - the ROI tools'
// default
toolGroup.addTool(CircleROITool.toolName, {
targetsFilter: measurementTargetFilters.allPixelData,
});
// The first pixel-data display set only
toolGroup.addTool(CircleROITool.toolName, {
targetsFilter: measurementTargetFilters.firstPixelData,
});
// Only the PT of a fusion viewport, computed as the primary target
toolGroup.addTool(CircleROITool.toolName, {
targetsFilter: measurementTargetFilters.firstPixelData,
targetPredicate: measurementTargetFilters.forModality('PT'),
});

Parameters

candidates: MeasurementTargetCandidate[]

options: MeasurementTargetOptions

Returns

MeasurementTargetCandidate[]

Defined in

tools/src/types/IBaseTool.ts:162