# nifti-reader-js

> A JavaScript NIfTI file format reader.

Latest version **0.8.0** (published 2025-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install nifti-reader-js
pnpm add nifti-reader-js
yarn add nifti-reader-js
bun add nifti-reader-js
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2025-02-26 |
| First published | 2016-02-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 171.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 148 |
| Author | Michael Martinez |
| Maintainers | rii-mango, thanayik |
| Keywords | JavaScript, NIFTI |

## Links

- npm: https://www.npmjs.com/package/nifti-reader-js
- Repository: https://github.com/rii-mango/NIFTI-Reader-JS
- Issues: https://github.com/rii-mango/NIFTI-Reader-JS/issues
- npm.io page: https://npm.io/package/nifti-reader-js

## Dependencies (1)

- [fflate](https://npm.io/package/fflate.md) ^0.8.2

## Recent versions

- 0.8.0 (latest) — 2025-02-26
- 0.7.1 — 2025-02-09
- 0.7.0 — 2025-02-06
- 0.6.9 — 2025-02-05
- 0.6.8 — 2023-11-16
- 0.6.7 — 2023-11-13
- 0.6.6 — 2023-05-12
- 0.6.5 — 2023-05-12
- 0.6.4 — 2023-04-13
- 0.6.3 — 2023-04-13
- 0.6.2 — 2023-03-17
- 0.6.1 — 2023-03-16
- 0.6.0 — 2023-03-16
- 0.5.4 — 2017-01-16
- 0.5.3 — 2016-03-10
- … 6 more at https://npm.io/package/nifti-reader-js/versions

## README

# NIFTI-Reader-JS
A JavaScript [NIfTI](http://nifti.nimh.nih.gov/) file format reader.  This reader supports both NIfTI-1 and NIfT1-2 file formats, both compressed (.nii.gz) and uncompressed (.nii).

### Usage
[API](https://github.com/rii-mango/NIFTI-Reader-JS/wiki/API), [drawing to canvas example](https://github.com/rii-mango/NIFTI-Reader-JS/blob/master/tests/canvas.html) and [more](https://github.com/rii-mango/NIFTI-Reader-JS/tree/master/tests)

Using in a HTML `script` tag to emulate older behaviour prior to the esbuild changes in `v0.6.4`:

```html
<script type="module">
    import * as nifti from './nifti-reader.js';
    window.nifti = nifti.default;
    console.log(nifti);
</script>
``` 


```javascript
var data = // an ArrayBuffer
var niftiHeader = null,
    niftiImage = null,
    niftiExt = null;

if (nifti.isCompressed(data)) {
    data = nifti.decompress(data);
}

if (nifti.isNIFTI(data)) {
    niftiHeader = nifti.readHeader(data);
    console.log(niftiHeader.toFormattedString());
    niftiImage = nifti.readImage(niftiHeader, data);
    
    if (nifti.hasExtension(niftiHeader)) {
        niftiExt = nifti.readExtensionData(niftiHeader, data);
    }
}
```

### Install
Get a packaged source file:

* [nifti-reader.js](https://raw.githubusercontent.com/rii-mango/NIFTI-Reader-JS/master/release/current/nifti-reader.js)
* [nifti-reader-min.js](https://raw.githubusercontent.com/rii-mango/NIFTI-Reader-JS/master/release/current/nifti-reader-min.js)

Or install via [NPM](https://www.npmjs.com/):

```
npm install nifti-reader-js
```

Or install via [Bower](http://bower.io/):

```
bower install nifti-reader-js
```

### Testing
```
npm test
```

### Building
See the [release folder](https://github.com/rii-mango/NIFTI-Reader-JS/tree/master/release) for the latest builds or build it yourself using:
```
npm run build
```
This will output nifti-reader.js and nifti-reader-min.js to build/.


Acknowledgments
-----
NIFTI-Reader-JS makes use of the following third-party libraries:
- [fflate](https://github.com/101arrowz/fflate) &mdash; for GZIP inflating

---
_Source: https://npm.io/package/nifti-reader-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
