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

[ENH] Add an option to cut streamlines #1119

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

arnaudbore
Copy link
Contributor

@arnaudbore arnaudbore commented Jan 16, 2025

Quick description

When you want to cut streamlines between two regions from a label file, you now have the possibility to either:

  • Keep all points inside the two ROIS. (default)
  • Keep one point inside each ROI (--one_point_in_roi)
  • No point in ROI ( use --no_point_in_roi)

I checked with MI-Brain and I'm not sure it works, I can filter the no_point_in_roi.trk with the mask :|

Here are some data.tar.gz with the command line:

scil_tractogram_cut_streamlines.py tractogram.trk --labels labels.nii.gz one_point_in_roi.trk -f --one_point_in_roi
scil_tractogram_cut_streamlines.py tractogram.trk --labels labels.nii.gz no_point_in_roi.trk -f --no_point_in_roi
scil_tractogram_cut_streamlines.py tractogram.trk --labels labels.nii.gz points_in_roi.trk -f

...

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)

...

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 Jan 16, 2025

Hello @arnaudbore, Thank you for updating !

Line 460:80: E501 line too long (87 > 79 characters)
Line 461:80: E501 line too long (85 > 79 characters)
Line 541:80: E501 line too long (105 > 79 characters)

Comment last updated at 2025-01-17 12:18:59 UTC

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 55.88235% with 15 lines in your changes missing coverage. Please review.

Project coverage is 69.53%. Comparing base (0ac4461) to head (0b63c48).
Report is 7 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1119      +/-   ##
==========================================
- Coverage   69.56%   69.53%   -0.04%     
==========================================
  Files         448      448              
  Lines       24078    24103      +25     
  Branches     3290     3298       +8     
==========================================
+ Hits        16751    16761      +10     
- Misses       5934     5946      +12     
- Partials     1393     1396       +3     
Components Coverage Δ
Scripts 70.27% <66.66%> (+0.01%) ⬆️
Library 68.56% <53.57%> (-0.10%) ⬇️

@frheault
Copy link
Member

I see a potential error in all three I think. If you look at all streamlines going through the no_point you will see some are going in and out and in again. And these few streamlines are present in a three.

This could be acceptable for the default (longest segment could be longest final segment)

image

image

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.

LGTM, however I think some unit tests would be nice to ensure no regression happens when we inevitably revisit this script later on.

Copy link
Member

@frheault frheault left a comment

Choose a reason for hiding this comment

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

Would it be possible to make a unit with synthetic data A 3x3x3 grid with a single central voxel as mask.

And try a straight line going through, a straight going in and out and in again, starting in going out, fully in, fully out.

We change/broke/fix this like 3 times and 2 years.

Juste the easiest case

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.

4 participants