Welcome to pipra’s documentation!¶
pipra is a smart tool for binary mask generation. It stores annotated mask in .mask files, which are basically HDF5 container that can be read easily with various tools, such as h5py, flammkuchen or MATLAB.
pipra is written in PyQt5 and uses pyqtgraph to show and interact with images. The following image provides an overview how the different classes inside pipra are arranged.
pipra relies on QMainWindow to open, save and export files, and interact with the menu bar and the status bar. The
PipraStack is a
QWidget that stores the image stack and the corresponding masks. It contains the slider to change the shown image and respective
mask in the
PipraImageView. To allow custom mouse events, such as drawing without moving the image or wheel-based image change,
PipraImageItem is introduced.
- class pipra.pipra.PipraImageItem(*args, **kwargs)¶
Custom pyqtgraph ImageItem to allow wheel and mouse events for dragging and drawing
allows dragging image and live painting
e (event) – Qt event
- wheelEvent(wh, ax=None)¶
Wheel event in image scene
wh (Wheel event) – Contains information about the wheel
ax (axis, optional) – Wheel axis. Defaults to None.
- class pipra.pipra.PipraImageView(im, mask=None, parent=None)¶
The drawing environment
im (numpy.ndarray) – The image to be masked
mask (numpy.ndarray, optional) – The binary mask for im, will be initialized as zeros when not provided. Defaults to None.
parent (QWidget, optional) – Used to show ImageView in parent QWidget. Defaults to None.
Generates binary mask
binary mask at current location
- Return type
Handling the main shortcuts
ev (QEvent) – Qt event
- keyReleaseEvent(self, QKeyEvent)¶
- mouseMoveEvent(self, QMouseEvent)¶
- mousePressEvent(self, QMouseEvent)¶
- mouseReleaseEvent(self, QMouseEvent)¶
forcePaint (bool, optional) – Force painting event to be executed. Defaults to False.
- setColor(colorCursor=None, colorMask=None, colorOthers=None, colorBlack=None)¶
Set color for cursor, mask, others and black. Colors need to be specified in RGBA (0…255).
colorCursor (tuple, optional) – Cursor color, default magenta. Defaults to None.
colorMask (tuple, optional) – Mask color, default green. Defaults to None.
colorOthers (tuple, optional) – Other color. Defaults to None.
colorBlack (tuple, optional) – Black color, default pitch black. Defaults to None.
- setZ(im, mask=None)¶
Show image at position z.
im (numpy.ndarray) – The image to be shown
mask (numpy.ndarray, optional) – If already a mask exists, otherwise it will be initialized with zeros. Defaults to None.
- class pipra.pipra.PipraMain¶
- close(self) → bool¶
- dragEnterEvent(self, QDragEnterEvent)¶
- dropEvent(self, QDropEvent)¶
Exporting segmentation masks as mp4 or tif file, or as single png files.
- class pipra.pipra.PipraStack(stack, mask=None, is_folder=False)¶
The PipraStack class carries the whole image stack and the respective masks. If it is a folder, it generates empty masks for each image.
stack (list or numpy.ndarray) – The image stack
mask (numpy.ndarray, optional) – The corresponding masks to the image stack. Defaults to None.
is_folder (bool, optional) – If the image stack is derived from a folder. Defaults to False.
Slot for a change in z or t along the image stack. Saves the current state and updates the image in the ImageView environment.
Saves the current mask and returns all masks.
- Return type
Shortcuts for efficient interaction with pipra.
key ([type]) – [description]
Change z or t signal depending on wheel direction
direction (int) – Wheel direction (up or down)
Main entry for pipra
- pipra.floodfill.floodfill(im, seed, time_it=False, tolerance=5, only_darker_px=True)¶
Floodfill with four neighbours, speed-enhanced using numba.
im (numpy.ndarray) – The input image
seed (tuple) – The (y,x) coordinates of the seeding pixel
time_it (bool, optional) – Times the floodfill procedure. Defaults to False.
tolerance (int, optional) – Intensity tolerance to seed intensity. Defaults to 5.
only_darker_px (bool, optional) – Floodfill for intensities [0, seed intensity + tolerance]. Defaults to True.
The floodfilled mask
- Return type
- pipra.grabcut.GrabCut(im, r, iterations=1)¶
GrabCut Algorithm for fast foreground annotation
im (numpy.ndarray) – The image data that should be analyzed
r (tuple) – The rectangle coordinates of foreground (x0, y0, x1, y1)
iterations (int, optional) – GrabCut iterations. Defaults to 1.
The estimated foreground mask from GrabCut
- Return type