Skip to content

feat(n4): GPU-accelerated N4 bias field correction#116

Open
FIrgolitsch wants to merge 3 commits intopr-3-slice-interpolationfrom
pr-n4-bias-field
Open

feat(n4): GPU-accelerated N4 bias field correction#116
FIrgolitsch wants to merge 3 commits intopr-3-slice-interpolationfrom
pr-n4-bias-field

Conversation

@FIrgolitsch
Copy link
Copy Markdown
Contributor

@FIrgolitsch FIrgolitsch commented Apr 30, 2026

Stacked PR 11/16 — review order: #115#97#98#99#100#101#108#106#107#87#116#110#111#40#112#113

Replaces #109 — that PR was permanently locked closed by GitHub (its base chain-merged had no common history). Recreated here on the proper base pr-3-slice-interpolation. Branch pr-n4-bias-field is unchanged.


PR #109 — N4 Bias Field Correction (CPU + GPU)

Adds N4 bias-field correction with CPU/GPU backends, replacing the previous z-intensity normalization.

Library

  • linumpy/intensity/bias_field.py — high-level API
  • linumpy/intensity/normalization.py — extended for N4 backend, plus fix(normalize): zero agarose per slice while preserving inter-slice brightness (per-slice subtraction of the agarose-median floor pins background voxels to exactly 0 in the normalized output, restoring pre-n4 visualization behavior; global divisor preserves the 2:1 inter-section brightness invariant)
  • linumpy/gpu/{bias_field,bspline,n4}.py — GPU kernels (CuPy)
  • Removes linumpy/gpu/normalization.py (superseded)

Scripts

  • scripts/linum_correct_bias_field.py — replaces linum_normalize_z_intensity
  • scripts/diagnostics/linum_benchmark_n4_gpu.py
  • scripts/diagnostics/linum_n4_gpu_visual_compare.py

Tests

  • linumpy/tests/test_bias_field*.py, test_gpu_{bspline,n4}.py
  • linumpy/tests/test_n4_gpu_{equivalency,perf}.py
  • Extended test_intensity_normalization.py with test_normalize_volume_agarose_floor_at_zero

Workflow integration

  • workflows/reconst_3d/soct_3d_reconst.nf: adds correct_bias_field process
  • workflows/reconst_3d/nextflow.config: N4 parameters

Build

  • pyproject.toml: entry-point swap (linum_normalize_z_intensitylinum_correct_bias_field), scipy-stubs/networkx-stubs dev deps, lint exemptions for linumpy/gpu/* and N4 diagnostic scripts

@FIrgolitsch FIrgolitsch force-pushed the pr-3-slice-interpolation branch from d941b23 to df76137 Compare April 30, 2026 03:21
@FIrgolitsch FIrgolitsch force-pushed the pr-3-slice-interpolation branch from df76137 to 247fcc0 Compare April 30, 2026 03:26
@FIrgolitsch FIrgolitsch force-pushed the pr-3-slice-interpolation branch from 247fcc0 to e7894cc Compare April 30, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant