3D and 4D images – stacks and hyperstacks

Digital images are not only bidimensional (2D) or multichannel (2D with several channels). We may have several 2D images with spatial, temporal, or any kind of relationship between them. These kinds of images are managed by ImageJ as stacks and hyperstacks. Stacks have three spatial dimensions: x, y, and z. Hyperstacks have four dimensions (x, y, z, and time) and both may also have several channels. As you may be thinking, these two kinds of images are really powerful, since almost any kind of single experiment that provides image results which are somehow related can be handled with them. Now, every image position is not a pixel but a voxel (it has volume), and has three or more dimensions. There is no need that all the dimensions are different from one, and consequently stacks are a subgroup of hyperstacks.

Let's open one sample stack to start familiarizing with this concept. Open the sample image described as T1 head (file t1-head.zip). This stack corresponds to a Magnetic Resonance Imaging (MRI) acquisition of a patient's head, so every 2D image is a slice showing the internal anatomy. You can move slice by slice with the arrow keys or your mouse wheel, or automatically by clicking on the small play icon in the bottom left of the image window (by right-clicking on the same icon, animation options can be accessed). Image | Show info… (Ctrl + I) displays the metadata information from the image file, providing details on the image acquisition as free text. To display the scale in every dimension, navigate to Image | Properties... (Ctrl + Shift + P) and you will see the window shown in the right-hand side of the following screenshot:

3D and 4D images – stacks and hyperstacks

Stack image with Image Properties window on the right. The 2D dimensions are shown in the image window (256x256), and the current slice on the left is number 58 out of 129. The scaling for every dimension is shown in the properties window (on the right).

All images in the stack must have the same 2D dimensions. ImageJ uses pixel width, height, and voxel depth as scaling factors to convert voxel coordinates into mm (as in this image, the unit of length is mm), and show them as usual on the status bar.

So now that we understand the basic concepts on stacks, let's start playing with them. The fact that we now have three dimensions will allow lots of processing steps to be applied to these images. You will find most operations available in the Image | Stacks menu. The first operation you will find, deals with adding or deleting slices. When you add a slice, it is placed after the current one in the stack and it is filled with background intensity, and when you choose to delete a slice, the current one will be removed from your stack; the "z" dimension will be updated in both cases. You can move forwards and backwards slice by slice from this menu and also go to a specific slice number.

If for any reason you want to convert your nice 3D stack into a set of 2D individual images, you can do it easily with Image | Stacks | Stack to Images. If you try to do this with the previously opened sample (T1 head), ImageJ will warn you because creating 129 images (in their corresponding windows) may not be a good idea. The inverse operation is also available (Image | Stacks | Images to Stack), which is useful in case you have different 2D images that could in fact be processed together as a stack. If you need to do this with a large number of images, you may place all your 2D individual images in the same folder, with the desired slice number in every file name, and drag-and-drop the folder in ImageJ status bar. ImageJ will read all images in the folder, sort them according to the file names, and create a stack. Afterwards, you can introduce scaling for every dimension and other parameters using Image | Properties (Ctrl + Shift + P).

Moving through the slices of a stack using the scrolling bar is a good way to explore your data, but sometimes it can be convenient to present all your 3D data in a single image. Image | Stacks | Make Montage... will help you in this process. The following screenshot depicts this process on our T1 head sample stack:

3D and 4D images – stacks and hyperstacks

Montage created from T1 head stack. Window on the left is a Montage created with options shown on the right.

Since this stack has 129 slices, we have modified the Montage options to display a grid with 6 columns and 4 rows, starting on slice number 10 (the first 9 slices were almost black), and including in the Montage, one of each five slices (Increment = 5). If Label Slices is checked (as in our example) you will see the slice label overimposed. We have modified the default Font Size to a larger value in order to display the labels correctly (Font Size = 32). All these values are not the ones that ImageJ fills in when you open the Montage interface for the T1 head image, so it can be a good exercise for you to modify them and see how different Montages are created.

All those 2D images integrated as a stack are, therefore, a 3D matrix of data, with an intensity value for every matrix position or voxel. Because of this, the 2D images that are displayed in the previous example are one possible way of reading your data, the 2D image is created reading "x" and "y" positions with a fixed "z" value. But if for instance, we fix the "x" coordinate and create a new 2D images reading "y" and "z" positions, we will be creating slices that are orthogonal to the ones in Montage. This can be done using Image | Stacks | Reslice... (/).You will need to select the direction of your new slicing (starting at left, top...) and the spacing of your new slices. When you click on OK, ImageJ will create a new stack with the desired orientation.

Reslicing probably has helped you in understanding the concept of stacks as 3D images. But it is a static process; you describe the new slicing, create a new stack, and done. With the same concept, but implemented in an interactive way, you can explore your 3D data. This option is accessed from Image | Stacks | Orthogonal Views (Ctrl + Shift + H), and is something commonly available at medical workstations:

3D and 4D images – stacks and hyperstacks

Orthogonal views applied to sample image T1 head. Original stack (top-left) and two new stacks created from the original in XY (bottom), and YZ (top right) directions are synchronized, so every time the user clicks on any of them the yellow axes are moved to that position, and the other two windows update.

As you can see in the screenshot, when you apply this operation on a stack, two new windows are created, that would be the result of reslicing the image in two orthogonal directions to the one originally shown in the stack. The new feature that this tool presents is that the three views are synchronized, so every time you click on a certain position, the other two windows update their slices to the corresponding coordinate (the yellow axis cross in the example).

Another processing that we can perform on our stack is 3D projection. You can think of it as a series of rays that will pass through your 3D volume and intersect a virtual 2D screen on the other side. You will be able to modify the orientation of this projection and the way these rays interact with your volume. You can just average all values of the volume intersected by every ray, calculate the maximum value, and keep the value that is closer to the 2D screen. Depending on the kind of projection, a different result is obtained. Image | Stacks | Z Project... will run this process only once, in the direction perpendicular to your slices, calculating the projected value (Average Intensity, Max Intensity, Min Intensity…) from all slices. The result will be a single 2D image.

Image | Stacks | 3D Project... allows modifying more options and calculates several projections rotating your stack around one of the main axes 360 degrees (default value, though it can be changed). The result is a new stack that when animated (with the play button at the bottom left of the image window), presents your rendered projections one after the other. This nice result can be saved as an AVI movie (File | Save As | AVI…) and is an interesting way of exploring your stacks. Test it with the T1 head image, selecting Mean Value as Projection Method and leaving the remaining options unmodified. Your result should be the same as in the following diagram, where the whole 3D projection process is illustrated:

3D and 4D images – stacks and hyperstacks

The scheme of 3D projection process is shown. In this example, the stack is rotated 10 degrees around the y axis, and in every rotation the projection calculates the average value and obtains a 2D image. All these images together (total of 36, one every 10 degrees) are the result (right of the diagram), that is also a stack and can consequently be animated.

As you have seen in this section, we have focused about stacks, and almost nothing has been said on hyperstacks. This is because the way you interact with hyperstacks and stacks is similar, taking into account that hyperstacks have more dimensions (time and channels). Some of the operations that you can apply to stacks can also be applied to hyperstacks, and if that is not possible, ImageJ will show a warning message. The only specific tools that you will find in the Image | Hyperstacks menu are those related to type conversion, such as converting stacks to hyperstacks and one tool to reduce dimensionality, that will create a new hyperstack fixing the position, time frame, or channel that you select.

To better understand how hyperstacks are manipulated, open the sample image called Mitosis. This image has 2 channels, 5 slices, and 51 frames, so it is a great example of complex data, and we encourage you to try it and move around all you need until you feel comfortable with the different dimensions. Also, create the Orthogonal Views (Ctrl + Shift + H) using the option on the Image | Stacks menu, and move around with them.

Tip

There is an option in case you want to process large images (for instance, hundreds of megabytes). You can open them as Virtual Stacks. In that case, the whole image will not be loaded in memory, but it will be accessed from disk, loading only the part of the stack or hyperstack that is needed. This is slower, but it will allow you to process images that do not fit in your system memory.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset