Page history Edit this page How do I edit this website?
Original MediaWiki page

3D Viewer › 4D Viewer

The content of this page has not been vetted since shifting away from MediaWiki. If you’d like to help, check out the how to help guide!

How to visualize 4D data

You can download example source code for this HowTo here.

Sometimes, 3D data are recorded over time, and it is desirable to visualize those data, i.e. show it in a time line, being able to animate it, etc. This is possible with the viewer. The following lines of code show how to do it programmatically:

// Open a hyperstack
ImagePlus imp = IJ.openImage(
      Prefs.getImagesURL() + "");

// Create a universe and show it
Image3DUniverse univ = new Image3DUniverse();;

// load the stack in the viewer

// get the Timeline object
Timeline tl = univ.getTimeline();

// start playback;

// wait a bit
try {
} catch(InterruptedException e) {}

// Stop animation

The 3D viewer automatically recognizes hyperstacks and shows a control panel on demand, providing buttons for playback, pause, etc.

Image3DUniverse allows to retrieve a Timeline object, which allows to call the corresponding functions programmatically.

Important methods of Viewer4D

Next to play() and pause(), the Timeline class provides several methods for stepping through the time frames of the 4D data:

/** Set bounce-back or repeat */
public void setBounceBack(boolean bounce);
public boolean getBounceBack();

/** Speed up the animation. */
public void faster();

/** Slows the animation down. */
public void slower();

/** Record the whole timeline */
public ImagePlus record();

/** Start animation.  */
public synchronized void play();

/** Stop/pause animation */
public synchronized void pause();

/** Display next timepoint. */
public void next();

/** Display previous timepoint. */
public void previous();

/** Display first timepoint. */
public void first();

/** Display last timepoint. */
public void last();