Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Jun 19, 2024

Conversation

levje
Copy link
Contributor

@levje levje commented Jun 18, 2024

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.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

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

pytest scilpy/segment/tests/test_tractogram_from_roi.py

Checklist

  • My code follows the style guidelines of this project (run autopep8)
  • I added relevant citations to scripts, modules and functions docstrings and descriptions
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I moved all functions from the script file (except the argparser and main) to scilpy modules
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@pep8speaks
Copy link

pep8speaks commented Jun 18, 2024

Hello @levje, Thank you for updating !

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

Comment last updated at 2024-06-18 21:12:03 UTC

@levje levje changed the title Bugfix: Empty remaining indices when filtering for a bundle [FIX] Empty remaining indices when filtering for a bundle Jun 18, 2024
Copy link
Contributor

@AntoineTheb AntoineTheb left a comment

Choose a reason for hiding this comment

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

Great tests, LGTM

Copy link

codecov bot commented Jun 19, 2024

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
@@            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 Coverage Δ
Scripts 69.24% <ø> (ø)
Library 66.88% <40.00%> (+0.07%) ⬆️

Copy link
Contributor

@arnaudbore arnaudbore left a comment

Choose a reason for hiding this comment

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

Great work thank you @levje

@arnaudbore arnaudbore merged commit 74c7765 into scilus:master Jun 19, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants