Repository navigation
Conversation
Contributor
|
The next version of relion (5.2) has a faster version of amyloid finder. |
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.
The final result of
relion_amyloid_finder(before tracing) consists of two coarse 2D maps: PSI, containing the winning local orientation, and FOM, containing its relative angular-contrastscore.
For each sampled orientation and output location, it measures selected-bin 1D DFT power across a strip of parallel lines. The legacy implementation extracts every overlapping line window independently, computes a full FFT for each window, and stores the resulting signal and nonsignal powers in two dense full-resolution arrays, which are untouched until the last minute. A separate pass then aggregates those arrays across the filament width into coarse per-angle score maps.
This PR introduces two complementary optimizations:
Sliding narrowband DFT: For each image row, only the required signal and nonsignal frequency bins are computed for the first window. When the window moves by one pixel, those coefficients are updated by removing the departing pixel, adding the entering pixel, and applying a precomputed phase rotation. This avoids recomputing a complete FFT for every overlapping window.
Fused width aggregation: The implementation precomputes which coarse output cells receive each physical row’s score. As soon as the sampled signal and nonsignal powers for a row are calculated, they are accumulated into every affected coarse cell. No subsequent stage needs the individual row scores after this aggregation, so their storage can be discarded or reused immediately, where most memory footprint is saved. Thus, the dense scores_perline and nonscores_perline images never need to be materialized; only the much smaller coarse per-angle score maps proceed to the PSI/FOM calculation.
This PR doesn't touch the math and should be equivalent. However aggregating powers early will change the order of float ops, which is not commute. Thus, it is expected that the final result is not bit identical. The PSI winning directions align, and maximum FOM absolute error is 1.49e-8 during the test.
The code, benchmark scripts and validation scripts are generated with GPT-5.6-sol.
Benchmark
The benchmark runs on a machine with 32C/64T AMD Zen 2 @ 3.1GHz CPU, 32 GiB 2666 MHz DDR4 x2 dual channel memory. Motion corrected, binned micrographs with final size 5,760 x 4,092 from EMPIAR-12870 dataset are used in benchmark.
For a single micrograph,
For n micrographs, where n can be divided by MPI procs,