MatToImg

Overview

MatToImg takes a MATLAB workspace file and converts it to Priism's native format for image stacks. MATLAB workspace files typically have a .mat extension and are created with MATLAB's save command. The conversion takes only two parameters: MAT file is the name of the MATLAB workspace file to read and IVE file is the name of the Priism file to generate.

Whether or not MATLAB needs to be installed where you use MatToImg, the versions of MATLAB with which MatToImg can work, and the handling of the contents of the workspace file differ for the Priism 3.3 version of MatToImg (introduced June 1999) and the Priism 3 version.

The Priism 3.3 version uses the MATLAB 5 shared libraries (these are stored in a subdirectory of extern/lib in the MATLAB distribution) so those libraries will need to be accessible from the computer on which MatToImg is run and the location of the libraries should be included in the LD_LIBRARY_PATH environment variable (or some equivalent method so the dynamic loader, rld, can load the libraries when MatToImg is run). The Priism 3 version is a stand-alone program that does not require anything beyond what is needed for other Priism applications.

In Priism 3.3, MatToImg will read MATLAB 4 or 5 workspace files. For Priism 3, MatToImg only reads MATLAB 4 workspace files, and if you're using MATLAB 5, you'll need to specify the -V4 option to MATLAB's save command.

In Priism 3.3, the output file is a three-dimensional data stack where each two-dimensional z section represents a two-dimensional matrix stored in the workspace file or a slice (where the first two dimensions vary) through a three- or higher dimensional matrix. The sections in the output are filled by taking (and slicing as necessary) the matrices in the order in which they appear in the workspace file. The slices from higher dimensional matrices appear in adjacent z-sections. The matrices must all have the same first two dimensions and must all be real-valued represented as double-precision floating-point or must all be complex-valued represented as double-precision floating-point. If these conditions aren't met, MatToImg will issue a warning about not being able to read the workspace file.

In Priism 3, the output file is a three dimensional data stack where each two-dimensional z section contains the data from a matrix stored in the workspace file. The ith section in the output file holds the data of the ith matrix as it appears in the workspace file. Matrices with three or more dimensions are simply stored in their entirety as two-dimensional arrays. The conversion assumes that all variables in the workspace file refer to matrices of the same size with real-valued entries represented as double-precision floating-point values. MatToImg does not check that the file matches these assumptions.

The inverse of MatToImg, ImgToMat, generates workspace files which can be used as input to MatToImg.

Related Priism Topics

ImgToMat | Priism | Categories | Applications