Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cellpose Filtering Workflow Bug #34

Open
sophiamaedler opened this issue May 7, 2024 · 0 comments
Open

Cellpose Filtering Workflow Bug #34

sophiamaedler opened this issue May 7, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@sophiamaedler
Copy link
Collaborator

sophiamaedler commented May 7, 2024

When applying the cell pose segmentation workflow some cytosol masks are not filtered out even though they do not have a matching nucleus.

Code and data to reproduce:

from sparcscore.pipeline.project import TimecourseProject
from sparcscore.pipeline.workflows import Multithreaded_Cytosol_Cellpose_Downsampling_TimecourseSegmentation, Cytosol_Cellpose_Downsampling_TimecourseSegmentation
from sparcscore.pipeline.extraction import TimecourseHDF5CellExtraction

project_location = f"test_project"
config_file = "config_segmentation.yml"

project = TimecourseProject(project_location, 
                            config_path=config_file, 
                            segmentation_f=Multithreaded_Cytosol_Cellpose_Downsampling_TimecourseSegmentation,
                            extraction_f = TimecourseHDF5CellExtraction,
                            overwrite=False,
                            debug=True)

#load data
images = np.load("images.npy")
labels = pd.read_csv("labels.csv", index_col = 0)

project.load_input_from_array(images, label = labels, overwrite = True)

project.segment()

All of the ids found in the nucleus mask should also be found in the cytosol mask but in this specific example that is not the case for the first image tile. This statement should return true but it returns false.

nucleus_ids = set(np.unique(segmentation[0][0]))
cytosol_ids = set(np.unique(segmentation[0][1]))

print(cytosol_ids.issubset(nucleus_ids))
Screenshot 2024-05-07 at 10 42 50

Data to reproduce:
Archive.zip

I have already implemented a warning which is issued during segmentation when this occurs, but the source of the problem needs to be identified. This bug was the reason why during extraction we sometimes got empty cells. This problem has been fixed as we now only look at cell_ids contained in the nucleus mask.

[06/05/2024 16:33:09] Warning: Different classes in different segmentatio channels. Please report this example to the developers
[06/05/2024 16:33:09] set1 nucleus: set(np.unique(shifted_map[0]))
[06/05/2024 16:33:09] set2 cytosol: set(np.unique(shifted_map[1]))
[06/05/2024 16:33:09] {48} not in nucleus mask
[06/05/2024 16:33:10] set() not in cytosol mask
@sophiamaedler sophiamaedler added the bug Something isn't working label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants