elektronn2.malis.malis_utils module¶
-
elektronn2.malis.malis_utils.
compute_V_rand_N2
(seg_true, seg_pred)[source]¶ Computes Rand index of
seg_pred
w.r.t.seg_true
. Small is better!!! The input arrays both contain label IDs and may be of arbitrary, but equal, shape.Pixels which are have ID in the true segmentation are not counted!
Parameters:
- seg_true: np.ndarray
- True segmentation, IDs
- seg_pred: np.ndarray
- Predicted segmentation
Returns: ri Return type: ???
-
elektronn2.malis.malis_utils.
mknhood2d
(radius=1)[source]¶ Makes nhood structures for some most used dense graphs
-
elektronn2.malis.malis_utils.
mknhood3d
(radius=1)[source]¶ Makes nhood structures for some most used dense graphs. The neighbourhood reference for the dense graph representation we use nhood(1,:) is a 3 vector that describe the node that conn(:,:,:,1) connects to so to use it: conn(23,12,42,3) is the edge between node [23 12 42] and [23 12 42]+nhood(3,:) See? It’s simple! nhood is just the offset vector that the edge corresponds to.
-
elektronn2.malis.malis_utils.
mknhood3d_aniso
(radiusxy=1, radiusxy_zminus1=1.8)[source]¶ Makes nhood structures for some most used dense graphs.
-
elektronn2.malis.malis_utils.
bmap_to_affgraph
(bmap, nhood)[source]¶ Construct an affinity graph from a boundary map
The spatial shape of the affinity graph is the same as of seg_gt. This means that some edges are are undefined and therefore treated as disconnected. If the offsets in nhood are positive, the edges with largest spatial index are undefined.
Parameters: - bmap (3d np.ndarray, int) – Volume of boundaries 0: object interior, 1: boundaries / ECS
- nhood (2d np.ndarray, int) – Neighbourhood pattern specifying the edges in the affinity graph Shape: (#edges, ndim) nhood[i] contains the displacement coordinates of edge i The number and order of edges is arbitrary
Returns: aff – Affinity graph of shape (#edges, x, y, z) 1: connected, 0: disconnected
Return type: 4d np.ndarray int32
-
elektronn2.malis.malis_utils.
seg_to_affgraph
(seg_gt, nhood)[source]¶ Construct an affinity graph from a segmentation (IDs)
Segments with ID 0 are regarded as disconnected The spatial shape of the affinity graph is the same as of seg_gt. This means that some edges are are undefined and therefore treated as disconnected. If the offsets in nhood are positive, the edges with largest spatial index are undefined.
Parameters: - seg_gt (3d np.ndarray, int (any precision)) – Volume of segmentation IDs
- nhood (2d np.ndarray, int) – Neighbourhood pattern specifying the edges in the affinity graph Shape: (#edges, ndim) nhood[i] contains the displacement coordinates of edge i The number and order of edges is arbitrary
Returns: aff – Affinity graph of shape (#edges, x, y, z) 1: connected, 0: disconnected
Return type: 4d np.ndarray int16
-
elektronn2.malis.malis_utils.
bmappred_to_affgraph
(pred, nhood)[source]¶ Construct an affinity graph from boundary predictions
Parameters: - pred (3d np.ndarray) – Volume of boundary predictions
- nhood (2d np.ndarray, int) – Neighbourhood pattern specifying the edges in the affinity graph Shape: (#edges, ndim) nhood[i] contains the displacement coordinates of edge i The number and order of edges is arbitrary
Returns: aff – Affinity graph of shape (#edges, x, y, z) 1: connected, 0: disconnected
Return type: 4d np.ndarray int16