Skip to content

fix(transforms): fix multichannel tile normalization when norm3D=False - #1508

Open
boomesh11 wants to merge 1 commit into
MouseLand:mainfrom
boomesh11:fix/multichannel-tile-norm
Open

boomesh11 wants to merge 1 commit into
MouseLand:mainfrom
boomesh11:fix/multichannel-tile-norm

Conversation

@boomesh11

Copy link
Copy Markdown

Summary

Fixes #1507.

In cellpose.transforms.normalize99_tile(), when norm3D=False and Lz > 1, line 293 previously assigned x01_rsz to x99[z] when nchan > 1:

x99[z] = x99_rsz[..., np.newaxis] if nchan == 1 else x01_rsz

Because x99 was filled with x01_rsz, (x99 - x01) evaluated to 0 on multi-channel inputs, causing (x99 - x01).min() < 1e-3 to always trigger an erroneous ZeroDivisionError: cannot use norm3D=False with tile_norm, sample is too sparse....

Changes

  • Corrected line 293 to assign x99_rsz instead of x01_rsz.
  • Added regression test test_normalize99_tile_multichannel_per_plane in tests/test_transforms.py.

In normalize99_tile, when norm3D=False and Lz > 1, line 293 previously assigned
x01_rsz to x99[z] instead of x99_rsz when nchan > 1. This caused x99 to equal x01
and resulted in an erroneous ZeroDivisionError ('sample is too sparse').

Fixes MouseLand#1507
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.

normalize99_tile: multichannel per-plane mode always fails; tile smoothing skips x axis

1 participant