Skip to content

Filtering range options#1949

Open
joshqsumner wants to merge 4 commits into
v5.0from
filtering-range-options
Open

Filtering range options#1949
joshqsumner wants to merge 4 commits into
v5.0from
filtering-range-options

Conversation

@joshqsumner

Copy link
Copy Markdown
Contributor

Describe your changes
Adds "in" and "out" modes for pcv.filters.obj_props which use a tuple for the thresh. Currently you could call it twice but sometimes calculating the regionprops is relatively slow so I'd rather be able to do the filtering in one step.

Type of update
This is a feature enhancement

Associated issues
None

Additional context
See 5/08/2026 dev meeting notes

For the reviewer
See this page for instructions on how to review the pull request.

  • PR functionality reviewed in a Jupyter Notebook
  • All tests pass
  • Test coverage remains 100%
  • Documentation tested
  • New documentation pages added to plantcv/mkdocs.yml
  • Changes to function input/output signatures added to updating.md
  • Code reviewed
  • PR approved

@joshqsumner joshqsumner added this to the PlantCV v5.0 milestone Jun 9, 2026
@joshqsumner joshqsumner added the enhancement Enhancements to existing features label Jun 9, 2026
@deepsource-io

deepsource-io Bot commented Jun 9, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 52fa895...b1ed24c on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Coverage  

Code Review Summary

Analyzer Status Updated (UTC) Details
Python Jul 10, 2026 9:54p.m. Review ↗
Code coverage Jul 10, 2026 9:54p.m. Review ↗

Code Coverage Summary

Language Line Coverage (New Code) Line Coverage (Overall)
Aggregate
100%
[✓ above threshold]
100%
Python
100%
[✓ above threshold]
100%

➟ Additional coverage metrics may have been reported. See full coverage report ↗


Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances plantcv.filters.obj_props to support range-based filtering modes (cut_side="in" and cut_side="out") so callers can filter objects within/outside a threshold range in a single pass (avoiding repeated regionprops computation).

Changes:

  • Added cut_side options "in" and "out" with tuple-based thresh validation.
  • Refactored filtering decision into a helper function (_apply_cut_side).
  • Updated documentation and expanded unit tests for the new modes and parameter validation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
tests/plantcv/filters/test_filter_objs.py Adds tests for "in"/"out" modes and new invalid-parameter cases.
plantcv/plantcv/filters/obj_props.py Implements "in"/"out" range filtering and routes comparisons through _apply_cut_side.
docs/filters_obj_props.md Documents the new range-based filtering options and tuple thresh behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +114 to +115
elif cut_side == "in":
gray_val = 255 if val > min(thresh) or val < max(thresh) else 0
Comment on lines +34 to +36
filtered_mask = obj_props(bin_img=mask, cut_side="in", thresh=(0.1, 0.6), regprop="solidity")
_, nobjs = create_labels(mask=filtered_mask)
assert nobjs == 20
Comment thread docs/filters_obj_props.md

Calculates properties of objects in a binary image.
Keeps objects that are either above or below a specified threshold for a specified property.
Keeps objects that are either above, below, within, or between a specified threshold for a specified property.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancements to existing features ready to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants