Skip to content

microCT image format basics

Ali Raeini edited this page Jul 4, 2021 · 3 revisions

Input image format for pnextract code

This file explains the BASICS of image formats compatible with pnextract and other codes relying on voxelImage/libvoxel library.

Only the standard formats and workflow are discussed. There are incompatibilities between the image format conventions we use and third party software which you need to be aware of when choosing different image format.

The standard workflow is to provide a separate header.mhd file along each micro-CT image, and ideally with the same base name as the image. The .mhd format we use is partly compatible with ITK mhd, meta header data. A sample file is provided in https://github.com/aliraeini/pnextract/blob/master/doc/Image.mhd

Technical note: libvoxel supports .tif, .raw, .raw.gz, ascii (.dat) file formats (see the description of ElementDataFile keyword in .mhd header files) and .am (Avizo, raw or ByteRLE-compressed) image files. If you segment you images using Avizo it is recommended that you convert your segmented images into 8bit (unsigned char) and save the data as default .am format, and then assign this File.am as the argument of ElementDataFile keyword. If you use Fiji-is-ImageJ for editing and segmenting the grey-scale images, then the recommended approach is to save the file as .mhd format (uncompressed). Libvoxel only supports compression in raw.gz (gnu zip) format, setting CompressedData to True in .mhd file is not enough. Compressed files in .gz formaat can be produced using 7z software, or gzip in Linux. Remember to update the ElementDataFile keyword in .mhd file if you compress your file in .gz format.

Visualizing image using "Fiji is ImageJ":

First google! and download sample "Fiji is ImageJ" or Paraview for visualizing 3D images.

Download sample micro-CT images from Imperial college pore-scale website: http://www.imperial.ac.uk/earth-science/research/research-groups/perm/research/pore-scale-modelling/micro-ct-images-and-networks/ . Note decompress the downloaded zip files, but do not decompress the .raw.gz files to save disk space. You can use free opensource software called 7z for compressing .raw files into .raw.gz format, or the other way around. libvoxel and hence pnextract ... support both formats, with the format being detected from the image suffix. After extracting the files, make sure that there is a .raw.gz and and .mhd files when you extract the zip files. Note, in Default Windows file browser, file suffixes are hidden but this can be changed.

To visualize the image in ImageJ, simply drag the .mhd file onto the "Fiji-is-ImageJ" status bar. Unfortunately ImageJ is not smart enough to auto-adjust contrast of the image after it is loaded, so you may see a black window after this. To fix this, you need to manually adjust Image Brightness and Contrast (see https://imagej.net/Brightness_and_Contrast). Essentially You can press Ctrl+Alt+C and set the max value to 1.

Note, if your image is in .tif or .am format, you need to directly open the .am file instead of its .mhd header file.

Quality checking input image

Finally, make sure that the pore value is zero, otherwise you need additional keywords to tell pnextract code, which voxels value is assigned to the void space, as discussed in pnextract_guide.pdf

In ImageJ the voxel values is shown in the main window statusbar when hoovering mouse over the image window. In Paraview, this can be checked by activating the colorbar.

Memory usage

pnextract needs something less than 10GB for a 1000 cubed image, and memory usage scales linearly with image-volume. Make sure your hardware has necessary RAM for this. You can use cropD keyword discussed in pnextract_guide.pdf to extract the network on a subset of the image.

Flow direction

Flow simulations using pnflow (opensource version) are always in x direction, in order to run flow in other directions of the image, simply add the "direction z" keyword in the .mhd header file.

Note ElementSpacing and ElementSize in .mhd files are ideantical, old versions of pnextract did not support ElementSize, but now ElementSpacing is considered deprecated (but supported).