edges.edge_strength
edges.edge_strength(
pcs,
valid,
res_um,
sigma_um=DEFAULT_SIGMA_UM,
erode_um=DEFAULT_ERODE_UM,
aggregate=DEFAULT_AGGREGATE,
)Gradient magnitude of whitened PCs, aggregated across PCs, per mm.
Each PC is Gaussian-smoothed (NaN-aware: filtered data divided by the filtered mask, which avoids a bias at the mask border), then its gradient magnitude (root of the summed squared derivatives over the three axes) is taken. The smoothing removes the blocky grid of the interpolated volume. The per-PC magnitudes are then aggregated across PCs: "median" keeps voxels where many PCs change together and "mean" averages them.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| pcs | np.ndarray | (AP, ML, DV, k) whitened PCs, e.g. load_whitened_pcs(...)["pcs"]. |
required |
| valid | np.ndarray | (AP, ML, DV) bool mask of voxels with data. | required |
| res_um | float | Voxel size, sets the sigma in voxels and the gradient spacing. | required |
| sigma_um | float | Gaussian sigma in um (0 = unsmoothed). | DEFAULT_SIGMA_UM |
| erode_um | float | Voxels this close to the mask border are dropped: their gradient is a mask artefact. | DEFAULT_ERODE_UM |
| aggregate | (median, mean) | How the per-PC gradient magnitudes are combined across PCs. | "median" |
Returns
| Name | Type | Description |
|---|---|---|
| np.ndarray | (AP, ML, DV) float32 edge strength (units: EDGES_UNITS [aggregate]), NaN outside the eroded mask. |