Skip to content

Commit 231df68

Browse files
committed
work on masked NU refinement
1 parent be15378 commit 231df68

21 files changed

Lines changed: 844 additions & 251 deletions

doc/implementation_notes/pcg_priors.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,6 +2574,140 @@ the acceptable-looking outputs do not validate the prior.
25742574
evaluation itself (phase-randomized masked FSC) is unchanged and still
25752575
envfsc-only.
25762576

2577+
SOLVE-SUPPORT POLICY, ENVFSC COUPLING (2026-09-09, user-directed).
2578+
automsk=yes now implies envfsc=yes on BOTH backends; envfsc is derived
2579+
in `validate_parameter_consistency` (logged when it overrides an
2580+
explicit or defaulted envfsc=no) and mirrored by
2581+
`set_refine3D_envfsc_policy` in the abinitio3D stage config so the
2582+
refine3D command lines read truthfully. Per backend:
2583+
- PCG: under automsk=yes the density envelope constrains BOTH the
2584+
base/unfil solve and the ML-regularized replay once a prior
2585+
reconstruction exists (the first base pair bootstraps on the sphere
2586+
and seeds the replay support). The strategy no longer consults
2587+
l_envfsc for the base support (`l_base_support_constrained =
2588+
l_state_support`; `build_pcg_state_support` throws if the coupling
2589+
is bypassed). The FSC pair is reported support-constrained, so
2590+
`evaluate_halfmap_pair` skips the phase-randomized re-masking; the
2591+
automask artifact is still written for its other consumers. The
2592+
envfsc=no + automsk=yes split of the 2026-09-01 three-rule policy
2593+
(spherical base, envelope replay) is retired.
2594+
- Gridding: the same envelope generator (automask3D of the base-pair
2595+
average at envmsklp, same binwidth) is applied post hoc to the FSC
2596+
pair with the phase-randomized correction, and the corrected FSC
2597+
feeds add_invtausq2rho exactly as the constrained-pair FSC feeds the
2598+
PCG ML prior. This is the closest post-hoc counterpart of the
2599+
constrained estimate a gridding assembly can offer: the mask
2600+
cannot enter the estimator, so the correction is the honest
2601+
substitute, and it is what makes the two backends' FSC-0.143/0.5
2602+
numbers and their regularization strength comparable under
2603+
automsk=yes.
2604+
Residual, deliberate asymmetries between the backends: (i) the PCG
2605+
solve support is built from the lag-one reference while the post-hoc
2606+
gridding envelope (and the automask artifact on both) is built from
2607+
the current base-pair average -- one iteration of envelope lag,
2608+
generous mask, negligible; (ii) the shipped PCG halves carry the
2609+
envelope, the shipped gridding halves carry only the soft spherical
2610+
support at msk_crop (the support-provenance sidecar records which),
2611+
so downstream masking (postprocess envfsc, NU evidence background) is
2612+
post hoc on gridding and already-in-the-map on PCG. automsk=no is
2613+
unchanged on both: sphere throughout, envfsc as requested. The final
2614+
classical reconstruct3D that refine3D/refine3D_auto/refine3D_states
2615+
issue no longer forces automsk=no (2026-09-09, after a refine3D_auto
2616+
run showed the shipped PCG map solved on the sphere while every
2617+
iteration had used the envelope): automsk rides along, filt_mode=none
2618+
and nu_refine=no still make the shipped map classical.
2619+
2620+
NU EVIDENCE ENVELOPE UNDER THE DOUBLE SUPPORT (2026-09-09, user-directed).
2621+
The evidence envelope stays the mask controlling the NU filtering of
2622+
the volumes: it is the only envelope that excludes detergent (micelle
2623+
is best explained by the coarsest candidate, so its margin is null),
2624+
which the density envelope cannot do. What changes is how its null is
2625+
obtained, in two regimes keyed on how the base pair was solved:
2626+
- SPHERICAL base pair (gridding; PCG bootstrap without a lag-one
2627+
reference): the robust median + nu_msk_sig*MAD of the margin over the
2628+
observed support, unchanged in substance -- the generous sphere makes
2629+
solvent the majority population -- with the pre-existing >50%-signal
2630+
warning promoted to the validity verdict (l_null_majority).
2631+
- ENVELOPE-CONSTRAINED base pair (PCG under automsk=yes): the estimator
2632+
has removed the far solvent, so its margin is an exact zero spike
2633+
(with the envelope near half the sphere the median lands on it and
2634+
the MAD collapses, inflating the envelope), and the remaining support
2635+
is not a solvent-majority mixture either (with a tight envelope the
2636+
median lands in the signal and the envelope collapses to the best
2637+
ordered core while the >50% check stays quiet). The null is therefore
2638+
DESIGNATED by Euclidean geometry rather than estimated from a
2639+
mixture: automask3D now exposes its binary core and dilated
2640+
intermediates, and set_nu_evidence_null_shell takes the median/MAD on
2641+
the dilation ring (dilated minus core), restricted to voxels the base
2642+
support carries at full weight (its cosine skirt attenuates the
2643+
noise). Labels are free on the observed density envelope and fixed
2644+
solvent outside it (NU_ENVMASK_EXCLUDED_SCORE), nesting the evidence
2645+
envelope inside the density envelope. Validity is shell sufficiency
2646+
(NU_ENVMASK_MIN_NULL_VOX, NU_ENVMASK_MIN_NULL_FRAC of the domain);
2647+
the core-to-shell median margin is logged as the separation
2648+
diagnostic. The shell width IS binwidth, which used to be 1 layer in
2649+
refine3D/refine3D_auto (parameter default) and 7 layers in abinitio3D
2650+
(ENVMSKWIDTH_DEFAULT), i.e. a one-voxel shell and a far tighter PCG
2651+
solve support in refine3D. RESOLVED (2026-09-09, user-directed): the
2652+
density envelope dilation has a shared physical minimum,
2653+
ENVMSKWIDTH_A_MIN = 7.5 A (the former abinitio3D default of 7 layers
2654+
at 1.075 A/pixel), applied in validate_parameter_consistency whenever
2655+
the envelope is in use (l_envfsc) as binwidth = max(binwidth,
2656+
ceiling(7.5/smpd_crop)) at the sampling the envelope is built at (a
2657+
lower bound, review 2026-09-09), so the
2658+
same physical envelope comes out at every crop level and in every
2659+
program; abinitio3D no longer injects a layer count. The minimum
2660+
replaces the default only: an explicit binwidth wins in either
2661+
direction. Whether 7.5 A is more than a dataset needs is measured,
2662+
not argued: the skirt attenuates rather than includes (inside the PCG
2663+
estimator a weight-0.4 skirt voxel is density at 40%), so the
2664+
full-weight ring is the only clipping margin, and the NU evidence
2665+
reports how much of that ring it labels signal
2666+
(>>> NU DILATION RING OCCUPANCY): signal in the ring means the
2667+
dilation is capturing density, a null ring means it is pure margin
2668+
and binwidth can be tightened for that specimen.
2669+
In both regimes the density-term median/MAD follow the null set, and
2670+
if the null is invalid or the envelope is empty nonuniform_filter_state
2671+
arms the density envelope itself as the background
2672+
(source='density_envelope', logged as EVIDENCE FALLBACK). The PCG
2673+
callers hand the state support and l_base_support_constrained (in the
2674+
distributed bootstrap blend: constrained only if both contributions
2675+
were) to nonuniform_filter_state; gridding passes nothing and stays in
2676+
the spherical regime. The standalone nu_filt3D route sets no shell.
2677+
Also removed: the vestigial regeneration planner
2678+
(plan_state_postprocess / AMSK_FREQ / NU_ENVMASK_ACTION_*) -- the
2679+
envelope has always been regenerated every cycle from the live
2680+
evidence and the artifact has no in-workflow reader. Side-by-side
2681+
lines to compare: NU ENVELOPE OCCUPANCY, "Null model", "Null shell
2682+
voxels", "Core median margin" against "Null median margin", and
2683+
whether the background was armed from the evidence envelope or the
2684+
fallback.
2685+
2686+
CODE REVIEW RESPONSE (2026-09-09, automsk_yes_code_review.md). The
2687+
masked-FSC bias of a support-constrained PCG pair (P1) is acknowledged
2688+
and deliberately NOT corrected: a common window on both halves can
2689+
contribute correlated power, but the constraint is the point of the
2690+
estimator, and the policy is to REPORT what was done rather than to
2691+
hide it -- evaluate_halfmap_pair now names the mode on every
2692+
evaluation (>>> FSC MODE in the log and the resolution text: spherical
2693+
support / envelope post hoc with phase-randomized correction /
2694+
estimator-constrained without correction). pcg_mskfile (P1) is now
2695+
returned by build_pcg_state_support as the state support regardless of
2696+
automsk, so FSC mode, provenance sidecar and the NU null regime see a
2697+
constrained pair. set_nu_evidence_null_shell (P1) reads the four
2698+
volumes through get_rmat_ptr and allocates only the two packed masks,
2699+
and logs the requested geometry diagnostics per state (envelope/support
2700+
Dice, fraction of the current dilation ring retained at full weight of
2701+
the base support, shell voxels of ring). core/dilated (P2) are requested
2702+
from automask3D only on the constrained branch. The dilation minimum
2703+
(P2) uses ceiling. The public policies (P2: automasking, abinitio3D,
2704+
refine3D, refine3D_auto, reconstruct3D_pcg) are updated in the same
2705+
change, including the stale refine3D_policy claim that references are
2706+
multiplied by the NU envelope. Not done: reusing the gridding FSC
2707+
envelope in the NU consumer (ownership boundary; one automask3D per
2708+
state per iteration is the accepted cost). The review's validation
2709+
matrix (nine cases, peak RSS on a production box) is the user's to run.
2710+
25772711
msp1 STAGE-7 COLLAPSE ROOT CAUSE (2026-09-06, from the full log sets):
25782712
the external-init repeats (5_abinitio3D) ran next to the completed
25792713
healthy set (4_abinitio3D) of the same project. The legacy sigma
@@ -3339,6 +3473,12 @@ the acceptable-looking outputs do not validate the prior.
33393473
filt_mode=none (bootstrap_rec3D pass 1 forces filt_mode=none and
33403474
is unaffected). `pcg_mskfile` is likewise rejected on NU routes
33413475
(development escape hatch isolated to filt_mode=none).
3476+
[SUPERSEDED 2026-09-09: validate_nu_replay_request and the NU-route
3477+
rejection went with the dead-code removal; pcg_mskfile is accepted on
3478+
every PCG route and, since the 2026-09-09 review, reported as the
3479+
state support: build_pcg_state_support returns it with l_have=.true.
3480+
regardless of automsk, so the FSC mode, the support-provenance
3481+
sidecar and the NU evidence null regime all see a constrained pair.]
33423482
- P2 refine3D_auto envfsc: now a guarded (genuinely overridable)
33433483
default.
33443484
- P2 _pproc: PCG skips all post-hoc mask multiplication in

doc/policies/3D/abinitio3D_policy.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -404,17 +404,20 @@ static local-resolution field; an explicit `automsk=yes` request uses the
404404
NU-evidence envelope to fix its background to the coarsest candidate.
405405

406406
Because `abinitio3D` currently keeps gold-standard refinement disabled,
407-
`GOLD_STD_STAGE` is off and `envfsc` defaults to `no`. The advanced `envfsc`
408-
control is nevertheless independent of `automsk` and NU filtering. The
409-
controller forces `envfsc=no` before `ENVFSC_STAGE`, forces it off for the cavgs
410-
route, and forwards the requested value at and after that boundary. With
411-
`envfsc=yes`, volume assembly generates a density envelope from the current
412-
merged half maps for phase-randomized FSC correction and cFAR, using
413-
`envmsklp` as its smoothing low-pass. The controller forwards `envmsklp` to
414-
staged and final reconstruction commands; its default is
415-
`ENVMSKLP_DEFAULT` (20 A). The density-mask growth width defaults to
416-
`ENVMSKWIDTH_DEFAULT` (7 voxels) through `binwidth` and is likewise preserved
417-
in staged and final reconstruction commands. The controller keeps a scheduled
407+
`GOLD_STD_STAGE` is off and `envfsc` defaults to `no`. `automsk=yes` implies
408+
`envfsc=yes` (policy 2026-09-09), so the two engage together at
409+
`AUTOMSK_STAGE`/`ENVFSC_STAGE`; the controller forces `envfsc=no` before
410+
`ENVFSC_STAGE`, forces it off for the cavgs route, and forwards the requested
411+
or implied value at and after that boundary. With `envfsc=yes`, volume
412+
assembly generates a density envelope from the current merged half maps for
413+
phase-randomized FSC correction and cFAR on gridding, and the PCG backend uses
414+
the same envelope as the support of both solves, using `envmsklp` as its
415+
smoothing low-pass. The controller forwards `envmsklp` to staged and final
416+
reconstruction commands; its default is `ENVMSKLP_DEFAULT` (20 A). The
417+
density-mask dilation is no longer injected as a layer count: every program
418+
applies the shared physical minimum `ENVMSKWIDTH_A_MIN` (7.5 A) at the
419+
sampling the envelope is built at, so the envelope keeps the same physical
420+
width across the autoscaled stages. The controller keeps a scheduled
418421
`lp` on the refine3D command line. From `NU_FILTER_STAGE`, staged
419422
`nonuniform` is promoted to `nonuniform_lpset`, so the NU frontier can feed an
420423
explicit merged-reference LP-set matching run, bounded at the high-resolution

0 commit comments

Comments
 (0)