@@ -22,7 +22,6 @@ def neuron_graph(id_list, proj_opts):
2222
2323 return g
2424
25-
2625def neuron_graph_from_annotations (annotation_list , proj_opts , anno_dict = None , append_annotations = True ):
2726 # Build a neuron graph from a readable list of annotation strings
2827 if anno_dict is None :
@@ -44,7 +43,6 @@ def neuron_graph_from_annotations(annotation_list, proj_opts, anno_dict=None, ap
4443
4544 return g
4645
47-
4846def append_annotation_list (g , annotation_list , proj_opts , anno_dict = None ):
4947 # Given a list of annotations (as a string), add a node property to each
5048 # skeleton containing which annotations they have
@@ -65,7 +63,6 @@ def append_annotation_list(g, annotation_list, proj_opts, anno_dict=None):
6563 print ('Not a valid key: ' + anno + ' (skipping)' )
6664 return g
6765
68-
6966def write_node_info (g , filename , delimiter = ',' ):
7067 f_nodeinfo = open (filename , 'w' )
7168 for id , node in g .nodes_iter (data = True ):
@@ -257,6 +254,16 @@ def __init__(self, conn_ids, proj_opts ):
257254 conndata = ci .get_connector_data ( post_conn_ids , proj_opts )
258255 self .connectors = { dat [0 ] : dat [1 ] for dat in conndata }
259256
257+ def annotations_from_neurons ( neurons , proj_opts ):
258+ anno_dat = ci .get_annotations ( [nrn .id for nrn in neurons ], proj_opts )
259+ anno_dict = {}
260+ for anno_id in anno_dat ['annotations' ]:
261+ anno_dict [ int (anno_id ) ] = {'str' : anno_dat ['annotations' ][anno_id ], 'skids' : [] }
262+ for skid in anno_dat ['skeletons' ]:
263+ for anno_info in anno_dat ['skeletons' ][skid ]:
264+ anno_dict [ anno_info ['id' ] ][ 'skids' ].append ( int (skid ) )
265+ return anno_dict
266+
260267def neurons_from_annotations ( annotation_list , proj_opts ):
261268 anno_dict = ci .get_annotation_dict ( proj_opts )
262269 id_list = ci .get_ids_from_annotation ( [anno_dict [anno ] for anno in annotation_list ], proj_opts )
@@ -266,16 +273,15 @@ def neurons_from_annotations( annotation_list, proj_opts ):
266273def neurons_from_id_list (id_list , proj_opts ):
267274 # Given a list of ids, build a list of NeuronObjs
268275 # associated with them, if one is already pre-existing
269- neurons = [ NeuronObj (id , proj_opts ) for id in id_list ]
276+ neurons = { id : NeuronObj (id , proj_opts ) for id in id_list }
270277 return neurons
271278
272279def get_adjacency_matrix ( neurons , input_normalized = False ):
273280 # Build a weighted adjacency matrix from neurons
274281 A = np .zeros ( (len (neurons ), len (neurons )) )
275- skid_to_ind = { skid :ii for ii , skid in enumerate ([nrn .id for nrn in neurons ])}
276- ind_to_skid = { ii :skid for ii , skid in enumerate ([nrn .id for nrn in neurons ])}
277- ids = [nrn .id for nrn in neurons ]
278- for nrn in neurons :
282+ skid_to_ind = { skid :ii for ii , skid in enumerate (neurons ) }
283+ ind_to_skid = { ii :skid for ii , skid in enumerate (neurons )}
284+ for nrn in neurons .values ():
279285 for conn_id in nrn .outputs .target_ids :
280286 for targ in nrn .outputs .target_ids [conn_id ]:
281287 if targ in ids :
@@ -308,7 +314,7 @@ def find_ids_by_name( neurons, name_pattern ):
308314 ids_found = []
309315 return [ nrn .id for nrn in neurons if re .search (name_pattern , nrn .name ) is not None ]
310316
311- def number_inputs ( neurons ):
317+ def number_ginputs ( neurons ):
312318 return [nrn .inputs .num () for nrn in neurons ]
313319
314320def number_outputs ( neurons ):
0 commit comments