Beispiel #1
0
def check_concurrency_data(tset_errors):
    start_times = [utils.hcm_time_to_ct_string(t) for t in tset_errors[:, 0]]
    durations = np.diff(tset_errors).T[0]
    code, instances, threshold, msg = (6, len(durations), None, "")
    for t, d in zip(start_times, durations):
        msg += "CT{}:({:02.2f}min)\n".format(t, d / 60)
    return code, instances, threshold, msg
Beispiel #2
0
def zoom_in_xaxis(ax, tstart, tend, tstep=None, label_rotation=90):
    ax.set_xlim(tstart, tend)
    tstep = get_tstep(tstart, tend) if tstep is None else tstep
    xticks = np.arange(tstart, tend, tstep)
    xticklabels = [
        utils.hcm_time_to_ct_string(xtick) for xtick in (xticks + 7) * 3600
    ]
    ax.set_xticks(xticks)
    ax.set_xticklabels(xticklabels, fontsize=8, rotation=label_rotation)
Beispiel #3
0
def check_velocity(data, threshold=300):
    t = data['preprocessing']['t']
    vel = data['preprocessing']['velocity']
    idx = vel > threshold  # cm/s
    code, instances, msg, window = 0, 0, "", list()
    if idx.any():
        code = 2
        instances = idx.sum()
        for tt in t[idx]:
            msg += "CT{};\n".format(utils.hcm_time_to_ct_string(tt))
            t1 = utils.hcm_time_to_ct(tt - 600)
            dt = 600 / 3600.
            window.append([t1, dt])
    return code, instances, "{}cm/s".format(threshold), msg, window
Beispiel #4
0
def plot_manual_zoomin(md, tstart, dt, tstep, VEL=True):
    md_data = md.data['preprocessing']
    tend = tstart + dt
    ts, te = [
        utils.hcm_time_to_ct_string((x + 7) * 3600) for x in (tstart, tend)
    ]
    print "plotting manual Zoom-In: CT{} to CT{} ..".format(ts, te)
    fig, ax = plt.subplots(figsize=(10, 3))
    plot_md(ax, md_data, lw=1)
    if VEL:
        plot_velocity(ax, md_data)
    zoom_in_xaxis(ax, tstart, tend, tstep)
    show_timeset_durations(ax, md_data, tstart, tend)
    figtitle = 'Experiment: {}\ngroup: {}, {}, day: {}\nZoom-In: CT{} to CT{}'.format(
        md.experiment.name, md.group.name, md.mouse.name, md.day, ts, te)
    plot_utils.add_figtitle(fig, figtitle, y=1.12)
    return fig, ts, te
Beispiel #5
0
def error_starts_durations(tset, long_idx):
    longest_idx = np.where(long_idx > 0)[0]
    starts = [x for x in tset[longest_idx, 0]]
    start_times = [utils.hcm_time_to_ct_string(t) for t in starts]
    durations = [x for x in (tset[longest_idx, 1] - tset[longest_idx, 0])]
    return starts, start_times, durations
Beispiel #6
0
                                lw=0.1,
                                fc=color,
                                ec=color)
        ax.add_patch(pat)

set_layout(ax)
draw_sctive_state_durations(ax, md_data)
draw_rectangle_around_active_state(ax, tstart, tstart + dt)

fname = "SSpaper2_fig1_{}".format(md.filename_long + f_suffix)
plot_utils.save_figure(md.experiment, fig, res_subdir, fname)

# # zoomin
tbin = [utils.ct_to_hcm_time(tstart), utils.ct_to_hcm_time(tstart + dt)]
md.cut_md_data(tbin)
tend = tstart + dt
ts, te = [utils.hcm_time_to_ct_string((x + 7) * 3600) for x in (tstart, tend)]
print "plotting manual Zoom-In: CT{} to CT{} ..".format(ts, te)
fig, ax = plt.subplots(figsize=(10, 3))
draw_distance_and_loco_events(ax, md_data, lw=1)
draw_timesets(ax, md_data)
set_layout(ax)
zoom_in_xaxis(ax, tstart, tend, tstep, label_rotation=0)
show_timeset_durations(ax, md_data, tstart, tend)

ts, te = [x.replace(':', '') for x in (ts, te)]
# save figure
fname2 = "SSpaper2_fig1_{}_zoomin_CT{}_CT{}{}".format(md.filename_long, ts, te,
                                                      f_suffix)
plot_utils.save_figure(md.experiment, fig, res_subdir, fname2)
Beispiel #7
0
 def __str__(self):
     return "group{}: {}, indv{}: {}, day: {}, [{} -> {}] Active for {}m {}s".format(
         self.group.number, self.group.name, self.mouse.number,
         self.mouse.name, self.day, hcm_time_to_ct_string(self.starttime),
         hcm_time_to_ct_string(self.endtime),
         *seconds_to_mins_and_secs_tuple(self.duration))