Exemplo n.º 1
0
def main():
    import neurokernel.mpi_relaunch
    # default limit is low for pickling
    # the data structures passed through mpi
    sys.setrecursionlimit(RECURSION_LIMIT)
    resource.setrlimit(resource.RLIMIT_STACK,
                       (resource.RLIM_INFINITY, resource.RLIM_INFINITY))

    parser = argparse.ArgumentParser()
    parser.add_argument('-c',
                        '--config',
                        default='default',
                        help='configuration file')
    parser.add_argument('-v',
                        '--value',
                        type=int,
                        default=-1,
                        help='Value that can overwrite configuration '
                        'by changing this script accordingly. '
                        'It is useful when need to run this script '
                        'repeatedly for different configuration')

    args = parser.parse_args()

    with Timer('getting configuration'):
        conf_obj = get_config_obj(args)
        config = conf_obj.conf
        change_config(config, args.value)

    setup_logging(config)

    worker_num = config['Retina']['worker_num']
    num_rings = config['Retina']['rings']
    radius = config['Retina']['radius']
    eulerangles = config['Retina']['eulerangles']

    manager = core.Manager()

    with Timer('instantiation of retina'):
        transform = AlbersProjectionMap(radius, eulerangles).invmap
        hexagon = hx.HexagonArray(num_rings=num_rings,
                                  radius=radius,
                                  transform=transform)

        retina = ret.RetinaArray(hexagon, config)

        # sets retina attribute which is required for the generation of
        # receptive fields
        #if generator is not None:
        #    generator.generate_datafiles(0, retina)

        add_master_LPU(config, 0, retina, manager)

        for j in range(worker_num):
            add_worker_LPU(config, j, retina, manager)
            connect_master_worker(config, j, retina, manager)

    start_simulation(config, manager)
Exemplo n.º 2
0
def main():
    import neurokernel.mpi_relaunch

    # default limit is low for pickling
    # the data structures passed through mpi
    sys.setrecursionlimit(RECURSION_LIMIT)
    resource.setrlimit(resource.RLIMIT_STACK,
                       (resource.RLIM_INFINITY, resource.RLIM_INFINITY))

    parser = argparse.ArgumentParser()
    parser.add_argument('-c', '--config', default='default',
                        help='configuration file')
    parser.add_argument('-v', '--value', type=int, default=-1,
                        help='Value that can overwrite configuration '
                             'by changing this script accordingly. '
                             'It is useful when need to run this script '
                             'repeatedly for different configuration')

    args = parser.parse_args()

    with Timer('getting configuration'):
        conf_obj = get_config_obj(args)
        config = conf_obj.conf
        change_config(config, args.value)

    setup_logging(config)

    num_rings = config['Retina']['rings']
    eulerangles = config['Retina']['eulerangles']
    radius = config['Retina']['radius']

    manager = core.Manager()
    
    with Timer('instantiation of retina and lamina'):
        transform = AlbersProjectionMap(radius, eulerangles).invmap
        r_hexagon = r_hx.HexagonArray(num_rings=num_rings, radius=radius,
                                      transform=transform)
        l_hexagon = l_hx.HexagonArray(num_rings=num_rings, radius=radius,
                                      transform=transform)

        retina = ret.RetinaArray(r_hexagon, config)
        lamina = lam.LaminaArray(l_hexagon, config)

        add_retina_LPU(config, 0, retina, manager)
        add_lamina_LPU(config, 0, lamina, manager)

        connect_retina_lamina(config, 0, retina, lamina, manager)

    start_simulation(config, manager)
Exemplo n.º 3
0
def main():

    from retina.screen.map.mapimpl import AlbersProjectionMap
    import retina.geometry.hexagon as hex
    from retina.configreader import ConfigReader
    import retina.retina as ret
    import networkx as nx
    config = ConfigReader('retlam_default.cfg', '../template_spec.cfg').conf
    transform = AlbersProjectionMap(config['Retina']['radius'],
                                    config['Retina']['eulerangles']).invmap
    hexarray = hex.HexagonArray(num_rings=14,
                                radius=config['Retina']['radius'],
                                transform=transform)
    a = ret.RetinaArray(hexarray, config)
    G = a.generate_neuroarch_gexf()
    nx.write_gexf(G, 'retina_neuroarch.gexf.gz')
Exemplo n.º 4
0
def gen_input(config):
    cuda.init()
    ctx = cuda.Device(0).make_context()
    atexit.register(ctx.pop)

    suffix = config['General']['file_suffix']

    eye_num = config['General']['eye_num']

    rings = config['Retina']['rings']
    steps = config['General']['steps']

    input_filename = config['Retina']['input_file']
    
    screen_write_step = config['Retina']['screen_write_step']
    config['Retina']['screen_write_step'] = 1
    
    screen_type = config['Retina']['screentype']
    screen_cls = cls_map.get_screen_cls(screen_type)
    eulerangles = config['Retina']['eulerangles']
    radius = config['Retina']['radius']

    for i in range(eye_num):
        screen = screen_cls(config)
        screen_file = 'intensities_tmp{}.h5'.format(i)
        screen.setup_file(screen_file)
    
        retina_elev_file = 'retina_elev{}.h5'.format(i)
        retina_azim_file = 'retina_azim{}.h5'.format(i)

        screen_dima_file = 'grid_dima{}.h5'.format(i)
        screen_dimb_file = 'grid_dimb{}.h5'.format(i)

        retina_dima_file = 'retina_dima{}.h5'.format(i)
        retina_dimb_file = 'retina_dimb{}.h5'.format(i)

        input_file = '{}{}{}.h5'.format(input_filename, i, suffix)

        transform = AlbersProjectionMap(radius,
                                        eulerangles[3*i:3*(i+1)]).invmap
        hexagon = hx.HexagonArray(num_rings=rings, radius=radius,
                                  transform=transform)
        retina = ret.RetinaArray(hexagon, config=config)
        print('Acceptance angle: {}'.format(retina.acceptance_angle))
        print('Neurons: {}'.format(retina.num_photoreceptors))

        elev_v, azim_v = retina.get_ommatidia_pos()

        rfs = _get_receptive_fields(retina, screen, screen_type)
        steps_count = steps
        write_mode = 'w'
        while (steps_count > 0):
            steps_batch = min(100, steps_count)
            im = screen.get_screen_intensity_steps(steps_batch)
            photor_inputs = rfs.filter(im)
            sio.write_array(photor_inputs, filename=input_file, mode=write_mode)
            steps_count -= steps_batch
            write_mode = 'a'
        
        tmp = sio.read_array(screen_file)
        sio.write_array(tmp[::screen_write_step],
                        'intensities{}{}.h5'.format(suffix, i),
                        complevel = 9)
        del tmp
        os.remove(screen_file)

        for data, filename in [(elev_v, retina_elev_file),
                               (azim_v, retina_azim_file),
                               (screen.grid[0], screen_dima_file),
                               (screen.grid[1], screen_dimb_file),
                               (rfs.refa, retina_dima_file),
                               (rfs.refb, retina_dimb_file)]:
            sio.write_array(data, filename)