Skip to content

Conversation

@GaiaGerbaka
Copy link
Contributor

@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
Contributor 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this to just grab name of the first tiff image, avoiding any hardcoding dependent on the filename's structure

Copy link
Member

Choose a reason for hiding this comment

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

After conversation, we opted to just drop this option as we don't need it for our functionality. It does not work as-is because we can't assume that files will end in .tiff.

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

@ErinWeisbart
Copy link
Member

Wonderful work @GaiaGerbaka ! Thanks for your lovely work!

@ErinWeisbart ErinWeisbart merged commit 9cb748c into CellProfiler:master Aug 20, 2025
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