mrc — the MRC/CCP4 volumetric data format

Added in version 0.7.0.

Reading of MRC/CCP4 volumetric files (MRC2014 file format) using the mrcfile library [Burnley2017].

References

[Burnley2017]

Burnley T, Palmer C and Winn M (2017) Recent developments in the CCP-EM software suite. Acta Cryst. D73:469-477. doi: 10.1107/S2059798317007859

Classes

class gridData.mrc.MRC(filename=None, assume_volumetric=False)[source]

Represent a MRC/CCP4 file.

Load MRC/CCP4 2014 3D volumetric data with the mrcfile library.

Parameters:
  • filename (str (optional)) – input file (or stream), can be compressed

  • assume_volumetric (bool (optional)) –

    If False (default), check the file header to determine whether the data in grid is a 3D volume. If True, assume grid is volumetric.

    Added in version 1.1.0.

Raises:

ValueError – If the unit cell is not orthorhombic or if the data are not volumetric.

header

Header data from the MRC file as a numpy record array.

Type:

numpy.recarray

array

Data as a 3-dimensional array where axis 0 corresponds to X, axis 1 to Y, and axis 2 to Z. This order is always enforced, regardless of the order in the mrc file.

Type:

numpy.ndarray

delta

Diagonal matrix with the voxel size in X, Y, and Z direction (taken from the mrcfile.mrcfile.voxel_size attribute)

Type:

numpy.ndarray

origin

numpy array with coordinates of the coordinate system origin (computed from header.origin, the offsets header.origin.nxstart, header.origin.nystart, header.origin.nzstart and the spacing delta)

Type:

numpy.ndarray

rank

The integer 3, denoting that only 3D maps are read.

Type:

int

Notes

  • Only volumetric (3D) densities are read.

  • Only orthorhombic unitcells supported (other raise ValueError)

  • Reading and writing are supported.

Added in version 0.7.0.

property edges

Edges of the grid cells, origin at centre of 0,0,0 grid cell.

Only works for regular, orthonormal grids.

histogramdd()[source]

Return array data as (edges,grid), i.e. a numpy nD histogram.

read(filename, assume_volumetric=False)[source]

Populate the instance from the MRC/CCP4 file filename.

property shape

Shape of the array

write(filename)[source]

Write grid data to MRC/CCP4 file format.

Parameters:

filename (str) – Output filename for the MRC file

Notes

The data array should be in xyz order (axis 0=X, axis 1=Y, axis 2=Z).

If the MRC object was created by reading an existing file, the original header information (including mapc, mapr, maps ordering) is preserved. Otherwise, standard ordering (mapc=1, mapr=2, maps=3) is used.

Added in version 1.1.0.