tomodrgn.mrc.MRCHeader#
- class MRCHeader(header_values: tuple, extended_header: bytes = b'')[source]#
Bases:
object
Class to parse the header of an MRC file and to write a new MRC header to disk.
Methods
Get the pixel size in angstroms per pixel based on header cella_xlen and nx ratio
Get the origin of the data coordinate system.
Constructor method to create an MRCHeader object describing a 3-D data array.
Constructor method to create an MRCHeader object from an MRC file name.
Update the pixel size in angstrom by adjusting the header cella_xlen, cella_ylen, and cella_zlen
Update the origin of the data coordinate system.
Write an MRC file header to the specified file handle.
Attributes
dtype_for_mode
field_names
fieldnames_structformats
mode_for_dtype
struct_format_string
struct_formats
Calculate the total header length as standard header (1024 bytes) + optional extended header (>= 0)
- get_apix() float [source]#
Get the pixel size in angstroms per pixel based on header cella_xlen and nx ratio
- Returns:
pixel size in angstroms
- get_origin() tuple[float, float, float] [source]#
Get the origin of the data coordinate system.
- Returns:
origin in (x, y, z)
- classmethod make_default_header(data: ndarray, is_vol: bool = True, angpix: float = 1, origin_x: float = 0, origin_y: float = 0, origin_z: float = 0)[source]#
Constructor method to create an MRCHeader object describing a 3-D data array.
- Automaticaly calculates and sets:
nx, ny, nz, mode, cella_xlen, cella_ylen, cella_zlen dmin dmax dmean ispg map machst
- Assumes default values for:
nxstart = nystart = nzstart := 0, mx := nx, my := ny, mz := nz, cellb_alpha = cellb_beta = cellb_gamma := 90 mapc := 1 mapr := 2 maps := 3 nsymbt := 0 extra1 := b’' * 8 exttyp := b’’ nversion := 0 extra2 := b’' * 84 origin_x = origin_y = origin_z = 0 rms := -1 nlabl := 0 labels := b’' * 84
- Parameters:
data – array of data to be described by this header
is_vol – whether the data array is a 3-D volume instead of a stack of 2-D images
angpix – pixel size in angstroms per pixel of the data array
origin_x – coordinate system origin along x-axis in angstroms, or the phase origin of the transformed image in pixels for MODE 3 or 4 data
origin_y – coordinate system origin along y-axis in angstroms, or the phase origin of the transformed image in pixels for MODE 3 or 4 data
origin_z – coordinate system origin along z-axis in angstroms, or the phase origin of the transformed image in pixels for MODE 3 or 4 data
- Returns:
MRCHeader object
- classmethod parse(fname: str)[source]#
Constructor method to create an MRCHeader object from an MRC file name.
- Parameters:
fname – path to MRC file on disk
- Returns:
MRCHeader object
- property total_header_bytes: int#
Calculate the total header length as standard header (1024 bytes) + optional extended header (>= 0)
- Returns:
total number of bytes in header and extended header
- update_apix(angpix: float) None [source]#
Update the pixel size in angstrom by adjusting the header cella_xlen, cella_ylen, and cella_zlen
- Parameters:
angpix
- Returns:
None