angelolab / ark-analysis

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

Drop 3rd dimension in segmentation masks #1018

Closed camisowers closed 1 year ago

camisowers commented 1 year ago

If you haven't already, please read through our contributing guidelines before opening your PR

What is the purpose of this PR?

Closes #1009. Changes shape of the segmentation masks from 3d to 2d. (1, 1024, 1024) --> (1024, 1024) This now allows the images to be stitched in Image_Stitching.ipynb without issue.

How did you implement your changes

Squeeze the ranked_segmentation_mask before saving it to a tiff.

Remaining issues

camisowers commented 1 year ago

I'm guessing the majority of the downstream pipeline doesn't actually run this function, and instead creates fake segmentation masks. Therefore, if there's an issue, the tests are unlikely to pick it up. Did you check all the functions that load segmentation masks?

tldr: I looked at a bunch of test functions and seems like usually the pseudo masks we create are 2d anyways, but regardless the load function returns the same array for the 2d vs 3d segmentation masks so we should be good

Yes, the tests for functions that require segmentation masks just create an array and save it to a tiff, then the function calls a loading function from alpineer. Whether those test images created are 2d or 3d, the load_images_from_dir() always handles them accordingly by only retrieving the row and column data. I checked and the load output is the same between the 2d and 3d masks, so nothing should have changed throughout the pipeline.