ess.reduce.live.roi.ROIFilter#

class ess.reduce.live.roi.ROIFilter(indices, norm=1.0, spatial_dims=None)[source]#

Filter for selecting a region of interest (ROI).

__init__(indices, norm=1.0, spatial_dims=None)[source]#

Create a new ROI filter.

Parameters:
  • indices (Variable | DataArray) – Variable with indices to filter. The indices facilitate selecting a 2-D ROI in a projection of a 3-D dataset. Typically the indices are given by a 2-D array. Each element in the array may correspond to a single index (when there is no projection) or a list of indices that were projected into an output pixel.

  • spatial_dims (tuple[str, ...] | None, default: None) – Dimensions of the detector that should be flattened when applying the filter. If None, defaults to indices.dims. For projections where indices represent a subset of the detector, this should be set to the full detector dimensions.

Methods

__init__(indices[, norm, spatial_dims])

Create a new ROI filter.

apply(data)

Apply the ROI filter to data.

set_roi_from_intervals(intervals)

Set the ROI from (typically 1 or 2) intervals.

set_roi_from_polygon(polygon)

Set the ROI from polygon vertices.

Attributes

spatial_dims

Dimensions that define the spatial extent of the ROI.

apply(data)[source]#

Apply the ROI filter to data.

The returned scale factor can be used to handle filtering via a projection, to take into account that fractions of source data point contribute to a data point in the projection.

Parameters:

data (TypeVar(T, DataArray, Variable)) – Data to filter.

Returns:

tuple[TypeVar(T, DataArray, Variable), Variable] – Filtered data and scale factor.

set_roi_from_intervals(intervals)[source]#

Set the ROI from (typically 1 or 2) intervals.

Return type:

None

set_roi_from_polygon(polygon)[source]#

Set the ROI from polygon vertices.

Parameters:

polygon (dict[str, Variable | Sequence[float]]) –

Polygon vertices as a dict mapping axis names to 1-D arrays of vertex positions. Must contain exactly two entries. Each entry can be either:

  • A scipp Variable for coordinate-based selection (uses named coordinates from the indices DataArray, with unit validation)

  • A sequence of floats for index-based selection (uses dimension indices as coordinates, no unit handling)

The two axes can independently use either mode.

Return type:

None

property spatial_dims: tuple[str, ...]#

Dimensions that define the spatial extent of the ROI.