Skip to content

Read and write files and manipulate data in the MRC2014 format

License

Notifications You must be signed in to change notification settings

sethaxen/MRCFile.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MRCFile.jl

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.

Installation

using Pkg
Pkg.add("MRCFile")

Example

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
Pkg.add("FTPClient")
Pkg.add("Plots")
using MRCFile, FTPClient, Plots

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

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

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.

About

Read and write files and manipulate data in the MRC2014 format

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages