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

One issue on handling HCP data -- HCP b vectors raise NaN in the gradient table #1668

Closed
YerongLi opened this Issue Nov 23, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@YerongLi
Copy link

YerongLi commented Nov 23, 2018

Description

In handling HCP data, calculating gradient_table with default b0_threshold=0 is not working.

Example

For

    bvals, bvecs = read_bvals_bvecs(fbval, fbvec)
    gtab = gradient_table(bvals, bvecs)

NaN appears in the gtab, for instance, if one can input this gtab into auto_response, ConstrainedSphericalDeconvModel and peaks_from_model subsequently, as one would see in http://nipy.org/dipy/examples_built/tracking_quick_start.html#example-tracking-quick-start.However following error pops up as a result:

 /opt/apps/software/Core/Anaconda3/5.0.0/lib/python3.6/site-packages/numpy/core/fromnumeric.py:2909: RuntimeWarning: Mean of empty
    slice.
       out=out, **kwargs)
    /opt/apps/software/Core/Anaconda3/5.0.0/lib/python3.6/site-packages/numpy/core/_methods.py:80: RuntimeWarning: invalid value encountered in
    true_divide
       ret = ret.dtype.type(ret / rcount)

    Intel MKL ERROR: Parameter 6 was incorrect on entry to DGELSD.
    multiprocessing.pool.RemoteTraceback:
    """
    Traceback (most recent call last):
       File
    "/home/yl148/.local/lib/python3.6/site-packages/dipy/reconst/csdeconv.py",
    line 545, in csdeconv
         fodf_sh = _solve_cholesky(P, z)
       File
    "/home/yl148/.local/lib/python3.6/site-packages/dipy/reconst/csdeconv.py",
    line 415, in _solve_cholesky
         raise la.LinAlgError(msg)
    numpy.linalg.linalg.LinAlgError: 1-th leading minor not positive definite

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
       File
    "/opt/apps/software/Core/Anaconda3/5.0.0/lib/python3.6/multiprocessing/pool.py", line 119, in
    worker
         result = (True, func(*args, **kwds))
       File
    "/opt/apps/software/Core/Anaconda3/5.0.0/lib/python3.6/multiprocessing/pool.py", line 44, in
    mapstar
         return list(map(*args))
       File
    "/home/yl148/.local/lib/python3.6/site-packages/dipy/direction/peaks.py", line
    390, in _peaks_from_model_parallel_sub
         parallel=False, nbr_processes=None)
       File
    "/home/yl148/.local/lib/python3.6/site-packages/dipy/direction/peaks.py", line
    505, in peaks_from_model
         odf = model.fit(data[idx]).odf(sphere)
       File
    "/home/yl148/.local/lib/python3.6/site-packages/dipy/reconst/multi_voxel.py",
    line 18, in new_fit
         return single_voxel_fit(self, data)
       File
    "/home/yl148/.local/lib/python3.6/site-packages/dipy/reconst/csdeconv.py",
    line 185, in fit
         P=self._P)
       File
    "/home/yl148/.local/lib/python3.6/site-packages/dipy/reconst/csdeconv.py",
    line 548, in csdeconv
         fodf_sh = _solve_cholesky(P, z)
       File
    "/home/yl148/.local/lib/python3.6/site-packages/dipy/reconst/csdeconv.py",
    line 415, in _solve_cholesky
         raise la.LinAlgError(msg)
    numpy.linalg.linalg.LinAlgError: 1-th leading minor not positive definite
    """

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last):
       File "tracking1.py", line 84, in <module>
         parallel=True)
       File
    "/home/yl148/.local/lib/python3.6/site-packages/dipy/direction/peaks.py", line
    476, in peaks_from_model
         nbr_processes)
       File
    "/home/yl148/.local/lib/python3.6/site-packages/dipy/direction/peaks.py", line
    287, in _peaks_from_model_parallel
         repeat(invB)))
       File
    "/opt/apps/software/Core/Anaconda3/5.0.0/lib/python3.6/multiprocessing/pool.py", line 266, in
    map
         return self._map_async(func, iterable, mapstar, chunksize).get()
       File
    "/opt/apps/software/Core/Anaconda3/5.0.0/lib/python3.6/multiprocessing/pool.py", line 644, in
    get
         raise self._value
    numpy.linalg.linalg.LinAlgError: 1-th leading minor not positive definite
@YerongLi

This comment has been minimized.

Copy link

YerongLi commented Nov 23, 2018

One solution @ShreyasFadnavis proposed is to bound the HCP b-values with b0_threshold=10 the function gradient_table, for example:

    bvals, bvecs = read_bvals_bvecs(fbval, fbvec)
    gtab = gradient_table(bvals, bvecs, b0_threshold=10)

With load a gradient table without NaN. This will work through the basic tracking example discussed above.

@YerongLi YerongLi closed this Nov 23, 2018

@skoudoro

This comment has been minimized.

Copy link
Member

skoudoro commented Nov 23, 2018

Thanks @YerongLi!

We need to warn the user. PR #1667 should fix this issue.

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