Friedrich-Alexander-Universität
Friedrich-Alexander-Universität
Stanford Radiology

Grid Data Container

CONRAD's principle data container is called "Grid". It is used to store any rasterized 1D, 2D, or 3D data. Also it is also possible to store multi-dimensional data such as multi-material images which will be described towards the end of this tutorial.

Abstract Grid

The class Grid itself is abstract and is designed for n-dimensional data. It stores the size, the spacing of the voxels, and the world position of voxel (0,0,...,0) as origin. Furthermore, all Grids have PointwiseIterators that allow sequential access to all elements of the Grid as the memory format of different n-dimensional data might differ. Note that we used the ... notation to implement variable argument length functions instead of arrays.


The Grid's basic operations are:

  • getNumberOfElements()
  • getOrigin()
  • getSize()
  • getSpacing()
  • show()
  • setOrigin(double ...)
  • setSpacing(double ...)

Grid1D

Grid1D is the one-dimensional implementation of Grid. It uses linear memory as float[] that is accessible via the getBuffer() method. Grid1D features a copy constructor that copies the array data bit-wise from the other Grid1D. Otherwise it also has a wrapper constructor that is able to wrap an existing float[] into a Grid1D. Grid1D has an extension to complex numbers Grid1DComplex that supports Fourier transforms. Note that this will initialize spacings and size with 0 which may cause trouble in the further processing.

Grid2D

Grid2D is the two-dimensional implementation of Grid. It also uses linear memory, i.e. float[] as underlying memory, as this is compatible with ImageJ, OpenGL, and OpenCL. It furthermore has auxiliary methods getWidth() and getHeight() that return getSize()[0] and getSize()[1] respectively. The method getSubGrid() delivers a Grid1D that can be processed as Grid1D. Internally the memory is mapped and the Grid1D operates directly on the Grid2D memory. Furthermore, Grid2D has a Complex subclass that supports 2D Fourier transform. Multi-material data can be processed by the subclass MultiChannelGrid2D which is an ArrayList of Grid2D. Internally it redirects all Grid2D functionality to the 0th channel.

Grid3D

Grid3D is the volume implementation of Grid. It uses an ArrayList of Grid2D to represent the volume. This is directly compatible with ImageJ and Grid2D and Grid3D can be wrapped to ImageJ containers without having to copy the memory. It also interoperates with OpenCL, as memory transfers can use pointer arithmetic to remap the ArrayList to linear memory in OpenCL. As all other Grids Grid3D offers a copy constructor to copy data.

PointwiseOperators

Simple mathematical operations like add, divide, multiply, subtract, log, etc. are found in this class. Depending on the underlying Grid, the different implementations are executed. If the grid lies in CPU memory, the operation is executed in CPU memory. If the grid lies in OpenCL memory, the operation is executed on OpenCL memory. If two grids are processed and both are in OpenCL memory, the operation is performed entirely in OpenCL.Otherwise, the data is first transferred to the CPU and the operation is executed on CPU.

InterpolationOperators

The InterpolationOperators allow reading and writing to non-uniform grid positions, i.e. (0.5). In contrast to OpenCL Textures, the indexing is not shifted by 0.5 and (1.0) refers to an exact grid node.

Raw Data IO

All grids can be read and written using ImageJ API. Convenience methods are found in GridRawIOUtil. Note that the file format is defined in the ImageJ Object FileInfo. Examples on how to use the methods are found in TestGridRawDataIO.java.