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

nifti-imaging

v0.0.1

Published

Neuroimaging Informatics Technology Initiative (NIfTI) image rendering for Node.js and browser

Downloads

137

Readme

nifti-imaging

NPM version NPM downloads build MIT License

Neuroimaging Informatics Technology Initiative (NIfTI) image rendering pipeline for Node.js and browser using the nifti-reader-js library.

Note

This effort is a work-in-progress and should not be used for production or clinical purposes.

Install

Node.js

npm install nifti-imaging

Browser

<script type="text/javascript" src="https://unpkg.com/nifti-imaging"></script>

Build

npm install
npm run build

Features

  • Renders single and multi-slice datasets with optional adjustment of window/level and color palette.
  • Handles all standard NIfTI datatypes, including integer, float and complex voxel types.
  • Decodes gzip-compressed NIfTI files (.nii.gz) transparently.
  • Supports 4D time-series datasets.
  • Outputs RGBA pixel arrays, suitable for use with HTML5 Canvas, WebGL and WebGPU, or other imaging libraries.
  • Provides a common bundle for both Node.js and browser.

Supported Datatypes

  • UINT8 (Type code 2)
  • INT8 (Type code 256)
  • UINT16 (Type code 512)
  • INT16 (Type code 4)
  • UINT32 (Type code 768)
  • INT32 (Type code 8)
  • FLOAT32 (Type code 16)
  • FLOAT64 (Type code 64)
  • COMPLEX64 (Type code 32) — rendered as voxel magnitude
  • RGB24 (Type code 128) — true-color

Usage

Basic image rendering

// Import objects in Node.js
const niftiImaging = require('nifti-imaging');
const { NiftiImage } = niftiImaging;

// Import objects in Browser
const { NiftiImage } = window.niftiImaging;

// Create an ArrayBuffer with the contents of the NIfTI byte stream.
const image = new NiftiImage(arrayBuffer);

// Render image.
const renderingResult = image.render();

// Rendered pixels in an RGBA ArrayBuffer.
const renderedPixels = renderingResult.pixels;
// Rendered width.
const width = renderingResult.width;
// Rendered height.
const height = renderingResult.height;

Advanced image rendering

// Import objects in Node.js
const niftiImaging = require('nifti-imaging');
const { NiftiImage, WindowLevel } = niftiImaging;
const { StandardColorPalette } = niftiImaging.constants;

// Import objects in Browser
const { NiftiImage, WindowLevel } = window.niftiImaging;
const { StandardColorPalette } = window.niftiImaging.constants;

// Create an ArrayBuffer with the contents of the NIfTI byte stream.
const image = new NiftiImage(arrayBuffer);

// Create image rendering options.
const renderingOpts = {
  // Optional slice index.
  // If not provided, the first slice is rendered.
  slice: 0,
  // Optional time-point index for 4D datasets.
  // If not provided, the first time-point is used.
  timePoint: 0,
  // Optional user-provided window/level.
  // If not provided, the rendering pipeline calculates it from pixel values.
  windowLevel: new WindowLevel(windowWidth, windowLevel),
  // Optional flag to indicate whether histograms should be calculated.
  // If not provided, the histograms are not calculated.
  calculateHistograms: false,
  // Optional standard color palette.
  // If not provided, the grayscale palette is used.
  colorPalette: StandardColorPalette.Grayscale
};

// Render image.
const renderingResult = image.render(renderingOpts);

// Rendered pixels in an RGBA ArrayBuffer.
const renderedPixels = renderingResult.pixels;
// Rendered slice index.
const slice = renderingResult.slice;
// Rendered time-point index.
const timePoint = renderingResult.timePoint;
// Rendered width.
const width = renderingResult.width;
// Rendered height.
const height = renderingResult.height;
// Window/level used to render the pixels.
const windowLevel = renderingResult.windowLevel;
// Array of calculated per-channel histograms.
// In case calculateHistograms rendering option is false
// histograms should not be present.
const histograms = renderingResult.histograms;

Please check a live example here.

License

nifti-imaging is released under the MIT License.