Skip to main content

alignment.align_histology

alignment.align_histology(
    channel_model,
    recorded,
    trace_xyz,
    *,
    pid='',
    feature_indices=None,
    cost=None,
    method='histology',
    dtw_penalty_scale='median',
    dtw_vertical_penalty=DTW_VERTICAL_PENALTY,
    dtw_horizontal_penalty=DTW_HORIZONTAL_PENALTY,
    min_overlap_fraction=MIN_OVERLAP_FRACTION,
    predicted_trace_std=None,
    progress=None,
)

Align a probe’s recorded channels to a histology trace.

Args: channel_model: :class:~ephysatlas.alignment.models.ChannelModel. recorded: [C, F] recorded channel features in feature units, row order (top first). trace_xyz: [L, 3] trace samples (m), top to bottom, usually already extended to the brain boundary with :func:~ephysatlas.alignment.geometry.extend_trace_to_brain. pid: Insertion id; its own channels are excluded from the model’s neighbours. feature_indices: Features the cost uses (all by default). cost: A precomputed [C_valid, L] cost to warp instead of the feature cost (the channel + unit variant passes its fused cost here). method: Label stored in the result. dtw_penalty_scale: "median" (penalties are fractions of the median cost, the published method) or "q10_q90" (of the 10-90% cost spread, for calibrated, row-relative costs). dtw_vertical_penalty, dtw_horizontal_penalty: Penalty fractions. min_overlap_fraction: Minimum covered fraction of the valid channels before falling back to a rigid shift. predicted_trace_std: [L, F] standardised predictions along the trace, if already computed (reused by the channel + unit variant). progress: progress(fraction, message) callback.

Returns: AlignmentResult: with cost_matrix / path, and in diagnostics the trace predictions (predicted_trace_std), the channel -> trace map (channel_to_trace), j_start / j_end, the warping total cost and whether the rigid fallback was used.