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: remove sft._data usage part 1 - tractogram coloring scripts + more #1105

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

Conversation

AntoineTheb
Copy link
Contributor

@AntoineTheb AntoineTheb commented Dec 12, 2024

Quick description

As per #891, although does not fix it completely. In doing so , I ended up reworking scil_tractogram_assign_custom_color.py

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)

No

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

@AntoineTheb AntoineTheb changed the title ENH: remove sft._data usage part 1 ENH: remove sft._data usage part 1 - tractogram coloring scripts + more Dec 12, 2024
# _lengths, so this feel kind of bad. However, the other way would be
# to create a new ArraySequence and iterate over the streamlines, but
# that would be way slower.
data_as_arraysequence._data = data
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't there a way to hstack the data, or vstack, and then convert to array sequence?

In my PR #890 , I had done this. Is it really that much slower?

image

Copy link
Member

Choose a reason for hiding this comment

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

Something I often do is that I create an array sequence with my streamlines like this:
dpp = sft.streamlines.copy()
dpp._data = my_array.copy()

That way everything is initialized with the right length, memory safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@EmmaRenauld I feel like iterating over all streamlines would be problematic for large (>1M) tractograms.
@frheault the problem with your approach is the dpp is still "prealocated" using the streamlines, which is weird. I think this is a deeper problem stemming from the way ArraySequences work but I'd rather not have to preallocate data per points as the streamlines' points. Especially if more complicated processing is needed and some DPP may be left to the streamline's value by accident.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@EmmaRenauld @frheault should be a bit cleaner now.

@AntoineTheb AntoineTheb marked this pull request as draft December 18, 2024 22:26
@pep8speaks
Copy link

pep8speaks commented Dec 26, 2024

Hello @AntoineTheb, Thank you for updating !

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

Comment last updated at 2024-12-26 22:52:25 UTC

Copy link

codecov bot commented Dec 26, 2024

Codecov Report

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

Project coverage is 69.55%. Comparing base (063af0c) to head (9d14d3f).
Report is 17 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1105      +/-   ##
==========================================
+ Coverage   69.53%   69.55%   +0.02%     
==========================================
  Files         448      448              
  Lines       24078    24088      +10     
  Branches     3291     3294       +3     
==========================================
+ Hits        16742    16754      +12     
+ Misses       5943     5941       -2     
  Partials     1393     1393              
Components Coverage Δ
Scripts 70.28% <85.29%> (+0.01%) ⬆️
Library 68.58% <62.96%> (+0.02%) ⬆️

@AntoineTheb AntoineTheb marked this pull request as ready for review December 26, 2024 22:53
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