Revision as of 17:39, 17 January 2011 by Albertcardona (talk | contribs) (Running fiji for heavy-duty, memory-intensive, high-performance TrakEM2 tasks)

TrakEM2 (ImageJ)
Author Albert Cardona
Maintainer Albert Cardona (
File TrakEM2_.jar (Included in Fiji)
Source trakem2 git repository
Initial release May 2006
Latest version 0.7m (4 December 2009)
Development status active
Category Registration, Segmentation, Image annotation, Plugins
Website TrakEM2 news and documentation

TrakEM2 is an ImageJ plugin for morphological data mining, three-dimensional modeling and image stitching, registration, editing and annotation.

See TrakEM2 snapshots for an overview.


  • Segmentation: manually draw areas across stacks, and sketch structures with balls and pipes.
  • Measurements: volumes, surfaces, lengths, and also measurements via ImageJ ROIs.
  • Image Registration: register floating image tiles to each other using SIFT and global optimization algorithms.
  • 3D Visualization: interacting with the 3D Viewer plugin, TrakEM2 displays image volumes and 3D meshes of all kinds.
  • Image Annotation: floating text labels.
  • Semantic segmentation: order segmentations in tree hierarchies, whose template is exportable for reuse in other, comparable projects.

TrakEM2 interacts with the 3D Viewer for visualization of image volumes and 3D meshes.

TrakEM2 in Fiji

  • Create new projects from "File - New - TrakEM2 (blank)"
  • Open an existing project by dragging its .xml file onto the toolbar, or via "File - Open".


Running fiji for heavy-duty, memory-intensive, high-performance TrakEM2 tasks

The following configuration has been tested in a machine with 8 CPU cores and 16 Gb of RAM, running Ubuntu 8.04 "Hardy", with a 1.6.0_16 or newer JVM:

./fiji -Xms10g -Xmx10g -Xincgc -XX:MaxPermSize=256m -XX:PermSize=256m
-XX:NewRatio=5 -XX:CMSTriggerRatio=50 -XX:+UseCompressedOops --

Put all the above in one line.

What the JVM flags mean:

  • -Xms10g : use an initial heap size of 10 Gb (i.e. start fiji with 10 Gb of RAM preallocated to it)
  • -Xmx10g: use a maximum heap size of 10 Gb. Note it's the same amount as the intial heap size, so that the heap cannot be resized.
  • -Xincgc : use the incremental garbage collector. Clean up unused memory in the concurrent mark-sweep generation (i.e. not the super-new generation of allocated objects) using parallel threads.
  • -XX:MaxPermSize=256m : set the heap size allocated to objects that don't need to be garbage often to 256 Mb. The default is only 32 Mb, which proves insufficient.
  • -XX:PermSize=256m : preallocate the heap for the permanent objects directly to the desired maximum, 256 Mb, so it doesn't ever have to be resized.
  • XX:NewRatio=5 : Set the ratio of ephemeral versus more long-lived objects to 5 (the default is 9 or more in 64-bit Sun JVMs).
  • XX:CMSTriggerRatio=50 : run the parallel garbage collector when the ratio of free versus non-free heap space is 50 % (the default is 92% in 64-bit JVM, which may incur in pauses and undesirable full sweeps).
  • XX:+UseCompressedOops : use 32-bit pointers when possible, in a 64-bit JVM. This can cut the memory footprint by half in many cases.
  • The ending double hyphen "--" is to specify all of these are JVM arguments, not fiji/ImageJ arguments.

With the above settings, we have succesfully registered 33,000 image tiles corresponding to 459 serial sections, using the "Align multi-layer mosaic" TrakEM2 command.


TrakEM2: 359 montages of 13x13 tiles of 2048x2048 pixels each.
TrakEM2 Display showing 9 images in a layer, where 2 images and one floating text label (set to 30% transparency) are selected (pink and white frames; white is the active one – note the corresponding pink and blue coloration of the object panels on the left). The Navigator (bottom left) paints a red frame to indicate the area currently displayed in the canvas (right).
3D Viewer: hardware-accelerated 3D visualization of image stacks as volumes, orthoslices and meshes. Above, secondary lineages of Drosophila third instar larval brain segmented in TrakEM2.
The three TrakEM2 trees, as an interface for editing and visualizing the three internal TrakEM2 data structures.
Example TrakEM2 segmentations, including Ball, Pipe, Profile, AreaList and floating text labels.
Effect of the CLAHE live filter in TrakEM2. Data with high dynamic range is displayed with perceptually boosted local contrast. CLAHE parameters are relative to display pixels and, therefore, will not result in an effective bandpass when zooming out largely on statically pre-processed images.