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 359 forks source link

cellpose on large .tif images (1GB-10GB) #917

Open Nespresso2000 opened 2 months ago

Nespresso2000 commented 2 months ago

Hi,

I want to use cellpose on some rather large .tif files of sizes ranging from 1GB-10GB. They are 2-d RGB images. I have a Tesla T4 GPU and 32GB RAM. Following #356 and #244 I first used openslide to convert my image and write them on my disk as zarr arrays; so now, I have a folder of zarr arrays corresponding to one image. To be honest, I am not able to understand exactly whats going on in this new piece of code and would appreciate a small explanation of the following points:

  1. Does this even work for 2d images? or only 3d? If not, is there anything I can do to process such large 2d images? Before finding this, I saw https://forum.image.sc/t/loading-whole-slide-image-and-running-cellpose-in-python/69992/7 according to which I'd need an obscene amount of RAM which is not possible.
  2. What does the block_size parameter mean in distributed_eval?
  3. How do I access / see what the segmented image looks like after? I could do that following the docs when I was saving a .npy file but I'm not able to find similar documentation

Apologies in advance if the questions are obvious but any help is appreciated!

zsamadi commented 1 month ago
  1. I don't suppose there is any difference between 3D and 2D. Take a look at this link on how to use Cellpose on Dask arrays.

  2. I don't know exactly what you mean by block_size or distributed_eval.

  3. The method mentioned in the above link results in a dask array of labels. You can view separate segmentation chunk results by iterating through them and computing them.

camilolaiton commented 1 month ago

Hello! @Nespresso2000 we just released a package for large-scale segmentation with cellpose (2D/3D images). Still in development but it'd be nice if you give it a shot. Unfortunately, you'd have to convert your data to OMEZarr.

Eddymorphling commented 3 weeks ago

Hello! @Nespresso2000 we just released a package for large-scale segmentation with cellpose (2D/3D images). Still in development but it'd be nice if you give it a shot. Unfortunately, you'd have to convert your data to OMEZarr.

Hi @camilolaiton I am interested in trying this out! How would I go about testing this? I have large datasets for Cellpose segmentation saved as zarrarrays. Do you have a tutorial on how to run your package in python? Thank you.

camilolaiton commented 2 weeks ago

Hi @Eddymorphling, not yet. I'll include a notebook with examples this week. In the meantime, you could take a look at this function main. We are using the OME-NGFF convention for the zarr (OME-Zarr) to get the image metadata (e.g., resolution).

Please, let me know if you have following questions. Make sure to properly set the parameters for the machine you're using.