MouseLand / cellpose

a generalist algorithm for cellular segmentation with human-in-the-loop capabilities
https://www.cellpose.org/
BSD 3-Clause "New" or "Revised" License
1.24k stars 360 forks source link

[BUG]Percentile normalization when norm3d=True #893

Open derekthirstrup opened 3 months ago

derekthirstrup commented 3 months ago

Describe the bug I wrote a script to denoise tif stacks using the new DenoiseModel class from Cellpose 3. It works great but there appears to be an issue with the normalization step. It appears to be performing a per z slice normalization which boost noise in out of focus planes. I assumed that passing norm3D= True to eval method would perform a per stack normalization of intensities. However it still appears to be doing per slice. What is the optimal way to force the normalization to be per stack? I did also evaluate stack normalization outside of cellpose but it seems to degrade the denoising performance and leads to a grainy output for this lamin tagged cell line. Left image is sequential rescaling subtracting camera offset and rescaling to max px value before passing to DenoiseModel percentile rescaling from [0,99] and right is just camera offset to max px value denoising. I think the z planes that are in focus look to be higher contrast with the sequential option but suffer from the out of focus planes boosting noise. image

Here is an out of focus plane example: image

anoshqa commented 3 months ago

Hi, can you share your codes to attempt norm3D=True please? I read the docs where I have to pass a whole dictionary in normalize=True but am struggling. When I import my tif stack into GUI it automatically uses the following - {'lowhigh': None, 'percentile': [1.0, 99.0], 'normalize': True, 'norm3D': True, 'sharpen_radius': 0, 'smooth_radius': 0, 'tile_norm_blocksize': 0, 'tile_norm_smooth3D': 1, 'invert': False}, and then I run denoise and the noise actually gets enhanced (instead of getting removed)