Ghostbuster's operators in SIMPLE: report of the run¶
Run "wave_operators", 2026-10-23 to 2026-10-24, unattended on the Dell (Intel Core Ultra 9 285, 24 cores, no
GPU), against base 5111068bf. The plan is ghostbuster_operators.md beside this report; its section 8,
"Progress", holds the detail and the evidence of every phase. Paths of the evidence are under the run directory
/home/elmlundho/agent_runs/wave_operators; each phase's diff is review/phase_N.diff there. Nothing is
committed: the change is the working tree against the base.
What the run delivered¶
SIMPLE can now predict a particle image from a 3D electrostatic potential with wave optics, under four models (projection, first Born and Rytov on the Ewald paraboloid, and multislice), and has the exact, hand-written derivative of that prediction. It is built on SIMPLE's own machinery: the Kaiser-Bessel (KB) gather and scatter of the PCG (preconditioned conjugate gradients) reconstruction's padded lattice, SIMPLE's CTF, its particle read path, its PCG start solve, density and maximum-likelihood (ML) prior. specter, the package that contains Ghostbuster, served only as the oracle that wrote reference files; nothing in the repository calls it.
On top of the operators:
reconstruct3D_wave, a new shared-memory program, reconstructs half maps from a project with known poses and CTF under any of the four models, by nonlinear conjugate gradients from the flat PCG map.simulate_scatteringnow draws its images with the same operators, with corrected sign conventions and the defocus at the specimen midplane (section "simulate_scattering" below).
What it buys, on simulated data with a known answer:
- On a 300 A ribosome at 100 kV, where the Ewald curvature limits a flat map beyond 4.7 A, Rytov with the data's curvature sign raises the agreement with the truth between 3 and 2.4 A (the Fourier shell correlation, FSC, of the map against the truth) from 0.66 to 0.81; the wrong sign drops it to 0.21. specter's converged reconstruction reaches 0.83.
- On an ordinary protein at 300 kV all models agree, Rytov slightly ahead (0.762 against 0.733 between 3 and 2 A), level with specter.
- On a 469-atom Pt nanoparticle every map finds all 469 atoms; the wave models place them more accurately (0.029 to 0.030 A against 0.035 A) and repair part of the band near the particle's own curvature limit (about 1 A). specter's own multislice matches SIMPLE's over the last band (0.801 both).
Cost: a Rytov gradient pass costs 1.7 to 3 times a PCG accumulation; the ribosome's wave reconstruction took about 9 min against 1.5 min for PCG at 24 threads. Multislice costs about 3 s a particle on one core at box 160, which suits nanoparticle sets, not 100 000-particle cryo-EM sets.
Phase by phase¶
- Phase 0, oracle and conventions (
review/phase_0.diff: the plan only). specter installed in scratch and its tests for the parts SIMPLE reproduces passed (one oversampling-3 rounding failure, explained). The SIMPLE-to-specter convention table measured through RELION star files (blob positions within 0.02 pixel, CTF zeros within 0.0001 1/A). Reference cases and three ground-truth datasets (protein, ribosome, Pt nanoparticle) simulated by specter's multislice with their truth. Both findings aboutsimulate_scattering(inverted phase, exit-face defocus) confirmed with numbers. - Phase 1, foundations (
review/phase_1.diff). The plane gather and scatter moved fromreconstructor_pcgintopcg_latticewith the curvature; the reconstruction's observation-batch frame extracted from the PCG worker intosimple_matcher_ptcl_io; the wavelength and interaction constant given one home (simple_math_ctf); the CTF's phase made public (eval_phase); the Poisson sampler moved tosimple_rnd; the newwave_field(2D complex fields) andnlcg_solver(nonlinear conjugate gradients). PCG results byte-identical to the base. - Phase 2, the single-scatter operator (
review/phase_2.diff).wave_imaging(the 2D chain of one particle) andwave_projector(the operator over a particle set) for projection, first Born and Rytov, forward, linearisation and adjoint, threaded and reproducible; the fold of the scatter accumulator moved into the lattice. The parity campaign against specter, the oversampling measurement and the cost table. - Phase 3, the program (
review/phase_3.diff).reconstruct3D_waveend to end (keys, UI, router, commander, strategy and its objective); the PCG worker's accumulation of a state's half extracted for sharing;simulate_scattering's single-scatter models on the shared operator, its keys renamed and retired; the library test; the ground-truth comparison on the protein and the ribosome. - Phase 4, multislice (
review/phase_4.diff).wave_multisliceand the cube gather and scatter of the lattice;wave_model=multislicein the program;simulate_scattering's multislice on the shared operator andsimple_scattering_simulator.f90deleted; the ground truth on the nanoparticle with SINGLE's atom detection. - Phase 5, documentation and this report (
review/phase_5.diff). The wave-model policy (doc/policies/3D/wave_model_policy.md); the user-guide pagedoc/user_guide/reconstruct3D_wave.mdand the updated../../user_guide/simulate_scattering.mdand index; the new sub-suites indoc/policies/test_environment_policy.md;../../policies/3D/reconstruct3D_pcg_policy.mdpointed at the moved routines; the note ofsimulate_scattering's author, Ruben, updated; a particle count corrected in the plan's Phase 4 entry (2 000 Pt particles, 1 000 per half, not 1 000).
simulate_scattering: what changed, for its author¶
Ruben wrote simulate_scattering on 2026-10-23 (commit f4cac4773); this section is for him. Ruben, your
simulator was the starting point of the 2D wave engine; the run moved it onto the shared operator.
Your note ghostbuster_scattering_simulator.md carries the full account in a dated section; in short:
- The images were those of
-V. The propagatorexp(+i pi lambda d k^2)and the lensexp(+i chi)were both conjugated relative to Kirkland while the transmission wasexp(+i sigma V), so a positive potential came out bright at underfocus and the multiple-scattering terms were those of the negated potential. Against specter on the same potential and pose (Phase 0), the simulator's image ofVcorrelated with specter's image of-Vat 0.98 to 1.000 and with that ofVat -0.90 to -0.93. The absorption had the right sign. Kirkland's signs are now used throughout. - Defocus referred to the exit face, half a box below the midplane that SIMPLE's CTF fits and specter use (the best match was 48.6 to 51.4 A off for a 48 A half depth). It now refers to the midplane.
- Keys.
scattering_modelbecamewave_model(withprojectionandrytovadded),ewaldselects the curvature sign or, for multislice, the beam direction, andabsorptionis retired forfraca: with the object potential(sqrt(1 - alpha^2) + i alpha) Vthe weak-phase limit of every model is SIMPLE's CTF with amplitude contrastalpha, tested to1e-5, so they are one quantity. No aliases (release 4). - No real-space rotation. Every model samples the potential's transform on the PCG lattice; multislice
gathers the rotated spectrum cube from it. The data are made by the exact operator the reconstruction inverts.
rotvolhad not corrected the KB window's roll-off (8 to 10% weaker off the centre). - Lens and geometry. The lens is SIMPLE's CTF phase, with a phase plate acting on the scattered waves only; shifts and phase shifts of the orientation table now apply.
- Code and tests.
simple_scattering_simulator.f90and its tester are gone: the FFT buffers becamewave_field, the lens and detectorwave_imaging(detect_intensityholds your Poisson and Gaussian noise), multislicewave_multislice, the Poisson samplerpoisson_rnd. Your multislice limits (zero, constant real and constant absorptive potentials) are kept; the first-Born constant-potential check gave way to the weak-phase identity and to first Born being Rytov's linearisation, and the vacuum is tested for every model. New tests can see the sign and the defocus reference (a weak sheet 16 A downstream images atdf + 16 A, notdf - 16 A). The FFTW plans now use SIMPLE's one planner lock (the unnamed critical section).
The PDB route, the potential route, the dose and noise, the defaults and the outputs are as you made them. The program and its tests ran on Linux (Oracle Linux 8, gfortran 15) throughout this run.
Decisions taken under delegation¶
Each is recorded, with its reason, in the plan section named.
- The FFTW planner lock is the unnamed critical section, not a named one (section 4.2, Phase 1).
- The window helpers,
plane_locandrim_freeare module procedures ofpcg_lattice, not type-bound, to leaveflex_pcg_tunchanged (Phase 1). ewald_curvrefuses a paraboloid more than 0.49 padded voxel past the Nyquist sphere (Phase 1).- Rytov exponentiates at the exit face, as specter and the approximation's definition do (section 3.2, Phase 2); the midplane differed by 2 to 17%.
- A phase plate's shift leaves the unscattered beam alone,
T(0) = 1(section 3.2, Phase 2). - The wavelength stays SIMPLE's CTF value, shared by design (section 3.2, Phase 2).
- Oversampling stays 2 with no key; the wave operator keeps the PCG lattice's three-tap window, and the existing
key
winszserves a caller who wants seven taps (Phases 2 and 3). - specter's positive curvature sign is one voxel of defocus off the symmetric reference; SIMPLE keeps the symmetric one (section 3.1, Phase 2).
- The program's design details (section 3.6, Phase 3): the prior in volts carries
boxpd^3; the start is the base PCG solve shrunk by the ML prior in closed form, written beside the wave maps; the Wiener filter is undone per shell; the step subset is 5% of a half within 256 to 1000 particles; the repeated passes use the in-memory pass buffer;pcg_mskfileis the support key; halves fromensure_field_halves. ewalddefaults tonofor projection andnegotherwise; projection with a curvature and multislice without one are refused (Phases 3 and 4).wave_multisliceis a per-thread type run bywave_projectoras its fourth model, not a second extension of the lattice with its own batch frame (section 4.1, Phase 4); its constant isWAVE_MSLICE, since Fortran is case-insensitive andWAVE_MULTISLICEwould name the type.- The ground-truth sets render each particle from its rotated atoms, are normalised by the dose so the gain is exact, and ship SIMPLE's orientation table beside their star files; the ribosome set propagates unpadded (Phase 0).
- specter reconstructs Rytov with its surface sampling (its real-space rotation would have taken 8 to 33 h); for multislice its real-space rotation is the only mode (Phases 3 and 4).
- The ML prior is left as the plan fixes it, from the flat start pair, so that Phase 3's results stand (Phase 4); see "Open".
- This phase added
doc/policies/3D/reconstruct3D_pcg_policy.mdto the file table, since the routines it names moved in Phase 1 (the item Phase 1 left for Phase 5).
Deviations from the plan¶
- The lattice's accuracy is ten times the plan's estimate. Section 6 assumed about
1e-3; the three-tap window interpolates a section to 0.7 to 1% of the image contrast for content off the box centre (Phases 1 and 2). The parity tolerance was measured at zero curvature, where both packages are exact by another route (8.2e-3 of the image contrast, 1.3e-2 of a gradient), and the golden test's bound set at 1.25 times that; a seven-tap window brings the operator to 4e-5 to 9e-4. Far below any particle's noise. - specter at general poses under multislice. specter's multislice exists only with its real-space trilinear rotation, whose own error (12.6 to 19% against its surface sampling) bounds parity at general poses; parity was established at quarter turns (to 7e-5 and 2e-3) and the gradient's 30% difference traced to specter's real-space gradient (Phase 4).
- The orientation test's criterion is a factor of four between the wrong and the right sign, not ten: the two signs differ by only 2% at box 24 (Phase 4, recorded before relied on).
- The particle cache is not used (it is two-dimensional only); the pass buffer serves the repeated passes (section 4.3).
- The nanoparticle set's expectation ("multislice recovers atoms the linear map misplaces or misses") did not arise: at this dose every map finds every atom; the difference is in position error and in the band near the curvature limit (Phase 4).
simulate_scatteringkeptrotvolfor multislice between Phases 3 and 4, then lost it as planned.
Evidence against the baseline¶
- PCG unchanged. A fixed case (400 myoglobin particles,
reconstruct3D rec_backend=pcg, point groups c1 and d2, objectivesccandeuclid) gives byte-identical maps, FSC and sigma2 files against the base build after every phase (scratch/identity_p4.log, earlieridentity_*.log); the 6 000-particle protein set likewise at 24 threads (Phase 1).pcg_reconreports all 42 gate metrics identical; PCG's accumulation on the protein set took 6.85 s after the move against 6.72 s at the base, within the run-to-run spread of 0.5 s (scratch/timing_pcg/times.txt). - Suites.
unit_image(925 assertions),unit_reconstruction(440),unit_numerics(1365),lib_reconstruction(86),pcg_reconpass (scratch/suites_p4/). The fast gate passes 14 of 15 entries; the failure,unit_pftc_align2D3D's "a class tie draws one of the tied classes", is the base's own, identical on the base build (Phase 0).check_test_registry.pyandcheck_descr.pypass. No CTest entry added. - Thread identity. Every new parallel path is bitwise identical at 1, 11, 16 and 24 threads, each twice, in
the testers and in the program (
scratch/thread_identity_p3.log,scratch/thread_identity_p4.log). - Parity with specter (
scratch/keep/parity/): within the lattice's interpolation error for every model and sign (table in the plan's Phase 2 entry), and for multislice where specter's rotation is exact. - Ground truth (
scratch/keep/gt3/scores_*.json,scratch/keep/gt4/table_pt.md,atoms.txt): the numbers above; full tables in the plan's Phase 3 and Phase 4 entries.
Open for the maintainer¶
- The prior near the Ewald limit. The ML prior comes from the flat start pair's FSC, which collapses exactly
where the flat model fails, so it is strongest there. On the nanoparticle a ten times weaker prior (
tau=10) recovers most of that band (truth FSC 0.47 to 0.50 at 1.12 A against 0.18 to 0.20); rebuilding the prior from the wave pair under the present prior would not, since that pair's FSC is held near zero there. A prior from a weakly regularised first wave solve is the candidate. - The ribosome's last band stays 0.02 below specter's (0.810 against 0.833) while the half maps agree: an error common to both halves, in the observation preparation shared with PCG (edge taper at large delocalisation, background-based noise normalisation), outside this run's files.
- Noise normalisation and the scale link. The particles' background spread was 1.035 to 1.098 of the true noise on these sets, because the background carries delocalised signal; the nonlinear models' absolute scale depends on it. The fitted gain shows it.
- SIMPLE's wavelength is 3.4e-4 short of the exact relativistic value: about 0.1 rad of lens phase at Nyquist for 2 um defocus at 300 kV. It concerns the CTF as a whole.
- Star interchange (Phase 0):
export_relionwrites no poses or origins, and the star import and exports read RELION's origins in angstroms as pixels. Not touched by this run. objfundefaults toeuclid(SIMPLE's global default), soreconstruct3D_wavestops on a project that has no registered noise spectra unlessobjfun=ccis given; every run of this work passedcc. The user guide says so; whether the program should default tocc, as a reconstruction from imported poses usually needs, is the maintainer's choice (found in Phase 5, which changes no code).- The base's fast-gate failure in
unit_pftc_align2D3D(code of base commit0147279c4). - Integration (section 4.7 of the plan):
rec_backend=waveinreconstruct3Dandrefine3D, distributed execution, Ewald correction in the PCG and gridding backends, CTF and pose refinement.