roi — Region of interest#
This module contains all the facilities related to the concept of region of interest (ROI), encapsulated in two main classes:
Module documentation#
Description of a region of interest.
- class hexsample.roi.Padding(top: int, right: int = None, bottom: int = None, left: int = None)[source]#
Padding on the outside of the region of trigger.
This is setup so that the padding can be initialized with a single argument, assuming that it is the same on all four sides, with two arguments (bottom = top and left = right), or with the padding different on all four sides.
Arguments#
- topint
Top-side padding in pixels.
- rightint
Right-side padding in pixels.
- bottomint
Bottom-side padding in pixels.
- leftint
Left-side padding in pixels.
- top: int#
- right: int = None#
- bottom: int = None#
- left: int = None#
- class hexsample.roi.RegionOfInterest(min_col: int, max_col: int, min_row: int, max_row: int, padding: Padding)[source]#
Class describing a region of interest (ROI).
A region of interest is the datum of the logical coorinates of its two extreme corners, in the order (min_col, max_col, min_row, max_row).
- min_col: int#
- max_col: int#
- min_row: int#
- max_row: int#
- shape() Tuple[int, int][source]#
Return the shape of the ROI.
Note that rows goes first and cols goes last—this is the shape that needs to be used to reshape the one-dimensional pha array so that it gets printed on the screen with the right size and orientation.
- at_border(chip_size: Tuple[int, int])[source]#
Return True if the ROI is on the border for a given chip_size.
We should consider making the chip size a class member, because it looks kind of awkward to pass it as an argument here.
- serial_readout_coordinates() Tuple[array, array][source]#
Return two one-dimensional arrays containing the column and row indexes, respectively, in order of serial readout of the ROI.
Example#
>>> col, row = RegionOfInterest(0, 4, 0, 3).serial_readout_coordinates() >>> print(col) >>> [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4] >>> print(row) >>> [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]
- serial_readout_indexes() array[source]#
Return a zero-indexed, two-dimensional array containing the serial readout index for each pixel in the ROI.
Example#
>>> print(RegionOfInterest(0, 4, 0, 3).serial_readout_indexes()) >>> [[ 0 1 2 3 4] [ 5 6 7 8 9] [10 11 12 13 14] [15 16 17 18 19]]
- rot_slice() Tuple[slice, slice][source]#
Return a pair of slice objects that can be used to address the ROT part of a numpy array representing, e.g., the pha values of a given event.
Note this operates in relative coordinates, i.e., native numpy indexing.