angelolab / ark-analysis

Integrated pipeline for multiplexed image analysis
https://ark-analysis.readthedocs.io/en/latest/
MIT License
71 stars 25 forks source link

Updating deepcell_visualization files after filtering for too small/too big cells from the cell table #1039

Open TerGla opened 1 year ago

TerGla commented 1 year ago

After running Mesmer/deep cells, we are usually plotting the cell size from the cell_table csv and excluding cells below/above a certain threshold. Is there an option that we could update the deppcell visualization images after this removal so that the cells we have excluded won't be anymore shown as segmented cells in the image? That would be great if you could implement this in your notebook. Thanks

ngreenwald commented 1 year ago

Hi @TerGla, The easiest would be the modify your segmentation masks to also exclude those same cells. That way, none of the downstream analysis needs to be modified. If you set those pixels back to zero in the mask, then those cells will basically disappear.

TerGla commented 1 year ago

Hi Noah,

Do you have a script for this? Since I have ca. 500 FOVs, it would be very challenging to find the cells in the images and remove them manually. From the cell table, I can easily remove them by excluding them. But isn’t there a code-based solution to find exactly those excluded cells in the images and remove the segmentation border line of those cells?

Best, Teresa

Am 18.08.2023 um 23:28 schrieb Noah F. Greenwald @.***>:

Hi @TerGlahttps://github.com/TerGla, The easiest would be the modify your segmentation masks to also exclude those same cells. That way, none of the downstream analysis needs to be modified. If you set those pixels back to zero in the mask, then those cells will basically disappear.

— Reply to this email directly, view it on GitHubhttps://github.com/angelolab/ark-analysis/issues/1039#issuecomment-1684453111, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A54KTQHDIN2D6Y5XGZ7XNJDXV7NAVANCNFSM6AAAAAA3VQHTTY. You are receiving this because you were mentioned.Message ID: @.***>

Zach-Sten commented 1 year ago

@TerGla I would write a code to open each fov as a numpy data array and then have it replace cell label values corresponding to those in your cell table that you want to remove with 0. The cell labels in your cell table per fov align with these values in the whole cell segmentation mask. This is a fast and easy way to apply the filters you had talked about making above. These modified numpy arrays and cell table can then be re-saved as .tiffs using the last few lines of code in the segmentation notebook 1.

TerGla commented 1 year ago

Great, thank you very much! I will do this

Am 21.08.2023 um 19:11 schrieb Zach-Sten @.***>:

@TerGlahttps://github.com/TerGla I would write a code to open each fov as a numpy data array and then have it replace cell label values corresponding to those in your cell table that you want to remove with 0. The cell labels in your cell table per fov align with these values in the whole cell segmentation mask. This is a fast and easy way to apply the filters you had talked about making above. These modified numpy arrays and cell table can then be re-saved as .tiffs using the last few lines of code in the segmentation notebook 1.

— Reply to this email directly, view it on GitHubhttps://github.com/angelolab/ark-analysis/issues/1039#issuecomment-1686720705, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A54KTQFQ3K7DYM53F3AZXIDXWOJE3ANCNFSM6AAAAAA3VQHTTY. You are receiving this because you were mentioned.Message ID: @.***>