Exemple #1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('cells_csv', help='CSV containing cell metadata')
    parser.add_argument('connections_h5',
                        help='HDF5 file containing cell connectivity')
    parser.add_argument('network_vtk_file', help='.vtk output file')
    parser.add_argument('--manifest')
    parser.add_argument('--morphology_vtk_file')

    args = parser.parse_args()

    # read in the cell CSV
    with open(args.cells_csv, 'r') as f:
        r = csv.DictReader(f)
        cells = list(r)

    # read in the connections from the H5 file
    h5u = Hdf5Util()
    connections = h5u.read(args.connections_h5)

    # write out the results
    write_network_vtk(args.network_vtk_file, cells, connections)

    if args.manifest:
        config = ju.read(args.manifest)
        manifest = Manifest(config['manifest'],
                            relative_base_dir=os.path.dirname(args.manifest))
        write_morphology_vtk(args.morphology_vtk_file, cells, manifest)
Exemple #2
0
    def load_connectivity(self):
        '''
        load the connectivity matrix from the hdf5 file in the CSR format - efficient for large networks
        '''

        h5u = Hdf5Util()
        
        con_path = self.description.manifest.get_path('CONNECTIONS')
        con = h5u.read(con_path)
        
        return con
Exemple #3
0
# cell positions
positions = np.random.random((N, 3))

# initialize the network
net = Network()

# add some populations
net.add_population(N_inh, type='inhibitory')
net.add_population(N_exc, type='excitatory')

# add the connectivity rule
net.connect(random_connectivity)

# build the matrix
cells, connections = net.build()

print len(connections)

# turn it into a sparse matrix
m = construct_matrix(connections)

# the connectivity to hdf5
Hdf5Util().write('connections.h5', m)

cells = pd.DataFrame.from_dict(cells)
cells['x'] = positions[:, 0]
cells['y'] = positions[:, 1]
cells['z'] = positions[:, 2]

cells.to_csv('cells.csv', index=False)