Repository navigation
Add edge fill options for Spliner's padding margin - #73
Merged
Merged
Conversation
Spliner pads each frame with a margin and fits the padded image. The margin is filled with a mirror image of the frame, so an emitter near the edge is fitted next to its own reflection, and defocused emitters within about a micron of the edge are often missed. On the 2016 SMLM challenge's astigmatic N1 movies the mirror finds 60% and 44% of the defocused emitters 450-900 nm from the edge (LD and HD). The new edge_fill parameter (ParametersSplinerSTD) offers two other fills, alongside the default 'mirror': - 'planar' fills the margin with a plane fitted to the nearby pixels, weighted by a Gaussian of background_sigma (first-order normalized convolution, PlanarBackground). - 'edge' copies the frame's outermost pixels straight out. With either, the background is estimated from the frame's own pixels only, and the margin stays in the fit with each pixel counting for 1/edge_fill_weight (default 30) of a real one. That weight goes in as a per-pixel variance through the C fitter's sCMOS term, which is now set before each frame (MultiFitter.setScmosTerm()). Leaving the margin out of the fit entirely made edge fits unstable. On the challenge's N1 movies both fills raise the Jaccard index by 0.03 to 0.036. On frames the size of the real Tubulin-A647-3D movie, with its background (about twice the frame median along one edge), they raise edge recall, but 'edge' adds false positives at the bright edge and 'planar' doesn't. With the analysis interleaved on one core, 'planar' takes 1.3 to 1.4 times as long per frame as the mirror on 64x64 and 320x256 pixel frames, and 'edge' costs nothing extra. The default is unchanged: on the Spliner test movie the default and an explicit 'mirror' give byte-identical localizations to master. The two fills reproduce the prototype they were tested as exactly (with fftw_estimate so the FFT plans are deterministic). The deconvolution finders only mirror. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
A new Spliner parameter, opt-in, for how the padding margin around each frame is filled.
mirrorstays the default.planaris a Gaussian-weighted plane (first-order normalized convolution, done with aMatchedFilterBank).edgecopies the outermost pixels straight out.MultiFitter.setScmosTerm(), a ctypes write, with no C changes).ParametersSplinerSTDhas the parameter. The deconvolution finders keep mirroring.Evidence
The 2016 SMLM challenge's AS-Exp N1 movies, Spliner alone, Jaccard:
mirror): N1.LD 0.9194, N1.HD 0.7345. On N1.LD it finds only 49-77% of the defocused emitters 450-900 nm from the edge (813 and 519 emitters on the two kinds of side).planar: 0.9542 and 0.7638.edge: 0.9540 and 0.7703.On 320 x 256 frames with a real cell's background (about twice the frame median along one edge):
planarkeeps the mirror's false positives at the bright edge (53 against 52 on N1.LD);edgeadds some (121).planarcosts 1.3-1.4x the mirror's time per frame, interleaved on one core.edgecosts nothing.Tests:
test_edge_fill.py(new): 6 passed. It covers:test_spliner.dax, the default and an explicitmirrorgive byte-identical localizations to master.fftw_estimate1).Merge Danger
Door: two-way
The parameter is opt-in, the default path gives byte-identical output, and there are no C or file-format changes.
Blast Radius: small
PeakFinderFitter.loadImage()andloadBackgroundEstimate()now pad throughpeak_finder.padImage(), andanalyzeImage()readspeak_finder.edge_fill. Every finder in the repository provides both.fitting.PeakFinderhas them (mirror unless the parameter is set), and so does the Spliner deconvolution finder, which gained them in this PR. A custom finder outside the repository that doesn't inherit fromfitting.PeakFinder, used withfitting.PeakFinderFitter, would need the same two additions.🤖 Generated with Claude Code