Skip to content

first draft of BoxObjects #278

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

GaiaGerbaka
Copy link

@GaiaGerbaka GaiaGerbaka commented Jul 23, 2025

Cellprofiler plugin with creates bounding box objects from the previously segmented objects

@ErinWeisbart
Copy link
Member

I put together a small test pipeline using the 1st image in the example dataset. IDPrimary finds 296 objects. BoundingBoxes using 1st or overlap both make 296 objects. I used workspace viewer to confirm that generally the objects are mapping to the correct numbers (1st in green, Overlap in pink, IDPrimary in black)
Screenshot 2025-08-04 at 2 28 09 PM

However, the final object made with 1st is almost all nan measurements. When I zoom in to the final object (296), workspace viewer shows object outlines that should have measurements for both box types.
Screenshot 2025-08-04 at 2 30 26 PM

Also, in the object.csv's, I would expect the AreaShape_Area and AreaShape_AreaBoundingBox to be the same always for when the bounding boxes are overlapping and to be either the same or smaller for bounding boxes that are 1st come first served (as you can end up with non-rectangular objects). In the overlapping objects, there are many examples where the two measurements are not the same. Object 7 is an example - it appears that the objects aren't overlapping but are using different logic than the 1st come first served.
Screenshot 2025-08-04 at 2 38 47 PM

test_runcellpose.cpproj.zip

@GaiaGerbaka
Copy link
Author

After digging into the first issue, I realized I was overwriting the ALLOW OVERLAP objects with the default non-overlapping object ("segmented") included in CellProfiler, I fixed this issue so now the objects are truly overlapping.

I was unable to replicate the second error raised by Erin ("the final object made with 1st is almost all nan measurements") so I could not track down the cause.

One issue raised after these changes is that the Measure modules do not operate properly using the truly overlapping objects. Going forward, I will try to crop out single images for each cell and process those independently, and/or will discuss with Beth about updating the Measure modules to allow for overlapping objects ("ijv" instead of "segmented")

def get_folder_name(self, workspace, filename_values):
"""Get original folder name based on user input"""
if self.file_name_method == FN_FROM_IMAGE:
filename_image = [f for f in filename_values if f.startswith("r")][0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this is hardcoded to match specific file name structuring? I tested it on the demo pipeline images and it crashes here.

segmented[y_min:y_max, x_min:x_max] = object_id

cropped_mask = input_label[y_min:y_max, x_min:x_max] == object_id
mask_save_filename = f"Object{image_name}_{self.output_object_name.value}_{object_id}.tiff"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image_name should not be a part of the mask filename as objects are independent of images

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants