Repository navigation
v0.9.0a1 — repository-wide bug sweep (77 bugs)
Pre-releaseFirst pre-release of the 0.9 series. Repository-wide bug sweep: 77 bugs fixed across all seven modules, plus stale-code removal, simplification, and tooling changes. Test suite 401 → 791 passing.
Shipped as an alpha rather than 0.9.0 final: several fixes change previously-returned numbers, ~24 public symbols are gone, and two correctness questions in the single-image FRC/FSC split are still open (see Known issues). pip install cubic continues to resolve 0.8.0 until 0.9.0 ships.
Highlights
- Silently-wrong results fixed. The worst class in the sweep: functions that returned plausible numbers instead of failing, so no test caught them.
morphology_correlationsread true-vs-true entries and never touched the prediction (identical inputs scored 0.921 instead of 1.0). Sectioned FSC reported 0.1225 µm at 0.13 µm sampling — below the physical floor. Every binomial FRC returned NaN.ms_ssimwrappeduint8arithmetic mod 256. Empty GLCM directions were averaged in as zeros, flipping a texture correlation's sign. - Even-shaped PSFs in
create_backprojectorwere wrong two independent ways: centered grids used(S-1)/2whereifftshiftputsS//2at DC (non-Hermitian mask,np.realdiscarding a large imaginary part), andf[::-1]mapsj → -j-1on even axes so the flipped PSF was not the conjugate OTF. Imaginary leakage 5.32e-1 → 1.46e-17. Odd shapes stay bit-identical to the reference. - Code that had never worked:
five_crop_resolution/grid_crop_resolutionraisedIndexErrorunconditionally;Image.to_cpu()and cross-deviceto_same_devicerejected CuPy input;remove_touching_objectsfailed on every GPU and every 2-D array; the skimage proxy had no host fallback. - Input mutation.
richardson_lucy_xpdidimage *= mask, andimg_as_floatreturns the same object for float input, so it destroyed the caller's array. Same class of bug in five other functions. - Performance, all byte-identical:
remove_touching_objects426× (5.0 s → 0.012 s),find_objects165×, mesh extraction 11×, GLCM peak GPU pool 7.5× smaller (3.95 GB → 0.53 GB at 256³).
Resolution metrics
- Sectioned FSC now projects a sector's shell radius onto Z rather than reporting it as an axial period, and uses the Koho et al. (2019) eq. (5) correction on isotropically resampled input. Reproduces the paper's Fig. 4b pollen stack at XY 0.586 µm / Z 4.38 µm against a published 0.59 / 3.91.
- New
axial_floor_factor(default 2.0) reportszasnanwhen the result falls below the pre-resampling axial Nyquist limit. - The one-image checkerboard calibration factor is clamped at 1.0. The Koho fit is an exponential centred on 0.98 that passes 1.0 at a crossing of ~0.925 and reaches 1.82 at the band edge, so a near-Nyquist crossing was reported up to 45% below the sampling limit — in both directions, and
xyhas no floor guard of its own. spacing=Nonenow means cycles-per-pixel consistently betweenradial_edgesandradial_bin_id; previously it clipped every non-DC voxel into the last bin.ssimgainsnormalize, which it had silently ignored whilepsnrandnrmsehonoured it.
Breaking changes
This is not a patch release. ~24 removed public symbols, 13 signatures with a parameter removed, mask now keyword-only on pcc/nrmse/psnr/ssim, extract_features returning three values, clahe(kernel_size→n_tiles), and ~14 inputs that were previously accepted and now raise. The cubic.metrics.frc shims are gone.
Fixes that change previously-returned numbers — re-running an analysis will not reproduce prior values:
remove_thin_objectschangedsize_z <= min_zto< min_z, matching its docstring.min_zis defaulted, so every existing caller changes: atmin_z=2, objects spanning 1/2/3/4 Z planes went from keeping{3,4}to keeping{2,3,4}.band_limited_pcc,band_limited_ssimandspectral_pccreturnnanfor degenerate input, matchingpcc.clear_xy_bordersno longer relabels in 3-D, socellpose_segmentids can be gapped where they used to be contiguous.get_true_featuresno longer derives feature ranges from the ground truth whenfeature_ranges is None— the old path normalized the true side but not the prediction.
Tooling
ruff selected only D and I, so pyflakes never ran and unused imports had accumulated; now ["D", "F", "I"]. rtree added to the mesh extra — extract_mesh_features raised ModuleNotFoundError for anyone following the documented install.
Known issues
- Single-image checkerboard split is optimistic. Against a synthetic known band limit, two-image FRC is accurate to 1–2% but the checkerboard split reads ~20% too fine, and it collapses once the true limit approaches the split halves' Nyquist — which is half the image's, since the halves are 2× coarser per axis. On interpolated input it is far worse: 0.68× after a subpixel shift, 0.35× after a Gaussian smooth, and no threshold crossing at all after 2× upsampling. The binomial split (
split_type="binomial") tracks the two-image reference to ~3% in all of those cases and is the better choice wherever photon counts are available; it is not reliable on deskewed/upsampled data either (0.40×). - Near-axis sectioned FSC does not decorrelate. With the default
disable_3d_sum=False,checkerboard_splitsums consecutive Z pairs before splitting in Y/X, so both halves share their Z content exactly and FSC on the purek_zline is identically 1.0.axial_floor_factorcatches the downstream symptom; the split geometry is the cause.
Numbers above were measured against scikit-image 0.26.0, while CI resolves 0.25.2. The library handles both, but DCR curve shapes differ enough between them that one test asserts a version-independent invariant instead of a fixture-specific value.
Install
pip install cubic==0.9.0a1Full changelog: v0.8.0...v0.9.0a1