Break tied connected-component peaks toward the centroid#111
Open
dimitrivlachos wants to merge 2 commits into
Open
Break tied connected-component peaks toward the centroid#111dimitrivlachos wants to merge 2 commits into
dimitrivlachos wants to merge 2 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_separationfilter, 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 breakintensity ties toward the pixel nearest the centroid, comparing
squared distances to avoid a per-pixel
sqrt. Pixels equidistant fromthe 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_distanceand 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_componentscovers the unique-maximum untied path andthe 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.