In previous posts, we’ve almost taken for granted how Fiji/ImageJ deals with multidimensional data. Whenever you have more than one image, be it a second channel all the way up to massive 5D datasets, you’re dealing with stacks.
This concept is so fundamental, I thought it deserving of it’s own post. Let’s stack ’em up.
A stack is just a linear collection of images. In the example below, let’s assume we have a single-channel, single-slice time course with ‘n’ frames:
Easy. A single dimension (which can be frames, slices or channels, or none of these if for example, you’re compositing something for a montage) is represented as a linear stack. Thus, if you wanted to delete a time point, you can simply run [ Image > Stacks > Tools > Slice Remover ] and delete, say, the 5th slice.
When you have more than one dimension, this is normally displayed as a hyperstack. You can tell if your stack is being displayed as a hyperstack because you will have multiple control bars underneath the image:
You might think (as the bars would suggest,) that the images are organised in a matrix. Something like this:
But you’d be wrong. The hyperstack is just a convenient way of handling dimensionality. In fact the images are all organised (as with the first example) in a linear fashion:
Travel with me into another dimension…
Not the most original of names, but you can’t fault its accuracy. Every hyperstack and indeed every stack has a property called the “Dimension Order”. This string simply represents in what order the dimensions (slices, frames or channels) are stored. Using our example above, the order would be XYCTZ, denoting that for each time point all of the channels are provided before the next time point begins. Compare this to the same example but in XYTCZ:
Of course you can have any permutation of Dimension Order and it won’t (assuming that it’s correct) affect the way your images are displayed.
It’s worth pointing out that one of only a few non-proprietary formats which can store multiple images within one container (video formats aside) is the good old Tagged Image Format (TIF). The Dimension Order (as well as the dimension size) is stored in the file header, so any programs which open TIF stacks know into which dimension the following images should be allocated.
Why this is good to know
For the most part, this is probably not that important to the end user. It only really becomes relevant when you start manipulating stacks, when it’s crucial. Consider the following stack with 2 channels 3 slices and 5 time points (in XYCZT order):
Say for example, you wanted to delete the third slice (z=3) from the stack. In XYCZT order (above) you would need to remove images 5, 6, 11 and 12. If however, the stack is in XYTCZ (below), you would need to remove images 9-12.
Epilogue: Some Useful Tools for Stack Manipulation
This post has mostly been based on the theory of stacks, but there are some great tools built into Fiji for stack manipulation. This handy graphic from the Fiji website covers some of the basics:
One of the most useful tools that I’ve found for working with stacks is [ Image > Duplicate ]. When dealing with Hyperstacks, extra options appear which let you fully duplicate a stack or substack to a particular range. You can use hyphen-separated ranges as below, or single values (at this point, comma separated lists don’t work).
Finally, if you have Fiji installed (instead of ImageJ) the Stack Sorter (found at [ Image > Stacks > Tools > Stack Sorter ] ) deserves a mention. It’s a very handy tool for shuffling a few images around, for instance if you want to get several images in order to make a montage.