scilus / scilpy

The Sherbrooke Connectivity Imaging Lab (SCIL) Python dMRI processing toolbox
Other
54 stars 59 forks source link

[FIX] Empty remaining indices when filtering for a bundle #1002

Closed levje closed 2 weeks ago

levje commented 2 weeks ago

Quick description

When using the _extract_vb_and_wpc_all_bundles function from the file tractogram_from_roi.py, there's a loop that updates and uses the remaining_ids list. While iterating over the bundles, it is possible that the list of remaining indices becomes empty thus creating an empty StatefulTractogram. This was causing some issues with the sub-function filter_grid_roi_both which internally was trying to transpose an empty matrix, which is invalid.

I added a quick check and some simple tests to make sure the sft provided as an input is not empty before filtering the streamlines w.r.t. the ROI.

Type of change

Check the relevant options.

Provide data, screenshots, command line to test (if relevant)

pytest scilpy/segment/tests/test_tractogram_from_roi.py

Checklist

pep8speaks commented 2 weeks ago

Hello @levje, Thank you for updating !

There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers:

Comment last updated at 2024-06-18 21:12:03 UTC
codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 40.00000% with 12 lines in your changes missing coverage. Please review.

Project coverage is 68.27%. Comparing base (99ad51e) to head (f67cf16).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1002 +/- ## ========================================== + Coverage 68.24% 68.27% +0.02% ========================================== Files 419 419 Lines 21405 21409 +4 Branches 3214 3216 +2 ========================================== + Hits 14608 14617 +9 + Misses 5532 5530 -2 + Partials 1265 1262 -3 ``` | [Components](https://app.codecov.io/gh/scilus/scilpy/pull/1002/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scilus) | Coverage Δ | | |---|---|---| | [Scripts](https://app.codecov.io/gh/scilus/scilpy/pull/1002/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scilus) | `69.24% <ø> (ø)` | | | [Library](https://app.codecov.io/gh/scilus/scilpy/pull/1002/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scilus) | `66.88% <40.00%> (+0.07%)` | :arrow_up: |