Skip to content
Skip to search
1,060 bytes added
12:03, 2 July 2015
Interact with a Ball object
== Export all Ball objects as a CSV file ==
# Open a text window containing all Ball objects as a CSV file,
# in calibrated coordinates.
# The text window has a "File - Save" menu for saving to a file.
# Albert Cardona 2015-07-02 for Jemima Burden at UCL.
# See also the API of the Ball class:
from ini.trakem2.display import Display, Ball
from ij.text import TextWindow
ball_obs = Display.getFront().getLayerSet().getZDisplayables(Ball)
# One entry for each id,x,y,z,r
rows = 
# Iterate every Ball instance, which contains one or more x,y,z,r balls
for ball_ob in ball_obs:
id = ball_ob.getId()
# Iterate every x,y,z,r ball of a Ball instance, calibrated
wbs = ball_ob.getWorldBalls()
for ball_coords in wbs:
# Store every ball as a row with id, x, y, z, r
rows.append(str(id) + "," + ",".join(str(c) for c in ball_coords))
csv = "\n".join(rows)
t = TextWindow("Balls CSV", csv, 400, 400)
← Older edit
Newer edit →
Retrieved from "
Set/change upload password