Read and write files and manipulate data in the MRC2014 format
Author sethaxen
11 Stars
Updated Last
1 Year Ago
Started In
June 2020


Lifecycle Build Status Coverage Stable Dev Code Style: Blue

MRCFile.jl implements the MRC2014 format for storing image and volume data such as those produced by electron microscopy. It offers the ability to read, edit, and write MRC files, as well as utility functions for extracting useful information from the headers.

The key type is MRCData, which contains the contents of the MRC file, accessible with header and extendedheader. MRCData is an AbstractArray whose elements are those of the data portion of the file and can be accessed or modified accordingly.


using Pkg


This example downloads a map of TRPV1 and animates slices taken through the map.

To set-up this example, install FTPClient and Plots with

using Pkg
using MRCFile, FTPClient, Plots

emdid = 5778 # TRPV1
ftp = FTP(hostname = "$(emdid)/map")
dmap = read(download(ftp, "emd_$(emdid).map.gz"), MRCData)
dmin, dmax = extrema(header(dmap))
drange = dmax - dmin

anim = @animate for xsection in eachmapsection(dmap)
    plot(RGB.((xsection .- dmin) ./ drange))

gif(anim, "emd-$(emdid)_slices.gif", fps = 30)

EMD-5778 slices

Reading a map as a memory-mapped array

MRC files can be huge. It is convenient then to load their data as memory-mapped arrays. This is easy to do:

using MRCFile

path = "mymap.mrc" # path to large uncompressed MRC file
mrc = read_mmap(path, MRCData)
... # do something

Note that writing to memory-mapped arrays is currently not supported.

Related packages

mrcfile is a full-featured Python implementation of of the MRC2014 format.

Used By Packages

No packages found.