MathOnco / valis

Virtual Alignment of pathoLogy Image Series
https://valis.readthedocs.io/en/latest/
MIT License
115 stars 28 forks source link

very large ome.tiff file size #142

Closed minajamshidi closed 1 month ago

minajamshidi commented 1 month ago

I used the example codes and tutorial to register our H&E and IHC slides. Whereas the code works properly, we have the issue that the ome.tiff registered slides are huge. Some are in the range of ~20G and some even ~90G. I would like to know if you have faced this issue before, whether there is any solution for it, or if I am missing sth from your tutorials where I could prevent the registered slides from being so large.

cdgatenbee commented 1 month ago

Hi @minajamshidi,

Thanks for reaching out, and glad to hear that you’re finding VALIS useful! To your answer your question, part of the reason the files are so large is likely because the default compression method (as of v1.1.0 “deflate”, but previously “lzw”) was chosen so that it works will all datatypes, and Q is set to 100 to have lossless compression. However, since it sounds like you are working with RGB images (usually uint8), you can likely significantly reduce the file sizes by changing the compression parameter to “jpeg”. If you’re ok with the ome.tiff not having lossless compression, reducing the Q parameter, maybe to 90, will further reduce the file size, and any reduction in quality will probably not be noticeable. Altogether, that would look like this:

registrar.warp_and_save_slides(dst_dir=”where/to/save/ometiff”, compression=”jpeg”, Q=90)

Please try that out and let me know if it reduces the file sizes enough. If not, there may be other things to try, but I think this should make a noticeable difference and is an easy fix.

Best, -Chandler

minajamshidi commented 1 month ago

Hi Chandler,

thanks for the hint. Your solution worked properly for most of our slides.

Best wishes Mina

cdgatenbee commented 1 month ago

Glad to hear it (mostly) worked out! I'll go ahead and close this issue, but please let me know if you run into any other problems.

Best, -Chandler