saeyslab / napari-sparrow

Other
17 stars 0 forks source link

tiling_correction "Reweighting did not converge" error #150

Closed sttimmer closed 10 months ago

sttimmer commented 11 months ago

Running the tiling correction (nas.im.tiling_correction) returns an error for some images with messages about "Reweighting did not converge" and "All-NaN slice encountered":

Reweighting did not converge. /home/stevent/mambaforge-pypy3/envs/napari-sparrow/lib/python3.10/site-packages/skimage/transform/_warps.py:673: RuntimeWarning: All-NaN slice encountered min_val = min_func(input_image) /home/stevent/mambaforge-pypy3/envs/napari-sparrow/lib/python3.10/site-packages/skimage/transform/_warps.py:677: RuntimeWarning: All-NaN slice encountered max_val = max_func(input_image)

It seems to occur more for smaller images, but there is no real pattern to it. If it occurs, the "tiling_correction" layer contains an entirely black image.

ArneDefauw commented 10 months ago

Thanks for opening an issue! This erros occurs because the basicpy model used for illumination correction does not converge. A fix would be to explicitely check for convergence of this model, and if not just proceed with other processing (inpainting). Then you will not have illumination correction, but there will still be inpainting done. I will implement a fix for this, and let you know when it is merged in main.

ArneDefauw commented 10 months ago

This issue should now be fixed on main.

If this is input image (for which basicpy model does not converge):

bug_tiling_output

Then result of nas.im.tiling_correction( sdata, img_layer="raw_image" )

will now be:

bug_tiling

So only inpainting is done.

If this this does not completely fix your issue, please feel free to reopen the issue