Module: roi¶
This module declares Region Of Interest (ROI) types as extensions of pyqtgraph.ROI objects.
- Current ROI types are:
- line
- rectangle
- freehand
- rect_line
Example
>>> roi = makeROI('line', [[10, 10], [20, 15]])
>>> roi.plot()
>>> roi.copy()
>>> win2 = open_file()
>>> roi2 = win2.paste()
Todo
- Correct ROI line handles to be at center of pixel
Class: ROI_Base¶
-
class
flika.roi.ROI_Base(window, pts)¶ ROI_Base interface for all ROI types
Template class for common and abstract functions, connects window.closeEvent to pyqtgraph.ROI.delete, set the window.currentROI to self
-
colorDialog¶ dialog for selecting the color of the ROI and its trace
-
pts¶ array of XY values used to copy the ROI
-
linkedROIs¶ set of rois that act as one ROI
Note
- All ROI objects implement the following methods:
- getMask():
- returns the [2, N] array of mask coordinates
- getPoints():
- returns the [N, 2] points that make up the ROI
- draw_from_points(pts, finish=True):
- updates the point locations that make the ROI, used in linked ROIs
-
-
ROI_Base.getTrace(bounds=None)¶ Compute the average of the pixels within this ROI in its window
Returns: Average value within ROI mask, as an array. Cropped to bounds if specified
-
ROI_Base.plot()¶ Plot the ROI trace in a
TraceFigReturns: the trace window that the ROI was plotted to Return type: tracefig.TraceFig
-
ROI_Base.colorSelected(color)¶ Set the pen color of the ROI
Parameters: color (QtGui.QColor) – new color for the ROI
-
ROI_Base.delete()¶ Remove the ROI from its window, unlink all ROIs and delete the object
Class: ROI_line¶
Class: ROI_rectangle¶
-
class
flika.roi.ROI_rectangle(window, pos, size, resizable=True, **kargs)¶ ROI rectangle class for selecting a set width and height group of pixels on an image.
Extends from
ROI_Baseand pyqtgraph.ROI
-
ROI_rectangle.crop()¶ Create a new window of the image cropped to this ROI
Returns: cropped image Window Return type: window.Window
Class: ROI_rect_line¶
Functions¶
-
flika.roi.makeROI(kind, pts, window=None, color=None, **kargs)¶ Create an ROI object in window with the given points
Parameters: - kind (str) – one of [‘line’, ‘rectangle’, ‘freehand’, ‘rect_line’]
- pts ([N, 2] list of coords) – points used to draw the ROI, differs by kind
- window (window.Window) – window to draw the ROI in, or currentWindow if not specified
- color (QtGui.QColor) – pen color of the new ROI
- **kargs – additional arguments to pass to the ROI __init__ function
Returns: ROI Object extending ROI_Base