Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
813d5d4
Updated some core dev info
Garyfallidis May 12, 2018
ae41159
Added a few more names
Garyfallidis May 12, 2018
3ecfa3a
Merge pull request #1517 from Garyfallidis/dev_info_update
skoudoro May 12, 2018
1af53ac
DOC: updated some developers affiliations.
jchoude May 14, 2018
f4c7e45
Merge pull request #1518 from jchoude/DOC_some_developers_affiliations
skoudoro May 14, 2018
144cadb
Updating the documentation for the workflow creation tutorial.
May 14, 2018
c5729fc
Removed the trailing whitespaces as per the PEP8 standard.
May 14, 2018
b421f9c
Moved some older highlights and announcements to the old news files.
arokem May 14, 2018
05d4691
Now also remove things from the front page.
arokem May 14, 2018
34937d4
Updated the workflow_creation.py according to the recommendations mad…
May 16, 2018
b7f94ae
Added back two more news announcements.
arokem May 16, 2018
b5001ba
TST: We should be able to read values with Streamline objects.
arokem May 16, 2018
a710850
BF: Enables extracting values with Streamline objects.
arokem May 16, 2018
202028d
PEP8
arokem May 16, 2018
5648281
Merge pull request #1521 from arokem/old_highlights
skoudoro May 16, 2018
23cb625
PEP8 the entire thing.
arokem May 16, 2018
8462d3e
Merge pull request #1524 from arokem/values_from_streamlines_object
skoudoro May 16, 2018
6bee25c
Merge pull request #1520 from parichit/doc_branch
skoudoro May 17, 2018
04bbca4
iniital changes
thechargedneutron May 18, 2018
2571445
extra env files deleted
thechargedneutron May 18, 2018
2fbe4b1
minor typo fix in quickstart
ShreyasFadnavis May 21, 2018
f7b0e61
input parametrs changed
thechargedneutron May 21, 2018
6dda3ac
Merge pull request #1529 from ShreyasFadnavis/micro
arokem May 21, 2018
786deb6
Wrong default value for parameter 'symmetric' False in connectivity_m…
albayenes May 21, 2018
0bdce0d
Merge pull request #1530 from albayenes/connectivity-matrix-wrong-def…
arokem May 21, 2018
cfc96f9
removed unncessary importd from sims eg
ShreyasFadnavis May 27, 2018
1263199
doc changed
thechargedneutron May 27, 2018
5ff2e7f
unnecessary venv files removed
thechargedneutron May 27, 2018
8410945
Explanation that is mistakenly rendered as code fixed in example of DKI
albayenes May 28, 2018
804f4e8
Merge pull request #1537 from ShreyasFadnavis/dipy-sims
Garyfallidis May 28, 2018
54823e7
Remove unused attributes in UI and add better way of handling absolut…
MarcCote Mar 4, 2018
50acf99
Remove FileMenu2D in favor of ListBox2D.
MarcCote Mar 4, 2018
5e061da
BF: button placement in viz_ui.py.
MarcCote Mar 6, 2018
ee6eee3
Rebased + update viz examples
MarcCote Apr 5, 2018
8d29466
Add Disk2D and use it as sliders' handle
MarcCote Apr 7, 2018
f370c80
Do not start session in viz example
MarcCote Apr 10, 2018
98b6565
Addressed @skoudoro comments
MarcCote Apr 20, 2018
bbd9808
Renamed DiskSlider2D to RingSlider2D
MarcCote May 17, 2018
afab328
Refactor get_actors
MarcCote May 29, 2018
c17a642
Rename DiskSlider to RingSlider
MarcCote May 29, 2018
c67a2df
Removed debugging BoundingBox
MarcCote May 29, 2018
866e26c
Remove empty line at the end of dosctring
MarcCote May 29, 2018
3c4eaf0
PEP8
MarcCote May 29, 2018
f1991f0
change for cvxpy - missing strict inequalities
Borda May 30, 2018
8110b02
update test asserts: equal -> almost_equal
Borda May 30, 2018
d1bdee5
DOC: Update Rafael's current institution.
May 26, 2018
ba39896
Merge pull request #1536 from jhlegarreta/UpdateRNHCurrentInstitution
arokem May 31, 2018
acda6e1
Merge pull request #1538 from albayenes/fix-explanation-of-code-in-ex…
arokem Jun 1, 2018
6fdbb63
Add tests files
MarcCote Jun 1, 2018
d8fb000
Merge pull request #1492 from MarcCote/enh_ui_components_positioning2
Garyfallidis Jun 1, 2018
7aeb622
Added DIPY reference in README.rst
Garyfallidis Jun 3, 2018
2c48473
Link the reference
Garyfallidis Jun 3, 2018
f95d1e6
Merge pull request #1545 from Garyfallidis/readme_ref
arokem Jun 3, 2018
df6d880
References to reference
Garyfallidis Jun 3, 2018
e1422d7
Merge pull request #1546 from Garyfallidis/readme_ref2
arokem Jun 4, 2018
1db31a9
Fixed references per request of @garyfallidis.
kesshijordan Jun 4, 2018
2475685
Merge pull request #1542 from Borda/fix_4_cvxpy
skoudoro Jun 5, 2018
fa7b35e
fix potential zero division in demon regist.
Borda May 30, 2018
88e132a
Merge pull request #1548 from kesshijordan/fix_boot_reference
Garyfallidis Jun 5, 2018
4484514
Merge pull request #1540 from Borda/fix_div_zero
skoudoro Jun 5, 2018
0e3c38f
Merge branch 'master' of https://github.com/nipy/dipy into cancer_sph…
thechargedneutron Jun 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
.. image:: https://img.shields.io/badge/License-BSD%203--Clause-blue.svg
:target: https://github.com/nipy/dipy/blob/master/LICENSE

DIPY is a python toolbox for analysis of MR diffusion imaging.
DIPY [DIPYREF]_ is a python library for analysis of MR diffusion imaging.

DIPY is for research only; please do not use results from DIPY for
clinical decisions.
Expand Down Expand Up @@ -83,3 +83,11 @@ Contributing
============

We welcome contributions from the community. Please read our `Contributing guidelines <https://github.com/nipy/dipy/blob/master/CONTRIBUTING.md>`_.

Reference
=========

.. [DIPYREF] E. Garyfallidis, M. Brett, B. Amirbekian, A. Rokem,
S. Van Der Walt, M. Descoteaux, I. Nimmo-Smith and DIPY contributors,
"DIPY, a library for the analysis of diffusion MRI data",
Frontiers in Neuroinformatics, vol. 8, p. 8, Frontiers, 2014.
6 changes: 3 additions & 3 deletions dipy/align/imwarp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1373,9 +1373,9 @@ def _get_energy_derivative(self):
x = range(self.energy_window)
y = self.energy_list[(n_iter - self.energy_window):n_iter]
ss = sum(y)
if(ss > 0):
ss *= -1
y = [v / ss for v in y]
if not ss == 0: # avoid division by zero
ss = - ss if ss > 0 else ss
y = [v / ss for v in y]
der = self._approximate_derivative_direct(x, y)
return der

Expand Down
Binary file removed dipy/data/files/test_ui_file_select_menu_2d.log.gz
Binary file not shown.
Binary file removed dipy/data/files/test_ui_file_select_menu_2d.pkl
Binary file not shown.
4 changes: 2 additions & 2 deletions dipy/reconst/mapmri.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ def fit(self, data):
lopt * cvxpy.quad_form(c, laplacian_matrix)
)
M0 = M[self.gtab.b0s_mask, :]
constraints = [M0[0] * c == 1,
K * c > -.1]
constraints = [(M0[0] * c) == 1,
(K * c) >= -0.1]
prob = cvxpy.Problem(objective, constraints)
try:
prob.solve(solver=self.cvxpy_solver)
Expand Down
2 changes: 1 addition & 1 deletion dipy/reconst/shore.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def fit(self, data):
self.cache_set(
'shore_matrix_positive_constraint',
(self.pos_grid, self.pos_radius), psi)
constraints = [M0[0] * c == 1., psi * c > 1e-3]
constraints = [(M0[0] * c) == 1., (psi * c) >= 1e-3]
prob = cvxpy.Problem(objective, constraints)
try:
prob.solve(solver=self.cvxpy_solver)
Expand Down
4 changes: 2 additions & 2 deletions dipy/reconst/tests/test_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ def test_forecast_positive_constrain():

sphere = get_sphere('repulsion100')
fodf = f_fit.odf(sphere, clip_negative=False)
assert_equal(fodf[fodf < 0].sum(), 0)
assert_almost_equal(fodf[fodf < 0].sum(), 0, 2)

coeff = f_fit.sh_coeff
c0 = np.sqrt(1.0/(4*np.pi))
assert_almost_equal(coeff[0], c0, 10)
assert_almost_equal(coeff[0], c0, 5)


def test_forecast_csd():
Expand Down
2 changes: 1 addition & 1 deletion dipy/reconst/tests/test_shore.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_shore_positive_constrain():
pos_radius=20e-03)
asmfit = asm.fit(data.S)
eap = asmfit.pdf_grid(11, 20e-03)
assert_equal(eap[eap < 0].sum(), 0)
assert_almost_equal(eap[eap < 0].sum(), 0, 3)


def test_shore_fitting_no_constrain_e0():
Expand Down
67 changes: 35 additions & 32 deletions dipy/tracking/streamline.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@

MEGABYTE = 1024 * 1024


class _BuildCache(object):
def __init__(self, arr_seq, common_shape, dtype):
self.offsets = list(arr_seq._offsets)
self.lengths = list(arr_seq._lengths)
self.next_offset = arr_seq._get_next_offset()
self.bytes_per_buf = arr_seq._buffer_size * MEGABYTE
# Use the passed dtype only if null data array
self.dtype = dtype if arr_seq._data.size == 0 else arr_seq._data.dtype
if arr_seq.common_shape != () and common_shape != arr_seq.common_shape:
if arr_seq._data.size == 0:
self.dtype = dtype
else:
arr_seq._data.dtype
if (arr_seq.common_shape != () and
common_shape != arr_seq.common_shape):
raise ValueError(
"All dimensions, except the first one, must match exactly")
self.common_shape = common_shape
Expand All @@ -50,34 +53,32 @@ def update_seq(self, arr_seq):
arr_seq._offsets = np.array(self.offsets)
arr_seq._lengths = np.array(self.lengths)


class Streamlines(ArraySequence):

def __init__(self, *args, **kwargs):
super(Streamlines, self).__init__(*args, **kwargs)

def append(self, element, cache_build=False):
""" Appends `element` to this array sequence.
"""
Appends `element` to this array sequence.

Append can be a lot faster if it knows that it is appending several
elements instead of a single element. In that case it can cache the
parameters it uses between append operations, in a "build cache". To
tell append to do this, use ``cache_build=True``. If you use
``cache_build=True``, you need to finalize the append operations with
:meth:`finalize_append`.
elements instead of a single element. In that case it can cache
the parameters it uses between append operations, in a "build
cache". To tell append to do this, use ``cache_build=True``. If
you use ``cache_build=True``, you need to finalize the append
operations with :meth:`finalize_append`.

Parameters
----------
element : ndarray
Element to append. The shape must match already inserted elements
shape except for the first dimension.
cache_build : {False, True}
Whether to save the build cache from this append routine. If True,
append can assume it is the only player updating `self`, and the
caller must finalize `self` after all append operations, with
``self.finalize_append()``.
Returns
element : ndarray Element to append. The shape must match already
inserted elements shape except for the first dimension.
cache_build : {False, True} Whether to save the build cache
from this append routine. If True, append can assume it is the
only player updating `self`, and the caller must finalize
`self` after all append operations, with
``self.finalize_append()``. Returns
-------
None
Notes
None Notes
-----
If you need to add multiple elements you should consider
`ArraySequence.extend`.
Expand Down Expand Up @@ -124,19 +125,20 @@ def extend(self, elements):
""" Appends all `elements` to this array sequence.
Parameters
----------
elements : iterable of ndarrays or :class:`ArraySequence` object
If iterable of ndarrays, each ndarray will be concatenated along
the first dimension then appended to the data of this
elements : iterable of ndarrays or :class:`ArraySequence` instance

If iterable of ndarrays, each ndarray will be concatenated
along the first dimension then appended to the data of this
ArraySequence.
If :class:`ArraySequence` object, its data are simply appended to
the data of this ArraySequence.
If :class:`ArraySequence` object, its data are simply appended
to the data of this ArraySequence.

Returns
-------
None
Notes
None Notes
-----
The shape of the elements to be added must match the one of the data of
this :class:`ArraySequence` except for the first dimension.
The shape of the elements to be added must match the one of the
data of this :class:`ArraySequence` except for the first dimension.
"""
# If possible try pre-allocating memory.
try:
Expand Down Expand Up @@ -597,7 +599,8 @@ def _extract_vals(data, streamlines, affine=None, threedvec=False):
"""
data = data.astype(np.float)
if (isinstance(streamlines, list) or
isinstance(streamlines, types.GeneratorType)):
isinstance(streamlines, types.GeneratorType) or
isinstance(streamlines, Streamlines)):
if affine is not None:
streamlines = ut.move_streamlines(streamlines,
np.linalg.inv(affine))
Expand Down
3 changes: 3 additions & 0 deletions dipy/tracking/tests/test_streamline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,9 @@ def test_values_from_volume():
vv = values_from_volume(data, np.array(sl1))
npt.assert_almost_equal(vv, ans1, decimal=decimal)

vv = values_from_volume(data, Streamlines(sl1))
npt.assert_almost_equal(vv, ans1, decimal=decimal)

affine = np.eye(4)
affine[:, 3] = [-100, 10, 1, 1]
x_sl1 = ut.move_streamlines(sl1, affine)
Expand Down
2 changes: 1 addition & 1 deletion dipy/tracking/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def connectivity_matrix(streamlines, label_volume, voxel_size=None,
This argument is deprecated.
affine : array_like (4, 4)
The mapping from voxel coordinates to streamline coordinates.
symmetric : bool, False by default
symmetric : bool, True by default
Symmetric means we don't distinguish between start and end points. If
symmetric is True, ``matrix[i, j] == matrix[j, i]``.
return_mapping : bool, False by default
Expand Down
29 changes: 19 additions & 10 deletions dipy/viz/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from dipy.viz.utils import lines_to_vtk_polydata
from dipy.viz.utils import set_input
from dipy.viz.utils import numpy_to_vtk_points, numpy_to_vtk_colors
import dipy.viz.utils as ut_vtk

# Conditional import machinery for vtk
from dipy.utils.optpkg import optional_package
Expand Down Expand Up @@ -1339,7 +1340,7 @@ def point(points, colors, opacity=1., point_radius=0.1, theta=8, phi=8):
return actor


def sphere(centers, colors, radii=1., theta=16, phi=16):
def sphere(centers, colors, radii=1., theta=16, phi=16, vertices=None, faces=None):
""" Visualize one or many spheres with different colors and radii

Parameters
Expand All @@ -1350,6 +1351,8 @@ def sphere(centers, colors, radii=1., theta=16, phi=16):
radii : float or ndarray, shape (N,)
theta : int
phi : int
vertices : vertices array
faces : faces array

Returns
-------
Expand Down Expand Up @@ -1378,16 +1381,22 @@ def sphere(centers, colors, radii=1., theta=16, phi=16):
radii_fa = numpy_support.numpy_to_vtk(radii.astype('f8'), deep=0)
radii_fa.SetName('rad')

src = vtk.vtkSphereSource()
src.SetRadius(0.5)
src.SetThetaResolution(theta)
src.SetPhiResolution(phi)

polyData = vtk.vtkPolyData()
polyData.SetPoints(pts)
polyData.GetPointData().AddArray(radii_fa)
polyData.GetPointData().SetActiveScalars('rad')
polyData.GetPointData().AddArray(cols)
if faces is None:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Hi @thechargedneutron you will need to rebase this on top of dipy#1528 (my many_spheres branch) and update the test too.

src = vtk.vtkSphereSource()
src.SetRadius(0.5)
src.SetThetaResolution(theta)
src.SetPhiResolution(phi)

polyData.SetPoints(pts)
polyData.GetPointData().AddArray(radii_fa)
polyData.GetPointData().SetActiveScalars('rad')
polyData.GetPointData().AddArray(cols)

else:
for object_ in range(len(sphere_obj)):
ut_vtk.set_polydata_vertices(polyData, vertices)
ut_vtk.set_polydata_triangles(polyData, faces)

glyph = vtk.vtkGlyph3D()
glyph.SetSourceConnection(src.GetOutputPort())
Expand Down
Loading