Skip to content

ENH: Add intensity modes (to01 | 0mean | none) to the LAMNr trainers. - #66

Merged
ntustison merged 1 commit into
mainfrom
IntensityModes
Sep 27, 2026
Merged

ntustison merged 1 commit into
mainfrom
IntensityModes

Conversation

@ntustison

Copy link
Copy Markdown
Member

Signed or absolute-valued inputs (decoded optical flow (u, v), CT in HU) were forced through a per-sample min-max, which destroys the sign, the u/v ratio and absolute scale. Default behavior ("to01") is unchanged.

Shared:

  • misc.ChannelNormalizer (moved out of the hybrid trainer): per-channel z-score / min-max with streaming float64 fit, sample (C, ...) and batch (B, C, ...) transforms, checkpoint-safe state. SignalNormalizer remains an alias.

Hybrid trainer:

  • Per-view "intensity" for image views; "0mean" fits a ChannelNormalizer on the training split, saves it in the checkpoint and exports reconstructions in original units. Rejected on tabular/signal1d views.

Glow 2D/3D trainers:

  • --intensity {to01,0mean,none} and --intensity-fit-batches. Non-to01 modes disable augmentation (flip, noise, clamp, ANTs spatial/intensity) and ImageDataset's per-image min-max; "0mean" fits per-view normalizers before ActNorm priming, saves them in the checkpoint, restores them on resume and refuses a resume with a different mode.
  • 2D trainer reads channels-first .npy/.pt arrays (C, H, W).
  • _build_args(argv=None) for testability.

ImageDataset:

  • normalize_intensity=True option (False skips iMath_normalize).
  • BUG: the no-augmentation path used Euler3DTransform for 2D images.

Inference tools:

  • lamnr_glow_tool_base refuses non-to01 checkpoints with a clear error until the tools apply the stored normalizers.

BUG: _prime_if_needed treated 2-channel 2D batches (B, 2, H, W) as channel-less 3D volumes; it now accepts spatial_dims and the sampling and preview call sites pass it.

Tests: tests/test_glow_intensity.py (normalizer forms, ImageDataset absolute intensities, .npy loading without augmentation, 2D end-to-end 0mean run with checkpoint/resume guard, 3D extract_view modes, priming, tool guard) and hybrid intensity tests.

Signed or absolute-valued inputs (decoded optical flow (u, v), CT in HU)
were forced through a per-sample min-max, which destroys the sign, the
u/v ratio and absolute scale. Default behavior ("to01") is unchanged.

Shared:
* misc.ChannelNormalizer (moved out of the hybrid trainer): per-channel
  z-score / min-max with streaming float64 fit, sample (C, ...) and
  batch (B, C, ...) transforms, checkpoint-safe state. SignalNormalizer
  remains an alias.

Hybrid trainer:
* Per-view "intensity" for image views; "0mean" fits a ChannelNormalizer
  on the training split, saves it in the checkpoint and exports
  reconstructions in original units. Rejected on tabular/signal1d views.

Glow 2D/3D trainers:
* --intensity {to01,0mean,none} and --intensity-fit-batches. Non-to01
  modes disable augmentation (flip, noise, clamp, ANTs spatial/intensity)
  and ImageDataset's per-image min-max; "0mean" fits per-view normalizers
  before ActNorm priming, saves them in the checkpoint, restores them on
  resume and refuses a resume with a different mode.
* 2D trainer reads channels-first .npy/.pt arrays (C, H, W).
* _build_args(argv=None) for testability.

ImageDataset:
* normalize_intensity=True option (False skips iMath_normalize).
* BUG: the no-augmentation path used Euler3DTransform for 2D images.

Inference tools:
* lamnr_glow_tool_base refuses non-to01 checkpoints with a clear error
  until the tools apply the stored normalizers.

BUG: _prime_if_needed treated 2-channel 2D batches (B, 2, H, W) as
channel-less 3D volumes; it now accepts spatial_dims and the sampling
and preview call sites pass it.

Tests: tests/test_glow_intensity.py (normalizer forms, ImageDataset
absolute intensities, .npy loading without augmentation, 2D end-to-end
0mean run with checkpoint/resume guard, 3D extract_view modes, priming,
tool guard) and hybrid intensity tests.
@ntustison
ntustison merged commit 8da9f2e into main Sep 27, 2026
3 checks passed
@ntustison
ntustison deleted the IntensityModes branch September 27, 2026 20:53
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