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

BF - fix eudx tracking for npeaks=1 #1888

Merged
merged 7 commits into from Jul 10, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -75,8 +75,12 @@ cdef class PeaksAndMetricsDirectionGetter(DirectionGetter):
raise IndexError("point outside data")

# Check to see how many peaks were found in the voxel
for numpeaks in range(self._ind.shape[3]):
if self._ind[ijk[0], ijk[1], ijk[2], numpeaks] < 0:
numpeaks=0
for i in range(self.peak_values.shape[3]):
# Test if the value associated to the peak is > 0
if self._qa[ijk[0], ijk[1], ijk[2], i] > 0:
numpeaks = numpeaks + 1
else:
This conversation was marked as resolved by arokem

This comment has been minimized.

Copy link
@arokem

arokem Jul 9, 2019

Member

Thanks! This is certainly clearer.

Would:

numpeaks = sum(self._qa[ijk[0], ijk[1], ijk[2], i] > 0) 

work here?

This comment has been minimized.

Copy link
@gabknight

gabknight Jul 10, 2019

Author Contributor

No, > doesn't work for arrays. Am I missing something?

Error compiling Cython file:
------------------------------------------------------------
...
         numpeaks = sum(self._qa[ijk[0], ijk[1], ijk[2], :] > 0)
                                                          ^
------------------------------------------------------------

dipy/reconst/peak_direction_getter.pyx:85:59: Invalid types for '>' (double[::1], long)

Would have been more clear :)

This comment has been minimized.

Copy link
@arokem

arokem Jul 10, 2019

Member

Oh well. Thanks for checking.

break

# Create directions array and copy peak directions from vertices
@@ -63,9 +63,20 @@ def get_direction(dg, point, dir):

# Check that points are rounded to get initial direction
point -= .5
id = peaks.initial_direction(point)
# id should be a (1, 3) array
npt.assert_array_almost_equal(id, [expected_dir])
initial_dir = peaks.initial_direction(point)
# It should be a (1, 3) array
npt.assert_array_almost_equal(initial_dir, [expected_dir])

peaks1 = peaks_from_model(SillyModel(), data, default_sphere,
relative_peak_threshold=.5,
min_separation_angle=25,
npeaks=1)
peaks1._initialize()
point = np.array([1, 1, 1], dtype=float)

# it should have one direction
npt.assert_array_almost_equal(len(peaks1.initial_direction(point)), 1)
npt.assert_array_almost_equal(len(peaks.initial_direction(point)), 1)


if __name__ == "__main__":
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.