labsyspharm / ashlar

ASHLAR: Alignment by Simultaneous Harmonization of Layer/Adjacency Registration
https://labsyspharm.github.io/ashlar/
MIT License
115 stars 40 forks source link

Artifact/Illumination correction in overlapping areas #210

Open bellonet opened 5 months ago

bellonet commented 5 months ago

I'm trying to use ASHLAR to stitch electron microscopy (EM) tiles, but although the stitching itself looks great, I don't think it offers the illumination correction needed. The tiles (pre-stitched) are darker in the overlapping part (most probably due to double imaging of those areas). Is there any parameter I can set to correct for those?

I didn't fully understand FFP and DFP, but when I tried to use them I got a black output image and a "Cannot cast ufunc 'true_divide' output from dtype('float64') to dtype('uint8') with casting rule 'same_kind'" error correspondingly.

Thank you!

jmuhlich commented 5 months ago

Glad to hear Ashlar is working for your EM images. Ashlar can perform illumination correction with user-specified illumination profiles during final image assembly but it doesn't compute the profiles itself. For optical fluorescence microscopy our lab uses the BaSiC algorithm (https://doi.org/10.1038/ncomms14836) to compute illumination profiles retrospectively from existing image sets, but it is also possible to collect the profiles prospectively using a particular imaging protocol. The correction in Ashlar is applied according to the following equation from the BaSiC paper:

image

Ashlar expects the --dfp image to have an unsigned integer pixel type that matches the input images. (Let me know if your input images are in floating point, and I can update the code to support that) The --ffp image must have a floating point pixel type. Both profile images must have the same dimensions as your input image tiles.

bellonet commented 5 months ago

Thank you for the quick response. Using BaSic to compute the illumination profile and setting dfp and ffp did improve the stitched image but the tiles overlapping areas are still noticeable. Maybe it's because my image comprises of only 6 tiles.