tomodrgn.mrc#

Classes and functions for loading and writing .mrc(s) headers and data.

Generally adheres to the MRC2014 Update 20141 specification.
Deviations from this standard include:
  1. any data in the extended header is read (and maintained for later writing), but is not interpreted or used in any way;

  2. the machst attribute of the header is unpacked as a byte string (e.g b`DA`) rather than as an array of uint8 (e.g. [68, 65, 0, 0]);

  3. the label attribute of the header is unpacked as a concatenated byte string rather than as an array of byte strings for all 10 80-character labels that may exist

Prefer the following uses:
  • interfacing with MRC headers: mrc.MRCHeader.parse() or mrc.parse_header()

  • loading an entire MRC file into memory: mrc.parse_mrc()

  • loading a list of MRC files into memory: mrc.parse_mrc_list()

  • lazily loading a single image from an MRC file: mrc.LazyImage

  • lazily loading a group of images from an MRC file: mrc.LazyImageStack

  • writing an MRC file to disk: mrc.write()

Functions

parse_header

Convenience function to create an MRCHeader object given an MRC file name

parse_mrc

Load an entire MRC file into memory as either a numpy array or a list of LazyImages

parse_mrc_list

Load the MRC file(s) specified in a text file into memory as either a numpy array or a list of LazyImages.

write

Write a data array to disk in MRC format.

Classes

LazyImage

Class to lazily load data from an MRC file on-the-fly

LazyImageStack

Efficiently load a particle stack from an NxDxD stack.mrcs file on-the-fly.

MRCHeader

Class to parse the header of an MRC file and to write a new MRC header to disk.