Skip to content

ROIs

ROIs define the image region used for analysis. Every quantitative analysis run is associated with an image, a channel, and an ROI id.

An ROI is defined in image pixel coordinates and is available across all channels of an AcqImage. Analysis still picks one channel per run. The same ROI can be reused for analysis on different channels.

AcqStore supports two ROI types:

  • Rectangular ROI (rectroi): used by all current analysis modules
  • Line-segment ROI (linesegmentroi): available in the API; not used by current kymograph analyses

Coordinates are pixel coordinates on the 2D image array (row, column / dim0, dim1). Rectangular stop coordinates are exclusive (numpy-style slicing).

See acqstore.acq_image.roi and the AcqImage API.

ROI identity

roi_id is the sole authoritative identity of an ROI within an AcqImage. Runtime lookup, editing, deletion, analysis association, saving, loading, and export all use roi_id.

name is free-form display and annotation text. It may be an empty string and multiple ROIs may have the same name. Changing a name does not change ROI identity. Code that saves, loads, or exports an ROI must preserve its name as data, but must not use the name to derive an identifier, key, path, relationship, or selection.

Create a rectangular ROI

With no bounds, the ROI covers the full image:

from acqstore.acq_image import AcqImage
from acqstore.sample_data import ensure_sample_file

acq = AcqImage(str(ensure_sample_file('kymograph-diameter')))

roi = acq.rois.create_rect_roi(
    name='full',  # display text only
    note='full-frame ROI',
)
print(roi.roi_id, roi.bounds)

Set explicit bounds

from acqstore.acq_image.roi import RectRoiBounds

bounds = RectRoiBounds(
    dim0_start=100,   # row start (inclusive)
    dim0_stop=2000,   # row stop (exclusive)
    dim1_start=40,    # column start
    dim1_stop=120,    # column stop
)
roi = acq.rois.create_rect_roi(bounds=bounds, name='vessel')
print(roi.roi_id, roi.bounds)

Edit bounds

acq.rois.edit_rect_roi(
    roi.roi_id,
    bounds=RectRoiBounds(
        dim0_start=100,
        dim0_stop=1800,
        dim1_start=50,
        dim1_stop=110,
    ),
    name='vessel-cropped',
)

List and select ROIs

print(acq.rois.get_roi_ids())
roi_id = acq.get_default_roi()  # first / default when present
channel = acq.get_default_channel()

Line ROIs

from acqstore.acq_image.roi import LineEndpoints

line = acq.rois.create_line_roi(
    endpoints=LineEndpoints(row0=10, col0=10, row1=10, col1=200),
    name='scan-line',
)

Current velocity, diameter, sum-intensity, and heart-rate analyses expect a rectangular ROI. Prefer create_rect_roi for analysis workflows.

Persist ROIs

acq.save()  # writes ROIs into <source>.json

Next