Skip to content, Skip to search


TrakEM2 Scripting

611 bytes added, 09:05, 16 October 2010
Interacting with Treeline, AreaTree and Connector
<li>X, Y coordinates, relative to the local coordinate system of the Tree that contains the [ Node].</li>
<li>A reference to a layer (get it with nd.getLayer()). The [ Layer] has a getZ() method to get the Z coordinate (in pixels).</li>
<li>A data field, which can be a radius or a java.awt.geom.Area (see below).</li>
<li>Treeline and Connector: its nodes [ getData()] return a radius. The default value is zero.</li>
<li>AreaTree</li> : its nodes [ getData()] return a [ java.awt.geom.Area] instance, or null if none yet assigned to it.</li>
== Obtaining the X,Y,Z coordinates of all nodes in a Tree ==
Here is how to iterate over all the node's X,Y,Z positions, in world coordinates:
data = nd.getData()
print x, y, z, data
== Sorting nodes by their tags ==
<source lang="python">
from ini.trakem2.display import Display
tree = Display.getFront().getActive()
table = {}
for nd in tree.getRoot().getSubtreeNodes():
tags = nd.getTags()
if tags is None:
for tag in tags:
tagged = table[tag]
if tagged is None:
tagged = []
table[tag] = tagged
# print the number of nodes that have any given tag:
for tag, tagged in table.iter_items():
print "Nodes for tag '" + str(tag) + "':", len(tagged)
Emailconfirmed, uploaders