Skip to content

Instantly share code, notes, and snippets.

@aleph-ra
Created June 21, 2015 18:34
Show Gist options
  • Save aleph-ra/30ccd7e10fb367bff8b1 to your computer and use it in GitHub Desktop.
Save aleph-ra/30ccd7e10fb367bff8b1 to your computer and use it in GitHub Desktop.
OpenWormReader.py
from NeuroMLUtilities import ConnectionInfo
import PyOpenWorm as P
############################################################
# A simple script to read the values in PyOpenWorm
############################################################
class OpenWormReader:
def __init__(self):
P.connect()
self.net = P.Worm().get_neuron_network()
self.all_connections = list(self.net.synapses())
def read(self):
conns = []
cells = []
for s in self.all_connections:
pre = str(s.pre_cell())
post = str(s.post_cell())
syntype = str(s.syntype())
num = int(s.number())
synclass = str(s.synclass())
conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if pre not in cells:
cells.append(pre)
if post not in cells:
cells.append(post)
print("Total cells read "+ str(len(cells)))
print("Total connections read "+ str(len(conns)))
return cells, conns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment