Skip to content

Break tied connected-component peaks toward the centroid#111

Open
dimitrivlachos wants to merge 2 commits into
mainfrom
tied_peaks
Open

Break tied connected-component peaks toward the centroid#111
dimitrivlachos wants to merge 2 commits into
mainfrom
tied_peaks

Conversation

@dimitrivlachos

Copy link
Copy Markdown
Collaborator

This PR changes how the spotfinder picks the peak pixel of a 3D
reflection when several pixels share the maximum intensity. The
deterministic tie-break added in #55 ordered candidates by z, then y,
then x, which is geometrically arbitrary and can land the peak in a far
corner of the spot. That inflates the peak-centroid distance and pushes
otherwise well-centred reflections over the max_peak_centroid_separation
filter, dropping them. This ports the upstream DIALS fix
(dials/dials#3198, for dials/dials#3014), which I raised against DIALS
after spotting the same issue here.

This is predicated on the upstream DIALS PR (dials/dials#3198) merging
first; waiting until that is approved and merged.

Changes:

  • Reworks Reflection3D::is_signal_preferred
    (spotfinder/connected_components/connected_components.cc) to break
    intensity ties toward the pixel nearest the centroid, comparing
    squared distances to avoid a per-pixel sqrt. Pixels equidistant from
    the centroid fall back to the previous z, y, x ordering, so the result
    stays fully deterministic regardless of signal iteration order.

  • Fetches the centre of mass once at the top of peak_centroid_distance
    and reuses it for both the tie-break and the final distance. The
    centroid was already computed there, so the common untied path does no
    extra work.

  • Adds the first spotfinder C++ test target under spotfinder/tests,
    wired into the build via add_subdirectory.
    test_connected_components covers the unique-maximum untied path and
    the tied case where the peak must resolve to the nearest-centroid
    pixel rather than the z, y, x-first corner. This is a first step
    toward the spotfinder unit-test suite tracked in Unit tests for spotfinder #95.

Closes #58.

When several pixels in a 3D reflection share the maximum intensity, the
peak was chosen by a fixed z, y, x ordering. That ordering is
geometrically arbitrary and can place the peak in a far corner of the
spot, inflating the peak-centroid distance and causing well-centred
reflections to be rejected by the max_peak_centroid_separation filter.

Break the tie in favour of the pixel nearest the centroid instead,
falling back to the existing z, y, x ordering only when distances are
exactly equal so the result stays deterministic. The centroid is already
computed in peak_centroid_distance(), so this adds no extra work on the
common untied path.

Ports the upstream DIALS fix (dials/dials#3198) and addresses #58.
Adds a test target under spotfinder/tests covering
peak_centroid_distance(): the unique-maximum untied path, and the tied
case where the peak must resolve to the pixel nearest the centroid
rather than the z, y, x-first corner.

Wires the first spotfinder C++ test target into the build, ready to grow
into the wider spotfinder unit-test suite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reevaluate tie-breaking logic for peak signal selection in 3D reflections

1 participant