Created
June 21, 2015 18:34
-
-
Save aleph-ra/30ccd7e10fb367bff8b1 to your computer and use it in GitHub Desktop.
OpenWormReader.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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