Exemplo n.º 1
0
 def render_tracks(self):
     """ Renders the tracks in a separate window using DiPy Fos """
     from cviewer.libs.dipy.viz import fos
     if not self.data_loaded:
         self.load_trackfile()
     # copy tracks for visualization
     T = [i[0] for i in self.streams]
     r=fos.ren()
     fos.add(r,fos.line(T,fos.white,opacity=0.1))
     fos.show(r)
Exemplo n.º 2
0
    def render_tracks(self):
        """ Renders the tracks in a separate window using DiPy Fos """
        from cviewer.libs.dipy.viz import fos
        if not self.loaded:
            self.load()

        # copy tracks for visualization
        T = [i[0] for i in self.obj.data[0]]
        r = fos.ren()
        fos.add(r, fos.line(T, fos.white, opacity=0.8))
        fos.show(r)
print 'Representing tracks using only 3 pts...'
tracks=[tm.downsample(t,3) for t in T]

print 'Deleting unnecessary data...'
del streams,hdr

print 'Hidden Structure Clustering...'
now=time.clock()
C=pf.local_skeleton_clustering(tracks,d_thr=20)
print 'Done in', time.clock()-now,'s.'

print 'Reducing the number of points...'
T=[pf.approximate_ei_trajectory(t) for t in T]

print 'Showing initial dataset.'
r=fos.ren()
fos.add(r,fos.line(T,fos.white,opacity=0.1))
fos.show(r)

print 'Showing dataset after clustering.'
fos.clear(r)
colors=np.zeros((len(T),3))
for c in C:
    color=np.random.rand(1,3)
    for i in C[c]['indices']:
        colors[i]=color
fos.add(r,fos.line(T,colors,opacity=1))
fos.show(r)

print 'Some statistics about the clusters'
lens=[len(C[c]['indices']) for c in C]