# Supported file formats

OpenCLIPER can load and write many image formats (those supported by the OpenCV library) but, in addition, data volumes in raw and Matlab's .mat format are supported. These are documented in detail below.

## Image formats

Image formats are supported through OpenCV library, and include Window bitmap (bmp), portable image formats (pbm, pgm and ppm), Sun raster (sr, ras), JPEG (jpeg, jpg, jpe), JPEG 2000 (jp2), TIFF files (tiff, tif) and portable network grapchics (png).

## Matlab format

A group of related k-space or x-space data is stored as one matlab file containing several variables. The names of these variables, their content and the mandatory / optional features are shown in the table below:

Variable name | Content | Mandatory / Optional |
---|---|---|

Dimensions | Spatial and temporal dimensions and number of coils | Mandatory for x-space and k-space related data |

XData | Images in x-space | Mandatory for x-space related data |

KData | Images in k-space | Mandatory for k-space related data |

SensitivityMaps | Sensitivity maps of coils used for image adquisition | Optional for k-space related data |

SamplingMasks | Sampling masks with information about image rows acquired | Optional for k-space related data |

### Data in x-space

A sequence of images in x-space is stored as an N-dimensional array variable of single precision real numbers in a single matlab file together with a dimensions variable (see Dimensions variable).

The first M dimensions are spatial and the last N-M are temporal. The structure of an x-space image stored as a matlab array is shown in the figure below, where every NDArray stores a single image (with its spatial dimensions in column-first order, following Matlab's convention).

### Data in k-space

A group of related k-space images, the sensitivity maps of the coils used for their capture and the sampling masks with information about image rows that have been acquired (not all rows have to be acquired for every temporal frame) are stored as array variables in a single matlab file. This file must also contain an additional dimensions variable (see Dimensions variable).

A sequence of images in k-space is stored as an N-dimensional array variable of single-precision complex numbers. The first M dimensions are spatial, then comes the coil dimension, and then the M-N-1 temporal ones. The structure of a k-space image stored as a matlab array is shown in the figure below, where every NDArray stores a single image (with its spatial dimensions in column-first order, following Matlab's convention).

A sequence of sensitivity maps is stored as an N-dimensional array variable of single precision complex numbers. The first N-1 dimensions are spatial and the last one is for coils.

A sequence of sampling masks is stored as an N-dimensional array variable of integer numbers. The first M dimensions are spatial (M = number of spatial dimensions of k-data - 1) and the remaining are temporal. The sampling mask for a given image is a vector made of ones and zeros. One means that the corresponding row of the image has been acquired, whereas zero means that row is absent.

### Dimensions variable

This variable stores spatial an temporal dimensions for Data in x or k space, and it is mandatory in a matlab file. The first NSD positions are the sizes of the spatial dimensions (width, height, depth, ...), then comes the number of coils used for the capture (0 for an x-space image) and then the number of temporal dimensions.

The structure of this matlab variable is shown in the figure below.

## CFL format

When using CFL format, OpenCLIPER stores elements of every single image, volume, sensitivity map or sampling mask (contained in one NDArray object) by rows: every element of a row is stored consecutively, then all the rows of the same slice and then consecutive slices (if any).

Every element is stored as a single-precision complex number (real part first, imaginary part afterwards) for k-space images and sensitivity maps, as a single precision real number for x-space images, or as an integer for sampling masks. Only grayscale images/volumes are currently supported (1 byte per pixel).

The sampling mask for a given image is a vector made of ones and zeros. One means that the corresponding row of the image has been acquired, whereas zero means that row is absent.

The CFL format for a single volume is shown in the image below.

A sequence of related images, volumes, sensitivity maps or sampling masks is stored as one file (with cfl extension).

Every CFL file needs a header file (with hdr extension) containing the data dimensions, starting with the size of every spatial dimension, then the number of coils (0 for x-space data) and then the number of temporal dimensions (same structure of the matlab dimensions variable, see format of matlab dimensions variable).