Пример #1
0
if __name__ == '__main__':
    CLI = argparse.ArgumentParser()
    CLI.add_argument("--data", nargs='?', type=str)
    CLI.add_argument("--frame_folder", nargs='?', type=str)
    CLI.add_argument("--frame_name", nargs='?', type=str)
    CLI.add_argument("--frame_format", nargs='?', type=str)
    CLI.add_argument("--frame_rate", nargs='?', type=none_or_float)
    CLI.add_argument("--colormap", nargs='?', type=str)
    CLI.add_argument("--event", nargs='?', type=none_or_str, default=None)
    CLI.add_argument("--markercolor", nargs='?', type=str, default='k')

    args = CLI.parse_args()

    blk = load_neo(args.data)
    blk = AnalogSignal2ImageSequence(blk)

    # get data
    imgseq = blk.segments[0].imagesequences[0]
    times = blk.segments[0].analogsignals[0].times  # to be replaced
    t_start = blk.segments[0].analogsignals[0].t_start  # to be replaced
    t_stop = blk.segments[0].analogsignals[0].t_stop  # to be replaced
    dim_t, dim_x, dim_y = imgseq.shape

    optical_flow = get_opticalflow(blk.segments[0].imagesequences)

    if args.event is not None:
        up_coords = get_events(blk.segments[0].events,
                               frame_times=times,
                               event_name=args.event)
Пример #2
0
                     help="path of output image file")
    CLI.add_argument("--alpha", nargs='?', type=float, default=0.001,
                     help='regularization parameter')
    CLI.add_argument("--max_Niter", nargs='?', type=int, default=50,
                     help='maximum number of iterations')
    CLI.add_argument("--convergence_limit", nargs='?', type=float, default=10e-3,
                     help='absolute change at which consider optimization converged')
    CLI.add_argument("--gaussian_sigma", nargs='+', type=float, default=[0,3,3],
                     help='sigma of gaussian filter in each dimension')
    CLI.add_argument("--derivative_filter", nargs='?', type=str, default='Simple',
                     help='Filter kernel to use for calculating spatial derivatives')

    args = CLI.parse_args()
    block = load_neo(args.data)

    block = AnalogSignal2ImageSequence(block)
    imgseq = block.segments[0].imagesequences[-1]
    asig = block.segments[0].analogsignals[-1]

    frames = imgseq.as_array()
    # frames /= np.nanmax(np.abs(frames))

    kernelHS = np.array([[1, 2, 1],
                         [2, 0, 2],
                         [1, 2, 1]], dtype=np.float) * 1/12
    kernelT = np.ones((2, 2), dtype=np.float) * .25
    kernelX, kernelY = get_derviation_kernels(args.derivative_filter)

    vector_frames = horn_schunck(frames=frames,
                                 alpha=args.alpha,
                                 max_Niter=args.max_Niter,
    CLI.add_argument("--node_data",
                     nargs='?',
                     type=str,
                     required=True,
                     help="path to input data in neo format")
    CLI.add_argument("--output",
                     nargs='?',
                     type=str,
                     required=True,
                     help="path of output file")

    args = CLI.parse_args()
    trigger_block = load_neo(args.trigger_data)
    node_block = load_neo(args.node_data)

    block = AnalogSignal2ImageSequence(node_block)

    wavefront_evt = [
        evt for evt in trigger_block.segments[0].events
        if evt.name == "Wavefronts"
    ]
    if wavefront_evt:
        wavefront_evt = wavefront_evt[0]
    else:
        raise ValueError("Input does not contain an event with name " \
                       + "'Wavefronts'!")

    block.segments[0].events.append(wavefront_evt)

    write_neo(args.output, block)