cryosparc.mrc#

Classes:

DT(value)

MRC data type enumerations

Header(nx, ny, nz, datatype, xlen, ylen, ...)

MRC file header

Data:

VOXEL_TYPES

Map from EPU voxelType values to integer data types

Functions:

read(file)

Read a .mrc file at the given file into a numpy array.

write(file, data, psize)

Write the given ndarray data to a file.

class cryosparc.mrc.DT(value)#

MRC data type enumerations

class cryosparc.mrc.Header(nx: int, ny: int, nz: int, datatype: DT, xlen: float, ylen: float, zlen: float, origin: Tuple[float, float, float], nsymbt: int)#

MRC file header

Attributes:

datatype

Integer-representation of MRC data type

nsymbt

Number of symbols in the symbol table following the header.

nx

Number of pixels in x dimension

ny

Number of pixels in y dimension

nz

Number of pixels in z dimension

origin

Location of image origin

xlen

Total size of X axis (e.g., in Angstroms)

ylen

Total size of Y axis (e.g., in Angstroms)

zlen

Total size of Z axis (e.g., in Angstroms)

datatype: DT#

Integer-representation of MRC data type

nsymbt: int#

Number of symbols in the symbol table following the header. Each symbol is 1024 bytes.

nx: int#

Number of pixels in x dimension

ny: int#

Number of pixels in y dimension

nz: int#

Number of pixels in z dimension

origin: Tuple[float, float, float]#

Location of image origin

xlen: float#

Total size of X axis (e.g., in Angstroms)

ylen: float#

Total size of Y axis (e.g., in Angstroms)

zlen: float#

Total size of Z axis (e.g., in Angstroms)

cryosparc.mrc.VOXEL_TYPES = {'16 BIT FLOAT': DT.FLOAT16, '32 BIT FLOAT': DT.FLOAT32, 'SIGNED 16 BIT INTEGER': DT.INT16, 'UNSIGNED 16 BIT INTEGER': DT.UINT16, 'UNSIGNED 8 BIT INTEGER': DT.UINT8}#

Map from EPU voxelType values to integer data types

cryosparc.mrc.read(file: str | PurePath | IO[bytes]) Tuple[Header, NDArray]#

Read a .mrc file at the given file into a numpy array. Returns the MRC header and the resulting array.

Parameters:

file (str | Path | IO) – MRC file path or handle.

Returns:

The MRC header and MRC data as a numpy array.

Return type:

tuple[Header, NDArray]

cryosparc.mrc.write(file: str | PurePath | IO[bytes], data: NDArray, psize: float)#

Write the given ndarray data to a file. Specify a pixel size for the mrc file as the last argument.

Parameters:
  • file (str | Path | IO) – File path or handle to write.

  • data (NDArray) – 2D or 3D numpy array of MRC data.

  • psize (float) – Pixel size to write into MRC.