Current issue


2024-06
Volume 10, issue 02
<< prev. next >>
ISSN: 2274-0422

Article Management

You must log in to submit or manage articles.

You do not have an account yet ? Sign up.

Image stack optimization (for CT and MRI data)

Why don't you allow CT/MRI data file larger than 500 Mo to be uploaded in MorphoMuseuM ?

Data storage has a cost and we want M3 to remain a free service. Keep in mind that M3 publishes primarily 3D surface models of specimens (.STL, .VTP, .VTK, .PLY...). Blender projects (.BLEND) are also accepted.

M3 also published image stacks produced via CT or MRI, but this remains an optionnal feature.

How can I reduce the size of CT-MRI data ?

CT/MRI data are often very heavy, and you may think that a .zip file of 500 Mo is ridiculously small. However, there are a few ways to reduce the size of a large set of images while keeping a reasonably good level of image quality. You can try the following options :

  • Option 1: crop your images in order to keep only the region of interest.
  • Option 2: If you have 16 bits (or 32 bits) images, you may decide to transform these images to 8 bits images. 8 bits images contain only 256 levels (while 16 bits images contain 256² levels), but in many cases 256 levels is enough to distinguish the different structures of interest on CT/MRI images. Transforming 16 bits images into 8 bits images will reduce the weight of you images by a factor of 2.
  • Option 3: only allow variation of "grey levels" in the region of interest. For instance, for CT images, set the same value (0) in all the regions corresponding to "air". This will have no effect on the size of the uncompressed images, but the resulting .zip file will be much smaller.
  • Option 4: if this is still not enough, you may consider to reduce the resolution of your original images by a factor of 2. Decreasing the resolution by a factor of 2 will reduce the weight of your images by a factor of 8. However, before uploading a dataset having the resolution decreased on M3, we encourage you to assess whether the structures of interest are still visible after you have reduced the resolution.

The last three options (and especially the last one) will have an impact on image quality. It is up to you to decide which decrease in image quality you are ready to accept before sharing your data.

Option 1 example : image cropping using ImageJ

You may use the software ImageJ to crop your images.

Case 1: you are able to fully load your CT/MRI dataset within ImageJ on your workstation

If you are able to open your entire CT/MRI dataset with ImageJ, then simply make use of the "Crop" function, and save your resulting image stack in another location (draw a rectangle delimitating your region of interest, and then go to menu Image->Crop).

Case 2: your dataset is too large to be opened entirely "at once".

It may happen that a CT/MRI data set is too large to be entirely loaded in memory (for instance you may have synchrotron data). Here I present you a rather simple way to crop such large data without having to load the entire image stack in memory. As a first step, download the crop macro and place this file inside the "macro" directory of ImageJ.

1) Open a part of your image sequence (for instance go in File->Import->Image sequence and chose to open only 1 image every 20 images by changing the Increment value, in order to reduce the amount of memory needed to open the stack by a factor of 20).

View

2) Open Macro recorder window (Plugin->Macros->Record)

View

3) Define the ROI with the rectangle selection tool. Adjust the ROI in order to have your structures of interest enclosed in the rectangle for all slices.

View

4) Copy the last "makeRectangle" command in the macro recorder window.

View

5) Open the _macro.txt file you have placed in your "macro" directory. Find the makeRectangle command and replace it by the one you have just copied from the Recorder window. Save the _crop.txt file.

View

6) Launch the _crop.txt macro. To do so, first go in Plugins->Macros->Install and chose the _crop.txt file. Then go in Plugins->Macro->_crop. The following window should appear. Here you should chose an input directory in which you have stored your original CT/MRI data. Be aware that this directory should contain only images, and that these images should all have the same width and height. If these requirements are not fulfilled, the _crop.txt macro will not work.

View

7) Chose an empty target directory. This will be the place where the new image stack will be stored.

View
Option 2 + option 3 example using ImageJ

You may use again ImageJ to transform your images.

To do so, you have to be able to open your entire CT/MRI dataset with ImageJ.

1) Open your whole image sequence (File->Import->Image sequence). Then go in Image->Adjug->Brightness/Contrast. If you use CT images, very often, you will see at least two peaks in the histogram. The leftmost peak usually corresponds mostly to that of "air", while the rightmost peak corresponds to that of the specimen. Then you may set the minimum value to a value greater than that of the peak of air.

ViewView

2) Then go in File->Image->Type and change the image type to 8bits. As a result all the voxels situated in a region containing air will have been given a value of 0.

View

3) Save your dataset (either as a .raw image or as an image stack), and compress it inside a .zip file.

In this example, we managed to reduce the size of the CT dataset by a factor of more than 10. Be aware that following this strategy, you can achieve similar results without changing the image type and without risking to give a value of 0 to voxels belonging to a region of interest by creating macros for Photosop implicating the creation of "masks". The idea is to manage to select all the regions which are of no biological value (air or sediment matrix) and to give them a value of 0.

Option 4 example : reducing image resolution by a factor of 2 using ImageJ

Again, you may use the software ImageJ to reduce the resolution of a CT/MRI dataset.

Step 1: download and install "averaging reducer" plugin

You can download the plugin at the following page.. Then close and restart ImageJ.

Step 2: Install and run the "binning" macro.

Download the binning macro and place this file inside the "macro" directory of ImageJ.

1) Launch the _binning.txt macro. To do so, first go in Plugins->Macros->Install and chose the _binning.txt file. Then go in Plugins->Macro->_binning. The following window should appear. Here you should chose an input directory in which you have stored your original CT/MRI data. Be aware that this directory should contain only images, and that these images should all have the same width and height. If these requirements are not fulfilled, the _binning.txt macro will not work.

View

2) Chose an empty target directory. This will be the place where the new image stack will be stored. The target directory will contain twice as less images as the input directory, and the width and height of the resulting images will have been divided by 2. The weight of the output directory should be 8 times smaller than that of the input directory.

View