Skip to content, Skip to search



2,160 bytes added, 27 January
For importing large collections of images and editing them immediately afterwards: update link: Jython Scripting moved to Jython Scripting Examples a while ago
{{Infobox Plugin| software = ImageJ| name = TrakEM2| author = Albert Cardona| maintainer = Albert Cardona ([])| filename = fiji:TrakEM2_.jar (Included in Fiji) | source = [ trakem2 git repository]| released = May 2006| latest version = 0.8n (April 12, 2011)| status = active| category = [[:Category:Registration|Registration]], [[:Category:Segmentation|Segmentation]], [[:Category:Image annotation|Image annotation]], [[:Category:Plugins|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.
== Features ==
* [[TrakEM2 tutorials]] with video tutorials.
* Examples of [[TrakEM2 Scripting|scripting in TrakEM2]].
* Writing [[TrakEM2_TPlugIn|plugins for TrakEM2]].
== 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 ImageJ-linux64 -Xms10g -Xmx10g -Xincgc -XX:MaxPermSize=256m -XX:PermSize=256m
-XX:NewRatio=5 -XX:CMSTriggerRatio=50 -XX:+UseCompressedOops --
import ij.IJ;, "Enhance Local Contrast (CLAHE)", "blocksize=127"
+ "histogram=256 maximum=3 mask=*None* fast_(less_accurate)");
To set the script to all images, save the above to a file named "whatever.bsh" (notice the filename extension ".bsh") and then right-click on the TrakEM2 canvas and choose "Script - Set preprocessor script layer-wise", and choose the whole range of layers. This will set the script to every image of every layer, and trigger mipmap regeneration for every image. When TrakEM2 loads the image, the script will run on the image before TrakEM2 ever sees its contents.
The preprocessor script gives you maximum power: do whatever you want with the image. For example, [[Jython ScriptingExamples#Correct_illumination_in_a_stack:_apply_the_illumination_of_one_slice_to_all_others | normalize the image]] relative to a known good mean and standard deviation for your data set.
=== For regenerating mipmaps the fastest possible ===
The default generation of mipmaps is done with are averaging, and is pretty fast. Still, you may want to consider parallelizing it: go to "Project - Properties...", and set the mipmap threads to the number of cores in your machine, for example 12. Stop reading if you are satisfied with the default quality of scaled images in TrakEM2. If you choose to generate mipmaps using Gaussians, go to "Project - Properties...", and set the mipmaps mode to "Gaussian". Then, you must take care of the following: In TrakEM2 0.9a and later, the mipmaps machinery uses can use a multi-threaded Gaussian implementation now present in the latest ImageJ. This means that now there are two sets of threads:
If your machine has 12 cores, the default settings will use 12 threads 1 thread for mipmaps and 12 threads for gaussian blurring. This means that, may not fit your data properties: you may end up waiting long times for mipmap generation if you your images are regenerating 12 or more images, there will be 12 + 12 * 12 = 156 concurrent threads. That's too many threadssmall.
You must decide between two Two strategiesare possible for accelerating Gaussian-based generation of mipmaps:
<li><b>Strategy A</b>: your data consists of large images (over 4000x4000). Right-click on the TrakEM2 display and choose "Project - Properties...", and set the mipmap threads to 1(the default). Now, mipmaps will be regenerated for one single image at a time, using 12 threads (given 12 cores) for computing the Gaussians.</li> <li><b>Strategy B</b>: your data consists of small images (smaller than 4000x4000). Go to the Fiji window and select "Edit - Options - Memory & Threads...", and set the number of threads to 1. Then, go to "Project - Properties...", and set the mipmap threads to 12. Now, mipmaps will be regenerated for 12 images at a time (given 12 cores), using a single thread for each to compute the Gaussians.</li>
Use <b>strategy A</b> as well if your computer has little RAM, or if access to the images is slow and contentious (such as if the data lives in a USB hard drive). That's why the default is one single thread for generating mipmaps.
If you change the method for generating mipmaps to a non-Gaussian method, the above situation does not occur. Set the number of threads for regenerating mipmaps to the number of cores, or less if your computer doesn't have much RAM.
=== Faster XML loading and less memory consumption with larger quadtree buckets ===
Besides choosing an appropriate mipmap generation strategy for large images, make sure that you set as well the bucket size appropriately.
What is a bucket in TrakEM2: each layer (each section) has an internal [ quadtree] to be able to find an object (e.g. an image) under the mouse, or to be able to quickly find images that overlap with other images. In other words, to be able to perform fast spatial queries such as finding the list of all images that intersect a given rectangle.
If the bucket size is small (the default is 4096 pixels on the side, and a bucket is then a square of 4096x4096 pixels, which could be considered quite small), then in combination with a very large canvas size there will be way too many buckets generated. <b>Will take a lot of time and also consume a lot of memory</b>.
If your sections only have about 100 images each, and images are somewhat large (say, each has dimensions of 8096x8096 pixels), then set the bucket size to a much larger value than the default, for example to 100000. Effectively there will be only one bucket.
Small buckets make sense when there are many small objects in a layer or many small zdisplayable objects. In that situation, such as a single image per layer, but many smaller Ball or Pipe or AreaList objects on it, then go for the default bucket size (4096) or smaller. Otherwise, go for big or even very big, effectively removing the buckets functionality and reducing to list search, which is just fine for small lists of images like about 100.
When registering/aligning a collection of 400,000 images spread over 5,000 sections, it makes sense to make the buckets large (like 40960, 10x the default, or even larger than that).
Setting the bucket size to a large value will reduce XML loading time <b>a lot</b>.
To set the bucket size, right-click and choose "Display - Properties ..." and write in the bucket size value.
== How much RAM should I allocate to the JVM for Fiji to run TrakEM2? ==
[[Image:TrakEM2-display-2.png|thumb|left|232px|[[TrakEM2]] showing one section of a serial section transmission electron microscopy (ssTEM) data set, with numerous neuronal arbors reconstructed using [ treelines] and [ connectors] (for synapses).]]
[[Image:TrakEM2_Display_segmentations.png|thumb|left|232px|Example TrakEM2 segmentations, including Ball, Pipe, Profile, AreaList and floating text labels.]]
== Publication ==
----* {{Publication | TrakEM2}}
[[Category:Image annotation]]
Bureaucrat, emailconfirmed, incoming, administrator, uploaders