npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@warpem/mrc-parser

v1.0.0

Published

Parser for MRC (Medical Research Council) cryo-EM map files

Readme

@warpem/mrc-parser

Parser for MRC (Medical Research Council) format files, commonly used in cryo-EM (cryogenic electron microscopy) for storing 2D images, 3D volumes, and image stacks.

Install

npm install @warpem/mrc-parser

Usage

Parse an entire MRC file

import { parseMRC } from "@warpem/mrc-parser";

const buffer = await fs.readFile("map.mrc");
const { header, data } = parseMRC(buffer.buffer);

console.log(header.dimensions); // { x: 256, y: 256, z: 256 }
console.log(data.length);       // 16777216

Parse header only, then read individual slices

import { parseHeader, readSlice } from "@warpem/mrc-parser";

const buffer = await fs.readFile("stack.mrc");
const header = parseHeader(buffer.buffer);

console.log(`${header.dimensions.z} slices, ${header.dimensions.x}x${header.dimensions.y} each`);

const slice0 = readSlice(buffer.buffer, header, 0);

Fetch from a URL with progress

import { fetchMRC } from "@warpem/mrc-parser";

const { header, data } = await fetchMRC("/api/file/abc123", {
  onProgress: (received, total) => {
    console.log(`${((received / total) * 100).toFixed(0)}%`);
  },
});

Fetch only the header (Range request)

import { fetchMRCHeader, fetchSlice } from "@warpem/mrc-parser";

const header = await fetchMRCHeader("/api/file/abc123");
const middleSlice = await fetchSlice("/api/file/abc123", header, Math.floor(header.dimensions.z / 2));

API

Types

| Type | Description | |---|---| | Int3 | { x: number; y: number; z: number } — integer triplet | | Float3 | { x: number; y: number; z: number } — float triplet | | MRCDataType | Data mode enum: Byte, Short, Float, Half, UnsignedShort, ShortComplex, FloatComplex, RGB | | MRCHeader | Parsed header with dimensions, pixel size, statistics, labels, and IMOD metadata | | ReadOptions | { sliceStart?: number; sliceEnd?: number } | | FetchOptions | { signal?: AbortSignal; onProgress?: (received, total) => void } |

Functions

| Function | Description | |---|---| | parseHeader(buffer) | Parse an MRC header from an ArrayBuffer | | readData(buffer, header, options?) | Read voxel data (all or a slice range) as Float32Array | | readSlice(buffer, header, sliceIndex) | Read a single slice as Float32Array | | parseMRC(buffer) | Parse header + all data in one call | | fetchMRC(url, options?) | Fetch and parse a complete MRC file | | fetchMRCHeader(url, options?) | Fetch only the header via Range request | | fetchSlice(url, header, sliceIndex, options?) | Fetch a single slice via Range request | | fetchSlices(url, header, sliceStart, sliceEnd, options?) | Fetch a range of slices via Range request |

All data is decoded into Float32Array regardless of the source data type (Byte, Short, Half, etc.).

Supported MRC modes

| Mode | Description | Bytes/element | |---|---|---| | 0 | Unsigned 8-bit integer | 1 | | 1 | Signed 16-bit integer | 2 | | 2 | 32-bit float | 4 | | 3 | Complex (2 × int16) | 4 | | 4 | Complex (2 × float32) | 8 | | 6 | Unsigned 16-bit integer | 2 | | 12 | 16-bit float (half) | 2 | | 16 | RGB (3 × uint8) | 3 |

License

BSD-3-Clause