Skip to content, Skip to search


TrakEM2 Scripting

52 bytes added, 09:12, 16 October 2010
Find out at which nodes the tree is connected to other trees, via Connector
<source lang="python">
from ini.trakem2.display import Display, Connector
from jarray import zerosarray
from java.awt.geom import Area
# Obtain the currently selected treeline or areatree:
tree = Display.getFront().getActive()
affine = tree.getAffineTransform()
layerset = tree.getLayerSet()
# Maps of nd vs list of trees:
outgoing = {} # e.g. presynaptic to some trees
for nd in tree.getRoot().getSubtreeNodes():
# Obtain the node position in world coordinates
fp = zerosarray([nd.xgetX(), nd.ygetY()], 'f')
affine.transform(fp, 0, fp, 0, 1)
x, = int(fp[0]) y = int(fp[1])
# Query the LayerSet for Connector objects that intersect it
cs = layerset.findZDisplayables(Connector, nd.getLayer(), x, y, False)
if cs.isEmpty():
if len(targets) > 0:
outgoing[nd] = targets
# print the map of nodes and the number of trees each connects to:
for node, targets in outgoing.iteritems():
Emailconfirmed, uploaders