Skip to content

Conversation

@skoudoro
Copy link
Member

The goal of this PR is to allow inhomogeneous array for data_per_streamlines in a Tractogram.

I encounter this case when I wanted to save the labels of a cluster using Quickbundles from DIPY.

All saved centroids have a different number of streamlines, which make the array inhomogeneous.

data_per_streamline = {} data_per_streamline['clusters_labels'] = np.array([c.indices for c in clusters], dtype=object) data_per_streamline['clusters_sizes'] = clusters.clusters_sizes() 

See the following tutorial: https://docs.dipy.org/stable/examples_built/segmentation/segment_quickbundles.html

@codecov
Copy link

codecov bot commented Jan 17, 2024

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 92.26%. Comparing base (0e925ab) to head (c907b45).

Files Patch % Lines
nibabel/streamlines/tractogram.py 84.61% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@ ## master #1291 +/- ## ========================================== - Coverage 92.27% 92.26% -0.01%  ========================================== Files 99 99 Lines 12460 12470 +10 Branches 2561 2565 +4 ========================================== + Hits 11497 11505 +8  - Misses 641 642 +1  - Partials 322 323 +1 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

raise ValueError('data_per_streamline must be a 2D array.')

if value.dtype == object and not all(isinstance(v, Iterable) for v in value):
raise ValueError('data_per_streamline must be a 2D array')
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to test this case? I think passing something like np.array([1, np.array([0, 1])], dtype=object)?

@effigies
Copy link
Member

Hi Serge, thanks, and apologies for the slow response. I'm going to look into what's going on with the pre-release tests.

@skoudoro
Copy link
Member Author

Hi @effigies,

Thank you for the review. no worries.

I will come back on this next week. What is the ETA of the next nibabel release?

@effigies
Copy link
Member

ETA April. Might aim for late March or early May, as April will be busy for me.

@effigies effigies merged commit c445edd into nipy:master Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants