Example #1
0
def tracking(video):
    # print "running tracking"
    pimsFrames = pims.Video(video, as_grey=True)
    cells = []
    track = []
    for frame in pimsFrames[:]:
        f = tp.locate(frame, 301, invert=False, minmass=2000)
        t = tp.link_df(f, 5)  #remember cells after they left frame
        tp.annotate(f, frame)
        cells += f
        track += t
        print t.head()
    tp.plot_traj(t)
    return t.head()
def tracking(video):
    # print "running tracking"
    pimsFrames = pims.Video(video, as_grey = True)
    cells = []
    track = []
    for frame in pimsFrames[:]:
        f = tp.locate(frame, 301, invert=False, minmass = 2000)
        t = tp.link_df(f, 5) #remember cells after they left frame
        tp.annotate(f, frame)
        cells += f
        track += t
        print t.head()
    tp.plot_traj(t)
    return t.head()
Example #3
0
def fn_print(data_file):
    df = pd.read_csv(data_file)
    df.max_rss /= 1e6
    mem = df.sort_values(by="max_rss", ascending=False)
    time = df.sort_values(by="time", ascending=False)

    print(
        tabulate([list(r) for _, r in mem.head(10).iterrows()],
                 headers=("file", "max_rss [M]", "time [s]"),
                 floatfmt=("", ".2f", ".2f")))
    print()
    print(
        tabulate([list(r) for _, r in time.head(10).iterrows()],
                 headers=("file", "max_rss [M]", "time [s]"),
                 floatfmt=("", ".2f", ".2f")))
for index, row in tmp_plt.iterrows():
    ax.text(row.name,
            row.percent,
            round(row.percent, 1),
            color='black',
            ha="center",
            fontsize=20)
plt.title("Popular search terms", fontsize=20)
plt.xlabel('keywords', fontsize=18)
plt.ylabel('percent', fontsize=18)

# dwelling time: which url/action do people spend most time on?
# event duration may need to be redefined
time = t.groupby(['url', 'action'])['event_duration'].sum().reset_index()
time = time.sort_values('event_duration', ascending=False)
time.head(20)  # .to_csv('longest_actions.csv')

# most frequent event
t['counter'] = 1
t['counter'] = t.groupby(['url', 'action'])['counter'].transform(sum)
t.sort_values('counter', ascending=False).drop_duplicates(
    ['counter', 'action'])[['counter', 'url',
                            'action']].head(20).to_csv('top_actions.csv')

# visitors per day
t.groupby('date')['user'].nunique().mean()
t.groupby('date')['UUID'].nunique().mean()

# traffic by DOW
ss = t.groupby('DOW')['UUID'].nunique().reset_index()
ax = sns.barplot(x="DOW", y="UUID", data=ss)