## SPIDER M-files - read files in SPIDER format into Matlab

SPIDER is a free image processing system for electron microscopy. It is used for three-dimensional reconstruction of single particle macromolecules, multivariate statistical classification, and electron tomography. See the extensive documentation and many available techniques at www.wadsworth.org/spider_doc/spider/docs/master.html

SPIDER has its own binary format for images and volumes. The SPIDER M-file collection lets users read SPIDER images, volumes, image stacks, and textual document files directly into Matlab data types for processing and visualization.
The provided M-files are:

`readSPIDERfile` | reads SPIDER binary files
`writeSPIDERfile` | writes SPIDER binary files
`readSPIDERheader` | reads the header of SPIDER binary files
`readSPIDERdoc` | reads SPIDER document files
`writeSPIDERdoc` | writes SPIDER document files
`example.m` | Example usage

NB: there is no specific data extension for SPIDER files.

readSPIDERfile

Read a SPIDER image, volume, or stack file into an array.

Usage

`m = readSPIDERfile(filename)`

If filename is a SPIDER image, `readSPIDERfile` reads it into a 2D array, `m`. If filename is a SPIDER volume, or image stack, it is read into a 3D array. `readSPIDERfile` calls `readSPIDERheader`.

writeSPIDERfile

Write a 2D or 3D array out to a SPIDER file.

Usage

`writeSPIDERfile(filename, array)`
`writeSPIDERfile(filename, array, 'stack')`

`writeSPIDERfile(filename, array)` will write data to a SPIDER image or volume, depending on whether the array is 2D or 3D.
`writeSPIDERfile(filename, array, 'stack')` writes a 3D array out as a stack file of images.

readSPIDERheader

Read the header of a SPIDER file.

Usage

`v = readSPIDERheader(filename)`

Reads the header of a SPIDER binary file into a vector (1D array). All the entries are floating point values. E.g., the width, height and depth are in v(12), v(2), v(1), respectively. For the meaning of other values, see www.wadsworth.org/spider_doc/spider/docs/image_doc.html

readSPIDERdoc

Read data from a SPIDER document file.

Usage

`m = readSPIDERdoc(filename)`
`m = readSPIDERdoc(filename, column)`
`m = readSPIDERdoc(filename, [column1, column2, ...])`

`m = readSPIDERdoc(filename)` reads all the columns of the document file into a 2D array, a matrix of [nrows ncolumns]. The array is accessed by `m(row,column)`.
`m(:,i)` returns the ith column
`m(j,:)` returns the jth row
`m(j,i)` returns a single element

`m = readSPIDERdoc(filename, i)` returns a single column of data.

`m = readSPIDERdoc(filename, [i j k])` returns a set of columns. Column=1 refers to the first SPIDER data column (textually, column 3). To retrieve the key column, use column=0.

writeSPIDERdoc

Write an array out to a SPIDER document file.

Usage

`writeSPIDERdoc(filename, array)`
`writeSPIDERdoc(filename, array, column_headers)`

`writeSPIDERdoc(filename, array)` writes a 2D array to a SPIDER document file.
`writeSPIDERfile(filename, array, column_headers)` writes the 2D array to a doc file with text headings over each column. The `column_headers` are a cell array of strings, created by e.g.,
`hdrs = { 'column1'; 'column2'; 'column3'}`.

Created: 02/04/09 Bill Baxter
Enquiries: spider@wadsworth.org