12.4. openwfs.processors

class CropProcessor(source, shape=None, pos=None, padding_value=0.0, multi_threaded=False)[source]

Bases: Processor

Processor to crop data from the source to some region of interest.

Works on any number of dimensions. If the cropped area extends beyond the size of the source data, the data is padded with ‘padding_value’

property data_shape: tuple

This default implementation returns the data shape of the first source.

property pos: tuple

Start (‘top-left’ corner) of the cropped region.

class MultipleRoi(source, rois, multi_threaded=True)[source]

Bases: Processor

Processor that averages signals over multiple regions of interest (ROIs).

property data_shape

This default implementation returns the data shape of the first source.

property pixel_size: None

Returns None, since the elements in the output of the MultipleRoi processor do not have a physical size.

class Roi(pos, radius=0.1, mask_type='disk', waist=None, source_shape=None)[source]

Bases: object

Represents a Region of Interest (ROI) to compute a (weighted) average over.

This class defines an ROI with specified properties such as coordinates, radius, mask type, and parameters specific to the mask type.

apply(image, order=1.0)[source]

Applies the mask to the frame data by computing the weighted average. Optionally, the image data can be raised to a power before the mask is applied. This is useful for simulating multi-photon excitation, or for computing weighted contrast over the mask.

Parameters:
  • image (np.ndarray) – The source image data.

  • order (float) – The order of the mask. Default is 1.0.

property mask_type: str
property pos: tuple[int, int]
property radius: float
property waist: float
property x: int

x-coordinate of the center of the ROI, relative to the center of the image.

property y: int

y-coordinate of the center of the ROI, relative to the center of the image.

class SingleRoi(source, pos=None, radius=0.1, mask_type='disk', waist=0.5, multi_threaded=True)[source]

Bases: MultipleRoi

class TransformProcessor(source, transform=None, data_shape=None, pixel_size=None, multi_threaded=True)[source]

Bases: Processor

Performs a 2-D transform of the input data (including shifting, padding, cropping, resampling).

By default, the output shape and pixel_size are the same as the input shape. If desired, explicit values can be provided for the output shape and pixel_size. The unit of the pixel_size should match the unit of the input data after applying the transform.

property data_shape

This default implementation returns the data shape of the first source.

property pixel_size: Quantity | None

This default implementation returns the pixel size of the first source.

select_roi(source, mask_type)[source]

Opens a window that allows the user to select a region of interest.