In [26]:
# import multi tracker analysis
import multi_tracker_analysis as mta

In [27]:
# load hdf5 data as a pandas dataframe, and load the configuration
# change the argument to match your data path!
pd, config = mta.read_hdf5_file_to_pandas.load_and_preprocess_data('/home/lab/demo/demo_1/retracked/20170711_150010_N1/20170717_105053_N1_trackedobjects.hdf5')


Preprocessing data - see config file for details!
[]
Found too many, or too few files
No delete cut join instructions found in path!

In [28]:
# pandas dataframe structure: each row is a measurement corresponding to one of the objects for each frame
pd.keys()


Out[28]:
Index([u'angle', u'area', u'frames', u'measurement_x', u'measurement_y',
       u'objid', u'position_x', u'position_y', u'time_epoch_nsecs',
       u'time_epoch_secs', u'velocity_x', u'velocity_y', u'time_epoch',
       u'speed'],
      dtype='object')

In [29]:
# show the object id's
import numpy as np
np.unique(pd.objid)


Out[29]:
array([    0,     1,     2, ..., 53569, 53570, 53571])

In [30]:
position_for_10 = pd[pd.objid==10].position_x.values
position_for_10


Out[30]:
array([ 1424.,  1424.,  1424.])

In [31]:
# wrap pandas dataframe into a dataset object for intuitive processing
# note: using copy=True creates a copy of the data
#       this allows you to add attributes to trajecties and pickle the dataset structure for future use
dataset = mta.read_hdf5_file_to_pandas.Dataset(pd, config=config)
dataset.load_keys() # load the object ids
trajec = dataset.trajec(dataset.keys[7]) # load the 7th trajectory
trajec.position_x # show the position x data


Out[31]:
array([ 612.        ,  612.        ,  612.        ,  620.04771372])

In [32]:
import matplotlib.pyplot as plt
%matplotlib inline

In [33]:
# plot the trajectory; this requires downloading my plotting library: https://github.com/florisvb/FlyPlotLib
# make a heatmap of the trajectories
bgimg = mta.plot.get_filename(config.path, 'bgimg')
binsx, binsy = mta.plot.get_bins_from_backgroundimage(bgimg)
mta.plot.plot_trajectories(pd, binsx, binsy)



In [34]:
mta.plot.plot_heatmap(pd, binsx, binsy)


Out[34]:
<matplotlib.axes._subplots.AxesSubplot at 0x7ff8e2537b50>

In [ ]: