Skip to content

Add options to segment_3d_image for removing objects touching borders#139

Open
lguerard wants to merge 2 commits intoimcf:develfrom
lguerard:fix/138-object3D-border-filtering
Open

Add options to segment_3d_image for removing objects touching borders#139
lguerard wants to merge 2 commits intoimcf:develfrom
lguerard:fix/138-object3D-border-filtering

Conversation

@lguerard
Copy link
Contributor

Fix #138

@codecov
Copy link

codecov bot commented Mar 25, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 25%. Comparing base (7cb7b68) to head (0eab3dd).
⚠️ Report is 28 commits behind head on devel.

Files with missing lines Patch % Lines
src/imcflibs/imagej/objects3d.py 0% 4 Missing ⚠️
Additional details and impacted files
@@         Coverage Diff          @@
##           devel   #139   +/-   ##
====================================
  Coverage     25%    25%           
====================================
  Files         25     25           
  Lines       1771   1763    -8     
====================================
+ Hits         437    443    +6     
+ Misses      1334   1320   -14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Defaults to None.
remove_touching_borders : bool, optional
Whether to remove objects that touch the borders in X and Y. Defaults to False.
remove_touching_borders_z : bool, optional
Copy link
Member

Choose a reason for hiding this comment

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

This won't have an effect if the non-z parameter is false, as far as I can see.

Either document this or automatically set the non-z to true if the z one is true inside the function. I prefer the latter approach as it seems less surprising.

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 checked this morning and there isn't a function in the 3DImageJSuite that could filter out only objects in Z but not XY.

There is a method in MorpholibJ that I could use though, should I switch to that ?

Copy link
Member

@ehrenfeu ehrenfeu Mar 25, 2026

Choose a reason for hiding this comment

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

Let me clarify what I'm trying to say.

From reading the docstring, what would an innocent developer think 🤔 will happen with this call?

label_imp = segment_3d_image(binary_imp, remove_touching_borders_z=True)

I believe the expectation is that at least some filtering would be happening, which is not the case given the current code execution path.

I don't know if we need a function that purely filters objects in Z, but if the Z-filtering is requested explicitly (without the XY-filtering), it will be silently ignored. My suggestion is to implicitly enable XY-filtering if Z-filtering is requested and to explain this in the docstring.

Would you think we should rather go for the MorphoLibJ approach that allows to only filter in Z? If you foresee any use-cases for this, it's clearly the better approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree.
At the moment, using only the Image3DSuite, there is no way to only filter in Z. If the user wants to do that, then it has to also filter in XY. I'm not happy about this, users might want to filter objects that aren't fully imaged in a stack and remove objects that are in slide 1 or slide max.

I'll improve this using MorpholibJ

@ehrenfeu ehrenfeu linked an issue Mar 25, 2026 that may be closed by this pull request
@ehrenfeu ehrenfeu added the enhancement New feature or request label Mar 25, 2026
@ehrenfeu ehrenfeu moved this to In progress in imcflibs Mar 25, 2026
@ehrenfeu ehrenfeu added this to the 2.0.0 milestone Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

Enable filtering cells touching borders

2 participants