elif mode == 'single':
    if actions in ['track','both']:
        print >>logfile, "Tracking %s #%i"%(mouse,n);logfile.flush()
        mt = MouseTracker(mouse=mouse, n=n, data_dir=data_dir, diff_thresh=diff_thresh, resample=resample_t, point_mode=point_finding_mode)
        mt.run(show=show, wait=ms_bt_frames, start_pos=start_position)
    if actions in ['mark','both']:
        print >>logfile, "Marking %s #%i"%(mouse,n);logfile.flush()
        m = Marker(mouse=mouse, n=n, data_dir=data_dir, mark_mode=mark_mode)
        mres = m.run(resample=resample_m, start_time=start_time)
        if not mres[0]:
            print >>logfile, "WARNING: Marking for %s #%i declared a warning: %s"%(mouse,n,mres[1]);logfile.flush()
    if actions == 'play':
        print >>logfile, "Playing %s #%i"%(mouse,n);logfile.flush()
        pb = Playback(ymaze_path=mouse, ymaze_n=n, data_dir=data_dir)
        pb.play(draw=show_tracking)
    
elif mode == 'collect':
    mice = [m for m in os.listdir(data_dir) if exclude_word not in m.lower() and m[0]!='.' and 'summary' not in m]

    rows = []
    for mouse in mice:
        print >>logfile, mouse;logfile.flush()
        fh = FileHandler(data_dir, mouse, n=1)
        for tr in xrange(fh.get_n_trials_wbehav()):
            fhm = FileHandler(data_dir, mouse, n=tr+1)
            data = np.load(fhm.make_path('behaviour.npz'))
            dic = dict(mouse=mouse, n=tr+1, score=data['score'], time_to_correct=data['time_to_correct'], distance=data['distance'], start_time=data['start_time'])
            rows.append(dic)
    
    rows = np.array(rows)
Beispiel #2
0
                          point_mode=point_finding_mode)
        mt.run(show=show, wait=ms_bt_frames, start_pos=start_position)
    if actions in ['mark', 'both']:
        print >> logfile, "Marking %s #%i" % (mouse, n)
        logfile.flush()
        m = Marker(mouse=mouse, n=n, data_dir=data_dir, mark_mode=mark_mode)
        mres = m.run(resample=resample_m, start_time=start_time)
        if not mres[0]:
            print >> logfile, "WARNING: Marking for %s #%i declared a warning: %s" % (
                mouse, n, mres[1])
            logfile.flush()
    if actions == 'play':
        print >> logfile, "Playing %s #%i" % (mouse, n)
        logfile.flush()
        pb = Playback(ymaze_path=mouse, ymaze_n=n, data_dir=data_dir)
        pb.play(draw=show_tracking)

elif mode == 'collect':
    mice = [
        m for m in os.listdir(data_dir)
        if exclude_word not in m.lower() and m[0] != '.' and 'summary' not in m
    ]

    rows = []
    for mouse in mice:
        print >> logfile, mouse
        logfile.flush()
        fh = FileHandler(data_dir, mouse, n=1)
        for tr in xrange(fh.get_n_trials_wbehav()):
            fhm = FileHandler(data_dir, mouse, n=tr + 1)
            data = np.load(fhm.make_path('behaviour.npz'))
Beispiel #3
0
    low_addr = int(min(df['Address']), base=16)
    high_addr = int(max(df['Address']), base=16)
    max_time = max(df['Timestamp(ms)'])

    saddr = args.saddr if args.saddr and args.saddr >= low_addr else low_addr
    eaddr = args.eaddr if args.eaddr and args.eaddr <= high_addr else high_addr
    stime = args.stime if args.stime and args.stime >= 0 else 0  # Time always starts a 0
    etime = args.etime if args.etime and args.etime <= max_time else max_time

    dff = df[(df.Address >= hex(saddr)) & (df.Address <= hex(eaddr)) &
             (df['Timestamp(ms)'] >= stime) &
             (df['Timestamp(ms)'] <= etime)].reset_index(drop=True)

    playback = Playback(dff, args.mapfile, saddr, eaddr, stime, etime)
    playback.play()

# --------------------------------------------------------------------------- #
elif args.command == 'analyze':
    mapcsv = read_csv(args.mapfile)
    df = DataFrame(mapcsv)

    high_addr = int(max(df['Address']), base=16)

    if (args.blocksize < 1) or (args.blocksize > high_addr):
        print('Please provide a valid block size: [1, {0}]'.format(high_addr +
                                                                   1))
        exit()

    iblocks = args.iblocks if args.iblocks else None