from path import path # Used in examples import runtrackpy movdir = path('bigtracks-demo-movie').abspath() print movdir movdir.makedirs_p() frames_extension = 'PNG' frames_pattern = '*.' + frames_extension import runtrackpy.test import scipy.misc for framenumber in range(20): x, y, img = runtrackpy.test.fake_image(framenumber) scipy.misc.imsave(movdir / 'example_%.4i.%s' % (framenumber, frames_extension), img) print runtrackpy.track.__doc__ imgfiles = movdir.glob(frames_pattern) im = imread(imgfiles[0]) def crop(): pass # If you wish, set a restricted view here, so you can zoom in on details. #xlim(0, 240) #ylim(0, 240) imshow(im) gray() colorbar() crop() gcf().set_size_inches(10, 10) params = dict(bright=1, featsize=5, bphigh=2, threshold=0.5, maxdisp=3 * sqrt(8)) features = runtrackpy.track.identify_frame(im, params) imshow(im) plot(features.x, features.y, 'r+', markersize=10) axis('image') crop() hist((features.x % 1, features.y % 1)); outputfile = movdir / 'bigtracks.h5' if outputfile.exists(): outputfile.remove() runtrackpy.track.track2disk(imgfiles, outputfile, params, #selectframes=range(1, 3), # To speed things up, we could do just 2 frames progress=True) import pantracks bt = pantracks.BigTracks(movdir / 'bigtracks.h5') bt.maxframe() bt.get_all() ftr = bt.get_frame(1) print ftr.frame.values[0] # Which frame was this, again? ftr.head() ftr = bt[1] print ftr.frame.values[0] for fnum in bt.framerange(): ftr = bt.get_frame(fnum) print fnum, len(ftr) ftr = bt.query('(x < xmax) & (y < ymax)', {'xmax': 100, 'ymax': 100}) ftr.x.max(), ftr.y.max(), ftr.frame.unique() import pandas with bt: ftr = pandas.DataFrame(bt.table.readWhere('(particle >= 2) & (particle <= 5)')) ftr.particle.min(), ftr.particle.max(), ftr.frame.unique() %%timeit for fnum in range(10): ftr = bt.get_frame(1) %%timeit with bt: for i in range(10): ftr = bt.get_frame(1) btq = pantracks.bigtracks.compute_quality(bt, frame_interval=1) btq.head() pantracks.bigtracks.plot_quality(btq)