Repository navigation
Conversation
compute_tract_label_indices dropped the tracts shorter than length_threshold from its local list before indexing, so the keys of the four label maps were positions in the filtered list, while the tract bounding boxes, the endpoint positions and the saved tracts use positions in the full tractography. Queries combined unrelated tracts, returned tracts below the threshold, and relative terms raised KeyError. Key the label maps by the position in the full tractography and leave the short tracts out of all of them. Set the bounding boxes and endpoint positions of the left-out tracts to NaN so that relative terms do not select them either. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
compute_tract_bounding_boxes raised a ValueError when a tract had fewer than 2 points, so tract_querier could not process tractographies containing such tracts. Leave tracts with fewer than 2 points out of the label indices, the same way as tracts shorter than the length threshold, give them NaN bounding boxes and endpoint positions so that no query selects them, and warn once with their number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 4, 2026
This branch has not been deployed
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.
What was wrong
A tractography containing a tract with fewer than 2 points could not be queried:
compute_tract_bounding_boxesraisedValueError: Tracts in the tractography must have at least 2 points ...(the error in #50). As discussed in #46, such tracts should be ignored with a warning instead.The change
Tracts with fewer than 2 points (including empty ones) are left out of the label indices through the same mechanism as tracts below
--length_threshold(introduced in #122): they are absent from the four label maps and their bounding boxes and endpoint positions are NaN, so no query (label terms,endpoints_in, relative terms) selects them. A singleUserWarninggives their number and suggeststract_mathto prune them. Indices of the other tracts are unchanged, so the saved results still refer to the input tractography.Behaviour change: inputs that used to stop with the
ValueErrornow run, with the warning.Testing
test_tracts_with_fewer_than_two_pointsintract_querier/tests/test_tract_label_indices.py: appends two 1-point tracts (inside labels) and an empty tract to the synthetic tractography; checks the warning and that every query gives the same result as without them. It fails without this change.tract_querier -q wmql_1_cst.qry: warns2 tracts have fewer than 2 points and are ignored, and returnscortico_spinal.left: 000385,cortico_spinal.right: 000000, as for the original file.python -m pytest -q -p no:cacheprovider tract_querier: 44 passed, 1 skipped.Merge order
Depends on #122 (#46) and must be merged after it: this branch is stacked on it, so until #122 is merged the diff here also shows its commit. #140 (#117) and #135 (#100) touch the same file; all of them merge together without conflict.
Closes #50
🤖 Generated with Claude Code