HOME GUIDE OPERATIONS DOCS FAQ TECHNIQUES FORMATS INSTALL NEW TIPS WEB LINKS WADSWORTH

Format of SPIDER 2D and 3D image files

SPIDER uses nsam to denote number of pixels (voxels) per row, nrow to denote number of rows, and nslice to denote the number of slices or planes in a volume. A 2D image is considered to be a special case of a volume consisting of a single slice (or plane).

The image data is preceeded by a header. There are labrec records in the header, where labrec = ceiling of (256/nsam). Please note that the length of the header in SPIDER images is always >= 1024 bytes and is calculated as follows (in FORTRAN) when a new SPIDER image is created:

LENBYT = NSAM * 4
LABREC = 1024 / LENBYT
IF (MOD(1024,LENBYT) .NE. 0) LABREC = LABREC + 1
LABBYT = LABREC * LENBYT
Where LENBYT is the record length in bytes, and the MOD function returns the remainder of dividing 1024 by LENBYT. This variable length header is used for compatibility with FORTRAN direct access unformatted file I/O

In indexed stack files the image data is also preceeded by an additional index header. There are indxrec records in the header, where indxrec = ceiling of (maxindx/nsam). The user must specify a value for maxindx whenever an indexed stack file is originally created. (For programmers attempting to write conversion utilities, I advise them to ignore indexed stacks. They are mainly in use at only a couple of sites with specialized large data requirements.)

The image data in a volume of nsam x nrow x nslice voxels is stored in the following manner:
Unformatted, direct access file containing a total of labrec + nrow x nslice records. In a standard SPIDER image file each record contains nsam 4-byte words which are stored as floating point numbers.
The sequence in which the information is stored in the file is as follows:

Records 1 --> labrec
SPIDER header
Records (labrec+1)--> (nrow+labrec)
slice No. 1
Records (nrow+labrec+1)--> (2*nrow+labrec)
slice No. 2
.
.
Records ((nslice-1)*nrow+labrec+1) -> (nslice*nrow+labrec)
slice No. nslice
.
.
Records (nslice*nrow+labrec+1) --> (nslice*nrow+labrec)


Layout of the SPIDER header is as follows:

    Word No.
  1. nslice = number of slices (planes) in volume (=1 for an image)
  2. nrow = number of rows per slice.
  3. irec = total number of records (including header records) in each image of a simple image or stacked image file.
  4. nhistrec = (obsolete, unused)
  5. iform = file type specifier. Obsolete file types d, 8, 11, 12, 16, -1, -3, -7, and -9 are no longer supported in SPIDER.
  6. iform (type) data type
    1 (r) 2D image.
    3 (r) 3D volume.
    -11 (fo) 2D Fourier, mixed radix odd.
    -12 (fe) 2D Fourier, mixed radix even.
    -21 (fo) 3D Fourier, mixed radix odd.
    -22 (fe) 3D Fourier, mixed radix even.
  7. imami = maximum/minimum flag. Is set at 0 when the file is created, and at 1 when the maximum, minimum, average, and standard deviation have been computed and stored into this header record (see following locations).
  8. fmax = maximum value.
  9. fmin = minimum value.
  10. av = average value.
  11. sig = standard deviation. A value of -1.0 indicates that sig has not been computed previously.
  12. ihist = (obsolete, no longer used).
  13. nsam = number of pixels per line.
  14. labrec = number of records in file header (label).
  15. iangle = flag that tilt angles are present.
  16. phi = tilt angle (See note #2 below).
  17. theta = tilt angle.
  18. gamma = tilt angle (also called psi).
  19. xoff = x translation.
  20. yoff = y translation.
  21. zoff = z translation.
  22. scale = scale factor.
  23. labbyt = total number of bytes in header.
  24. lenbyt = record length in bytes.
  25. istack = This position has a value of 0 in simple 2D or 3D (non-stack) files. In an "image stack" there is one overall stack header followed by a stack of images in which each image has its own image header. (An image stack differs from a simple 3D image in that each stacked image has its own header.) A value of >0 in this position in the overall stack header indicates a stack of images. A value of <0 in this position in the overall stack header indicates an indexed stack of images and gives the maximum image number allowed in the index.
  26. NOTUSED = This position is unused now! Prior to release 9.0, a -1 at this location in an overall stack indicated a valid stack and in the stacked images, a value of 1 indicated that this image was in use (existed).
  27. maxim = This position is only used in the overall header for a stacked image file. There, this position contains the number of the highest image currently used in the stack. This number is updated, if necessary, when an image is added or deleted from the stack.
  28. imgnum = This position is only used in a stacked image header. There, this position contains the number of the current image or zero if the image is unused.
  29. lastindx = This position is only used in the overall header of indexed stacks. There, this position is the highest index currently in use.
  30. unused
  31. unused
  32. Kangle = flag that additional angles are present in header. 1 = one additional rotation is present, 2 = additional rotation that preceeds the rotation that was stored in words 15..20.
  33. phi1
  34. theta1
  35. psi1
  36. phi2
  37. theta2
  38. psi2
50-76 == reserved for Jose Maria's transforms
212-214 == cdat = character * 11 containing creation date e.g. 27-MAY-1999
215-216 -- ctim = character * 8 containing creation time e.g. 09:43:19
217-256 -- ctit = character * 160 containing title

Note#1 :
All character arrays are retrieved from the floating point buffer array containing the header record(s) by equivalence assignments. Thus character arrays are stored in the header without any conversion.


Note#2 :
The angle, offset & scale factor locations contained in the SPIDER header are available to communicate between different SPIDER operations. Currently they are NOT used in the code distributed with SPIDER, but some outside labs make extensive use of these positions. The angles are usually in Euler format and are given in degrees.


Note#3 :
SGI, most IBM, Mackintosh, and Sun Unix machines use a different byte ordering from GNU/Linux on Intel, or HP Alpha machines. SPIDER contains the "CP TO OPEND" operation to interconvert these files. However SPIDER can read/write either byte ordering now.



Source: image_doc.html     Last update: 28 Nov. 2004     ArDean Leith


© Copyright Notice /       Enquiries: spider@wadsworth.org

BACK TO SPIDER BACK TO WADSWORTH