# Supported file formats

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

## Raw format

When using raw 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 raw 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 a group of files (one file per image/volume/sensitivity map/sampling mask) with a common name prefix and a suffix or suffixes that depends on the coil number used for capture in the k-space and/or the temporal frame number (1-dimensional indexes are used for coil and frame identification).

By default, the name used for the different data has the following formats:

Data type | Name format |
---|---|

images in x-space | `<namePrefix>_<W>x<H>_frame<FF>.raw` |

volumes in x-space | `<namePrefix>_<W>x<H>x<D>_frame<FF>.raw` |

images in k-space | `<namePrefix>_<W>x<H>_coil<CC>_frame<FF>.raw` |

volumes in k-space | `<namePrefix>_<W>x<H>x<D>_coil<CC>_frame<FF>.raw` |

sensitivity maps (k-space) | `<namePrefix>_<W>x<H>_coil<CC>.raw` |

sampling masks (k-space) | `<namePrefix>_<H>_frame<FF>.raw` |

where `<namePrefix>`

is the prefix for the name (common to all related files
of the same kind)
`<W>`

is the width of the image in pixels, `<H>`

its height, `<D>`

the
volume depth, `<CC>`

are the two digits used for the coil number and `<FF>`

are the two digits used for the frame number.

## Matlab format

### Data in x-space

A sequence of images in x-space is stored as an N-dimensional array of single precision real numbers. 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 captured (not all rows have to be captured for every temporal frame) are stored as array variables in a single matlab file.

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.