Пример #1
0
      streamlines.append(npts)
  return streamlines

cb_subj1 = getStreamlines("c10_test.vtk")
cb_subj2 = getStreamlines("c50_test.vtk")

from dipy.align.streamlinear import (StreamlineLinearRegistration,
                                     vectorize_streamlines)

"""
An important step before running the registration is to resample the streamlines
so that they both have the same number of points per streamline. Here we will
use 20 points.
"""

cb_subj1 = vectorize_streamlines(cb_subj1, 20)
cb_subj2 = vectorize_streamlines(cb_subj2, 20)

"""
Let's say now that we want to move the ``cb_subj2`` (moving) so that it can be
aligned with ``cb_subj1`` (static). Here is how this is done.
"""

srr = StreamlineLinearRegistration()

srm = srr.optimize(static=cb_subj1, moving=cb_subj2)

"""
After the optimization is finished we can apply the learned transformation to
``cb_subj2``.
"""
s_tract = load_tract(s_file,s_ind)
t_tract = load_tract(t_file,t_ind)

          

from dipy.align.streamlinear import (StreamlineLinearRegistration,
                                     vectorize_streamlines,
                                     BundleMinDistance)

"""
An important step before running the registration is to resample the streamlines
so that they both have the same number of points per streamline. Here we will
use 10 points.
"""
points = 20#10#20
s_tract = vectorize_streamlines(s_tract, points)
t_tract = vectorize_streamlines(t_tract, points)

"""
Let's say now that we want to move the ``s_tract`` (moving) so that it can be
aligned with ``t_tract`` (static). Here is how this is done.
"""
num_fiber = 300#50#100,200
s_rand_idx = np.random.randint(low = 0, high = len(s_tract), size = min(num_fiber,len(s_tract)))
s_tract_tmp = [s_tract[i] for i in s_rand_idx]

t_rand_idx = np.random.randint(low = 0, high = len(t_tract), size = min(num_fiber,len(t_tract)))
t_tract_tmp = [t_tract[i] for i in t_rand_idx]

#s_tract_tmp = s_tract[:50]
#t_tract_tmp = t_tract[:50]