[ENH/FIX] Add flag to turn off clipping during cleaning when clip_edges is True#201
Open
36000 wants to merge 2 commits into
Open
[ENH/FIX] Add flag to turn off clipping during cleaning when clip_edges is True#20136000 wants to merge 2 commits into
36000 wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new clean_unclipped flag to control whether cleaning steps operate on unclipped streamlines when clip_edges=True, aiming to standardize clipping behavior across multiple cleaning criteria (standard/Mahalanobis, orientation, QuickBundles thresholding, isolation forest).
Changes:
- Add
clean_unclippedparameter to the publicrecognize()API and propagate it into bundle recognition. - Refactor cleaning criteria to use a unified “clip for cleaning” decision.
- Update recognition test coverage to exercise the new flag when
clip_edges=True.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
AFQ/recognition/tests/test_recognition.py |
Updates clip_edges API test to pass the new clean_unclipped flag. |
AFQ/recognition/recognize.py |
Adds clean_unclipped argument and forwards it to recognize_bundles. |
AFQ/recognition/criteria.py |
Refactors cleaning criteria to accept a “clip for cleaning” decision (currently introduces runtime issues that need fixes). |
Comments suppressed due to low confidence (1)
AFQ/recognition/recognize.py:32
clean_unclippedis inserted into the middle of therecognizepositional-parameter list (betweenclip_edgesandrb_recognize_params). This is a backwards-incompatible API change for any downstream code that passes optional args positionally (it will silently shift arguments). To avoid breaking positional callers, add the new argument at the end of the signature (or make optional args keyword-only) and keep existing positional ordering intact.
def recognize(
tg,
img,
mapping,
bundle_dict,
reg_template,
nb_points=False,
nb_streamlines=False,
clip_edges=False,
clean_unclipped=False,
rb_recognize_params=None,
refine_reco=False,
prob_threshold=0,
dist_to_waypoint=None,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
211ec7f to
2ac430d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This also includes a fix to make the clipping logic for all of our cleaning methods the same (standard, orientation, quickbundles, isolation forest) .