TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Rubick65/dcemapper/llms.txt
Use this file to discover all available pages before exploring further.
src.roi module provides functions to build and manipulate 3D binary masks used to restrict quantitative analysis to a specific region of interest. All functions accept and return the same full_mask array (shape (X, Y, Z), float values in [0, 1]), making them easy to chain. Each function modifies a single Z slice while leaving other slices untouched, and applies smoothing at slice boundaries to reduce hard-edge artifacts.
update_rectangular_mask(roi_coords, full_mask, z_index)
Sets a rectangular region of a single slice to 1.0, then applies a gentle Gaussian blur (sigma=0.5) to smooth the mask edges. The result is combined with the existing mask using an element-wise minimum so that previously excluded voxels cannot be re-included.
Bounding box defined as
(x1, y1, x2, y2) in pixel coordinates. Values are floored to integers and clipped to the array bounds automatically. The order of x1/x2 and y1/y2 does not matter; the function sorts them internally.3D float mask array of shape
(X, Y, Z) with values in [0, 1]. Pass np.ones((X, Y, Z)) to start with a full-volume mask.Index of the axial slice to update.
numpy.ndarray — the updated full_mask (modified in-place and also returned).
update_elliptical_mask(full_mask, ellipsis_center, radius, z_index)
Paints an elliptical region on a single slice using the analytic ellipse equation, then smooths the mask edge with a Gaussian blur (sigma=1.0). Like the rectangular variant, the result is combined with the existing slice via element-wise minimum.
3D float mask array of shape
(X, Y, Z).(xc, yc) — pixel coordinates of the ellipse centre.(a, b) — semi-axis lengths in the x and y directions respectively. Values are in pixels.Index of the axial slice to update.
numpy.ndarray — the updated full_mask.
update_polygon_mask(full_mask, polygon_coords, z_index)
Rasterises an arbitrary polygon onto a single slice using 4× supersampling for antialiasing. The high-resolution binary mask is created with skimage.draw.polygon, then downscaled back to the original slice dimensions using bilinear interpolation (skimage.transform.resize, order=1). The result is combined with the existing slice via element-wise minimum.
3D float mask array of shape
(X, Y, Z).Ordered list of
(x, y) vertex coordinates defining the polygon boundary. At least three vertices are required. The polygon is automatically closed.Index of the axial slice to update.
numpy.ndarray — the updated full_mask.
restar_mask(full_mask, z_index)
Resets a single slice of the mask back to all 1.0, effectively undoing any ROI drawn on that slice. This is the undo operation exposed in the GUI via Ctrl+Z.
3D float mask array of shape
(X, Y, Z).Index of the axial slice to reset.
numpy.ndarray — the updated full_mask with full_mask[:, :, z_index] set entirely to 1.0.
Chaining mask operations
All four functions share the same interface and return the modified array, so they can be chained naturally:All mask functions apply changes with
np.minimum, which means the mask can only be narrowed — a voxel set to 0 on a previous call cannot be restored to 1 except by calling restar_mask on the entire slice.