vanvalenlab / deepcell-tf

Deep Learning Library for Single Cell Analysis
https://deepcell.readthedocs.io
Other
427 stars 99 forks source link

Error creating segmentation masks for small images #709

Open ashishshel opened 10 months ago

ashishshel commented 10 months ago

Hi, I have configured and set up the Mesmer pipeline to generate cell segmentation masks from DNA and Membrane tif files. The pipeline works well with all images that are above 256*256 dimensions. However, for images smaller than these dimensions I am getting an error indicating an incompatibility with shape. I have attached screenshots of the error. Further, I have also checked if there was a 'lower limit' for the image dimensions hard-coded in the scripts for the pipeline but could not find it. Could you please guide me in resolving this issue. Thanks. Screenshot 2024-01-29 at 3 33 51 PM Screenshot 2024-01-29 at 3 34 42 PM

ngreenwald commented 9 months ago

Hmmm, interesting issue. What should happen is that images smaller than 256x256 are padded prior to prediction. It seems that logic may not be working correctly. I'm wondering if this is because one of your dimensions is larger, and the other smaller? Maybe we only check the first dim, not both?

As a workaround, you can create a 286x286 blank image, and then assign your smaller image within that larger padded version. The padded image will be able to generate predictions, and then you can subset back out the original 286x206.

megleila commented 9 months ago

Hello -

I did this and am getting a new issue. Small ROIs, specifically with one dimension less than 256, will not be processed using Mesmer. So I have done as you said and assigned the DNA and Membrane channels within a larger canvas background in photoshop and flatten the image. I send the larger image through Mesmer and it works, and then crop it back to the original size. However in downstream analyses the mask file is only being read as having even numbered cells; ie every other cell is not picked up. E.g. if the true number of cells in an image is 154, cells 2,4,6,...,154 will be listed in output csv files, but the even numbered cells are missed. I have manually counted the cells on the image and confirmed that it's not simply mis-numbering, but actually missing exactly half of the cells.

I've looked at the mask files that have undergone this process and they appear (in ImageJ) to have identical properties and file info. I cannot figure out how to get around this. I asked the downstream analysis software I use (steinbock, bodenmiller lab) and they say it has to be related to the mask rather than anything to do with steinbock. Attaching a mask file that has undergone this cropping process that has this issue for reference.

Thanks, Megan

Batch17_004.tiff.zip

rossbar commented 9 months ago

Which version of deepcell-tf are you using? There was a problem with small tiles that was fixed by #673, though I'm not sure that's the same issue as reported here.