def test_most_similar_mam(): xyz1 = np.array([[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0]], dtype='float32') xyz2 = np.array([[0, 1, 1], [1, 0, 1], [2, 3, -2]], dtype='float32') xyz3 = np.array([[-1, 0, 0], [2, 0, 0], [2, 3, 0], [3, 0, 0]], dtype='float32') tracks = [xyz1, xyz2, xyz3] for metric in ('avg', 'min', 'max'): # pf should be much faster and the results equivalent pf.most_similar_track_mam(tracks, metric=metric)
def skeletonize(fdpy,flsc,points=3): dpr=Dpy(fdpy,'r') T=dpr.read_tracks() dpr.close() print len(T) Td=[downsample(t,points) for t in T] C=local_skeleton_clustering(Td,d_thr=10.,points=points) #Tobject=np.array(T,dtype=np.object) #''' #r=fvtk.ren() skeleton=[] for c in C: #color=np.random.rand(3) if C[c]['N']>0: Ttmp=[] for i in C[c]['indices']: Ttmp.append(T[i]) si,s=most_similar_track_mam(Ttmp,'avg') print si,C[c]['N'] C[c]['most']=Ttmp[si] #fvtk.add(r,fvtk.line(Ttmp[si],color)) print len(skeleton) #r=fos.ren() #fos.add(r,fos.line(skeleton,color)) #fos.add(r,fos.line(T,fos.red)) #fvtk.show(r) #''' save_pickle(flsc,C)
print('singletons %d ' % lens.count(1)) print('doubletons %d' % lens.count(2)) print('tripletons %d' % lens.count(3)) """ Find and display the skeleton of most representative tracks in each cluster: """ skeleton=[] fvtk.clear(r) for c in C: bundle=[T[i] for i in C[c]['indices']] si,s=td.most_similar_track_mam(bundle,'avg') skeleton.append(bundle[si]) fvtk.label(r,text=str(len(bundle)),pos=(bundle[si][-1]),scale=(2,2,2)) fvtk.add(r,fvtk.line(skeleton,colors,opacity=1)) #fvtk.show(r) fvtk.record(r,n_frames=1,out_path='fornix_most',size=(600,600)) """ .. figure:: fornix_most1000000.png :align: center **Showing skeleton with the most representative tracks as the skeletal representation**. The numbers are depicting the number of tracks in each cluster. This is a very compact way to see the underlying structures an alternative would be to draw the representative tracks with different widths.
print('max %d min %d' % (max(lens), min(lens))) print('singletons %d ' % lens.count(1)) print('doubletons %d' % lens.count(2)) print('tripletons %d' % lens.count(3)) """ Find and display the skeleton of most representative tracks in each cluster: """ skeleton = [] fvtk.clear(r) for c in C: bundle = [T[i] for i in C[c]['indices']] si, s = td.most_similar_track_mam(bundle, 'avg') skeleton.append(bundle[si]) fvtk.label(r, text=str(len(bundle)), pos=(bundle[si][-1]), scale=(2, 2, 2)) fvtk.add(r, fvtk.line(skeleton, colors, opacity=1)) #fvtk.show(r) fvtk.record(r, n_frames=1, out_path='fornix_most', size=(600, 600)) """ .. figure:: fornix_most1000000.png :align: center **Showing skeleton with the most representative tracks as the skeletal representation**. The numbers are depicting the number of tracks in each cluster. This is a very compact way to see the underlying structures an alternative would be to draw the representative tracks with different widths.