susan.io.mrc¶
- susan.io.mrc.read(filename)[source]¶
Read an MRC/CCP4 file and return its data and pixel size.
- Parameters:
filename (str) – Path to the MRC file.
- Returns:
data (numpy.ndarray) – Volume or image array with shape (Z, Y, X), dtype determined by the MRC mode field (float32 for mode 2, int16 for mode 1, etc.).
pix_size (numpy.ndarray) – Pixel size in Ångströms, shape (3,) float32, ordered (X, Y, Z).
- susan.io.mrc.write(data, filename, apix=1, ispg=None, fill_statistics=True)[source]¶
Write a numpy array to an MRC2014 file.
- Parameters:
data (numpy.ndarray) – Array to write, shape (Z, Y, X). float64 is automatically downcast to float32. Supported dtypes: int8, int16, uint16, float16, float32, float64.
filename (str) – Output file path.
apix (float or array-like of shape (3,), optional, ordered (X, Y, Z).) – Pixel size in Ångströms. A scalar sets all three axes equally. Default 1.
ispg (int, optional) – Space-group number written to the header. Default 1 (P1).
fill_statistics (bool, optional) – If True (default), compute and write min, max, mean, and std into the header statistics fields.
- susan.io.mrc.get_info(filename)[source]¶
Read only the header of an MRC file without loading the data.
- Parameters:
filename (str) – Path to the MRC file.
- Returns:
shape (numpy.ndarray) – Volume dimensions as (NX, NY, NZ), shape (3,) uint32.
pix_size (numpy.ndarray) – Pixel size in Ångströms, shape (3,) float32, ordered (X, Y, Z).
dtype (numpy.dtype) – NumPy dtype corresponding to the MRC mode field.