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')
In [28]:
# pandas dataframe structure: each row is a measurement corresponding to one of the objects for each frame
pd.keys()
Out[28]:
In [29]:
# show the object id's
import numpy as np
np.unique(pd.objid)
Out[29]:
In [30]:
position_for_10 = pd[pd.objid==10].position_x.values
position_for_10
Out[30]:
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]:
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]:
In [ ]: