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

Memory issue using cellpose for TMA ome.tiff #933

Open Mona-Khorani opened 1 month ago

Mona-Khorani commented 1 month ago

Hi, I have an ome.tiff image from Xenium instrument and I am using cellpose to do segmentation. However, the file is too heavy and I can not do so even under server access. I would be thankful to know if anyone had the same issue and what are recommendations. Thank you.

zsamadi commented 1 month ago

Hi, if the file is too big, you may need to convert it to Zarr dataset and use Cellpose to segment the tiles.

Mona-Khorani commented 1 month ago

Thank you. You mean to ome.zarr? and introduce the entire image without splitting to cellpose? The image is 35GB. This step is taking alot of my time because of memory issues, I can not figure it out even under server access. Any help would be greatly appreciated. Mona


From: Zain Samadi @.> Sent: Tuesday, May 7, 2024 2:50 PM To: MouseLand/cellpose @.> Cc: Mona Khorani @.>; Author @.> Subject: Re: [MouseLand/cellpose] Memory issue using cellpose for TMA ome.tiff (Issue #933)

Hi, if the file is too big, you may need to convert it to Zarr dataset and use Cellpose to segment the tiles.

— Reply to this email directly, view it on GitHubhttps://github.com/MouseLand/cellpose/issues/933#issuecomment-2099371790, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AW2JAKFZWRMC5AX3GUEDQTLZBFECDAVCNFSM6AAAAABHJZGQCSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJZGM3TCNZZGA. You are receiving this because you authored the thread.Message ID: @.***>

zsamadi commented 1 month ago

Sure, Zarr naturally converts image to dataset with the tile size you specify. You probably need to get familiar with Zarr and Dask packages to be able to handle those files, see this link for an example of applying cellpose on a big image using Zarr.

Mona-Khorani commented 1 month ago

Thank you so much, then you do not suggest splitting the image, doing segmentation, and putting them back together? Thank you.

10X support suggested this: “If your TMA sections are well separated so it should be possible define a rectangular bounding box for each core. The range of X and Y coordinates for each core can be determined from Xenium Explorer, and those coordinates can then be used to subset the data. For example, say one section has 100 < X < 300 and 300 < Y < 500. You can use that information to filter x_location and y_location, and look up the valid cell_id of cells belonging to that sections. At this point, you can either analyze all the detected transcripts directly, or you can use the set of cell_id to filter the complete h5 file. For combining them again after splitting. We need to aggregate the matrices. This is probably the easiest part and alternately some third-party tools can probably perform this.”

From: Zain Samadi @.> Sent: Tuesday, May 7, 2024 3:03 PM To: MouseLand/cellpose @.> Cc: Mona Khorani @.>; Author @.> Subject: Re: [MouseLand/cellpose] Memory issue using cellpose for TMA ome.tiff (Issue #933)

Sure, Zarr naturally converts image to dataset with the tile size you specify. You probably need to get familiar with Zarr and Dask packages to be able to handle those files, see this linkhttps://github.com/MouseLand/cellpose/blob/0c0d00a2bb0daa91e3983124db698230ea887828/cellpose/contrib/distributed_segmentation.py for an example of applying cellpose on a big image using Zarr.

— Reply to this email directly, view it on GitHubhttps://github.com/MouseLand/cellpose/issues/933#issuecomment-2099388644, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AW2JAKDHQH3KNWAGRQG5UETZBFFP3AVCNFSM6AAAAABHJZGQCSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJZGM4DQNRUGQ. You are receiving this because you authored the thread.Message ID: @.**@.>>

zsamadi commented 1 month ago

With splitting the image, you may have issues with the cells lying on the boundary of your sections. Using Dask, you can create overlapping tiles from Zarr dataset. Cellpose uses those overlaps to reconstruct labeling at the boundaries. If you don't have cells lying on the boundary, you can safely split your image and run segmentation on the sections independently.

camilolaiton commented 3 weeks ago

Hi @Mona-Khorani @zsamadi check this package out: Large-scale cellpose. Works with OME-Zarr.