Refactor _find_identical_streamlines to use DIPY FastStreamlineSearch (FSS) and connected components#1311
Open
CSimon-A wants to merge 4 commits intoscilus:masterfrom
Open
Conversation
Author
|
Hey @frheault and @StongeEtienne, the FSS refactor is complete. Ready for your review when you have a moment! |
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.
Quick description
Replaces the custom, greedy streamline matching algorithm in
_find_identical_streamlineswith a robust, graph-based clustering approach using DIPY'sFastStreamlineSearchand SciPy'sconnected_components.Motivation & Improvements:
bidirectionalparameter (defaultTrue). The legacy vector subtraction (streamline - streamlines[j]) failed to match geometrically identical streamlines if their endpoints were flipped (A->B vs. B->A). FSS natively solves this.nb_resample_pts(default64). The old code grouped purely by exact point counts (np.unique(lengths)), meaning identical curves sampled at 50 vs. 51 points were missed.perform_tractogram_operation_on_linesand therobustwrapper functions to accurately document the dispatcher logic, distinguishing between the heuristic extremity-hashing pathway and the rigorous FSS pathway.Type of change
Check the relevant options.
Command line to test
Run the updated unit test for robust operations to verify that streamline deduplication, union, intersection, and difference logic behaves correctly:
pytest -v -n 0 test_tractogram_operations.py::test_robust_operationsChecklist
Note to Reviewers regarding the CLI (
scil_tractogram_math.py):This refactor adds two new configurable parameters to the robust operations in the core module:
nb_resample_pts(default 64) andbidirectional(default True).I intentionally did not expose these as new
argparsearguments in thescil_tractogram_math.pyCLI script yet, as I wasn't sure if we want to clutter the terminal interface with them. The CLI will safely fall back to the defaults (64 points, bidirectional matching). Let me know if you would prefer me to add--resample_ptsand--bidirectionalflags to the CLI in this PR!