Commit 6eaf90d
Parameter optimization for phase and fluorescence reconstructions (mehta-lab#525)
* Add model-level reconstruct() convenience functions
Each physics model (phase_thick_3d, isotropic_thin_3d,
isotropic_fluorescent_thick_3d, isotropic_fluorescent_thin_3d,
inplane_oriented_thick_pol3d) gets a reconstruct() function
that chains generate_test_phantom + calculate_transfer_function +
apply_transfer_function + apply_inverse_transfer_function.
* Add per-model API layer (waveorder.api)
Each physics model (birefringence, phase, fluorescence,
birefringence_and_phase) gets its own module with Settings,
simulate(), compute_transfer_function(),
apply_inverse_transfer_function(), and reconstruct().
All API functions accept/return xr.DataArray/Dataset.
Shared utilities in _settings.py and _utils.py.
* Refactor CLI to delegate to per-model API modules
CLI settings.py now re-exports from waveorder.api modules.
compute_transfer_function.py and apply_inverse_transfer_function.py
dispatch to birefringence, phase, fluorescence, or
birefringence_and_phase API functions. Removes apply_inverse_models.py.
* Add CLI simulate, view, and download commands
New commands: wo sim, wo view, wo download-examples.
Adds AliasGroup for short aliases (rec, sim, dle, gui).
Updates main.py help formatting. Adds wo entry point.
* Add API and CLI examples
6 API examples (birefringence, birefringence_and_phase, phase_2d,
phase_3d, fluorescence_2d, fluorescence_3d) and matching CLI
shell scripts with YAML config files.
* Update tests for new API architecture
Rewrite API tests to use per-model imports. Update channel names
(BF -> Transmittance, Pol -> Depolarization). Add parametrized
example runner tests for API and CLI examples.
* Update model examples and configs README
Align model example parameters (4-State scheme, yx_pixel_size=0.1,
z_position_list sign convention). Update configs README.
* Update internal callers to use API transfer function settings
Replace BirefringenceTransferFunctionSettings,
PhaseTransferFunctionSettings, FluorescenceTransferFunctionSettings
with direct imports from waveorder.api modules in plugin,
calibration, and test code.
* Simplify API examples to only use the API
Remove model-level imports (torch, waveorder.models, waveorder.api._utils)
and comparison/verification code. Each example now shows only the API:
settings, simulate, compute_transfer_function,
apply_inverse_transfer_function, reconstruct, and print output.
* Simplify configs README
Replace outdated instructions, zenodo links, and TODO with a short note
that configs are auto-generated by test_generate_example_settings.
* Delete download-examples command
Remove download.py, its import/registration/alias in main.py,
and its reference in the view command docstring.
* Move view to end of help, add [v] alias
* Simplify test_examples.py with glob parametrization
Replace explicit file lists with glob("*.py") and glob("*.sh") so new
examples are picked up automatically.
* Consolidate duplicated _make_czyx test helpers into shared fixture
Replace 5 near-identical _make_czyx / _make_czyx_data / _make_czyx_xarray
helpers across test files with a single make_czyx factory fixture in
tests/conftest.py. Also remove duplicate test_position_list_from_shape_scale_offset
from cli tests (superset exists in api tests).
* Documented configs
* Move configs README and delete old configs directory
* Remove expensive contrast limit computation from CLI
* smaller arrays to relive test bottleneck
* Migrate to uv, ruff, and hatch (mehta-lab#523)
* Migrate build system from setuptools to hatchling + uv-dynamic-versioning
* Replace black/isort/autoflake with ruff config
* Apply ruff formatting to codebase
* Migrate CI workflows to uv
* Migrate ReadTheDocs to uv
* Update CONTRIBUTING.md for uv workflow
* Generate and commit uv.lock
* Fix trailing whitespace and missing newlines in non-Python files
* Add formatting commits to git-blame-ignore-revs
* Update install instructions across docs for uv and removed [all] extra
* Update install instructions and keep [all] extra for backward compatibility
[all] is now an alias for [visual] since dev/docs/test deps moved to
[dependency-groups] (PEP 735). Extras ([project.optional-dependencies])
are published to PyPI for end users; dependency groups are local-only
for contributors via uv sync --group <name>.
* Update uv.lock
* Use --only-group for minimal CI/RTD installs, add pre-commit to dev group
* Add waveorder/optim/ module with OptimizableFloat type, losses, logging, and optimizer loop
* Make optics differentiable: smooth pupil, tilted pupil on Ewald sphere, gradient-safe kernels
* Make models differentiable: remove in-place ops, accept tensor params, add pseudo-SVD and tilt
* Add OptimizableFloat and tilt fields to settings, split base vs optimizable settings classes
* Add optimize() to phase and fluorescence API modules
* Add CLI optimization support: OptimizationSettings, optimizable param detection, birefringence guard
* Add tensorboard dependency and update example configs with tilt fields
* Add optimization examples and tests
* add comment for using your own data
* Handle numpy input in generate_pupil for backwards compatibility
* Clean up steepness defaults: use 1e4 consistently, fix docstring
* Make tilt integration test check loss improvement instead of convergence tolerance
* iohub depend on pypi
* Reduce 3D midband_power_loss to scalar for optimizer
* Use optimized config path for reconstruction after optimization
* feat: Added to_device to be target cuda
Signed-off-by: Sricharan Reddy Varra <sricharan.varra@biohub.org>
* style: formatting
Signed-off-by: Sricharan Reddy Varra <sricharan.varra@biohub.org>
* Remove z_focus_offset="auto" option and auto-focus CLI code
* Fix 3D optimize loss reduction and parameter name unpacking in phase.py
Reduce per-slice (Z,) loss to scalar before backward pass, matching
fluorescence.py. Use split(".")[-1] for dotted parameter names.
* Revert device/CUDA changes and fix phase.py bugs
* Add numpy-style docstrings to public API functions
* Add 3D optimization integration tests for phase and fluorescence
* Apply missing api-refactor changes: rename validators, remove vector_transfer_function
* Fix generate_pupil callers to pass tensors instead of numpy arrays
* Remove '(or auto)' from z_focus_offset config comments
* bump iohub
* cleaner docs on pupil
* cleaner documentation of z_position_list and na_det
* enable tilt_angle_{zenith,azimuth} for phase_thick_3d
* remove unecessary branching logic
* remove parallel SVD paths...prefer one-shot SVD when available
* synchronize fluorescence and phase optimization loops
* simplify loss handling
* remove redundant _get helper
* clean resolution of optimizable floats
* clean and test optimization cli
* [o] -> (optimizable)
* document pupil steepness choice
---------
Signed-off-by: Sricharan Reddy Varra <sricharan.varra@biohub.org>
Co-authored-by: Sricharan Reddy Varra <sricharan.varra@biohub.org>1 parent 185d5dd commit 6eaf90d
39 files changed
Lines changed: 2167 additions & 231 deletions
File tree
- docs/examples
- cli/configs
- maintenance
- PTI_simulation
- QLIPP_simulation
- optimization
- tests
- cli_tests
- optim
- waveorder
- api
- cli
- models
- optim
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
337 | 338 | | |
338 | 339 | | |
339 | 340 | | |
340 | | - | |
| 341 | + | |
341 | 342 | | |
342 | 343 | | |
343 | 344 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
73 | | - | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
0 commit comments