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

bundles_distances_mdf asymmetric values #2310

Closed
bloomdt-uw opened this issue Jan 6, 2021 · 2 comments · Fixed by #2389
Closed

bundles_distances_mdf asymmetric values #2310

bloomdt-uw opened this issue Jan 6, 2021 · 2 comments · Fixed by #2389
Assignees
Milestone

Comments

@bloomdt-uw
Copy link

Description

Using bundles_distances_mdf to calculate minimum average direct-flip distances between streamlines on subjects from HCP dataset results in asymmetric values. Expecting distance to be symmetric: MDF(i,j)=MDF(j,i)

>>> import numpy as np
>>> from dipy.io.streamline import load_tractogram
>>> import dipy.tracking.streamline as dts
>>> tractogram = load_tractogram(tg_fname, 'same')
>>> streamlines = tractogram.streamlines
>>> fgarray = np.array(dts.set_number_of_points(streamlines, 100))
>>> mdf = dts.bundles_distances_mdf(fgarray, fgarray)
>>> np.count_nonzero(mdf-mdf.T)
2930

Asymmetries are small, so this may be a result of numerical error:

>>> np.sum(abs(mdf-mdf.T))
0.014194488525390625

Way to reproduce

Code example

>>> import numpy as np
>>> import dipy.tracking.streamline as dts
>>> A = np.load('max_asymmetric_mdf.npy')
>>> dts.bundles_distances_mdf(A,A)
array([[ 0.        , 27.01378632],
       [27.01377106,  0.        ]])

max_asymmetric_mdf.npy.zip

Relevant images

image

Operating system and version

macOS-10.16-x86_64-i386-64bit

Python version

Python 3.8.5 (default, Sep  4 2020, 02:22:02) 
[Clang 10.0.0 ]

dipy version

dipy 1.2.0

dependency version

NumPy 1.17.5
@skoudoro
Copy link
Member

skoudoro commented Jan 6, 2021

Hi @bloomdt-uw,

Thank you for this nice report. Can you look into this @BramshQamar and @Garyfallidis? Thanks!

@skoudoro
Copy link
Member

skoudoro commented May 7, 2021

Sorry for the late reply @bloomdt-uw.

I just had a look and fixed it on #2389. It should be good for the next release in June

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants