ohsu-qin/nifti-js

Name: nifti-js

Owner: OHSU QIN

Description: NIfTI support for Javascript

Forked from: scijs/nifti-js

Created: 2016-03-09 19:37:27.0

Updated: 2016-03-09 19:37:28.0

Pushed: 2015-10-26 11:02:36.0

Homepage: null

Size: 164

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

NIfTI support for Javascript

This can parse files in the Neuroimaging Informatics Technology Initiative format (version 1). Currently, data (as opposed to the header) can only be read from “.nii” files (files that include both the header and the data in one file), you can still read the header from a header-only file though.

build status

Note that the output is compatible with what is output by nrrd-js. The main area where this breaks down (so far) is encoding orientation information. The NIfTI file format allows for two different transformations in one file (with various options for specifying the transformations). In contrast, the NRRD format only supports a very simple scheme whereby the “data axes” can be mapped to basis vectors in the physical space (in addition to another scheme more or less corresponding to “method 1” in the NIfTI format). Currently, nifti-js simply discards one type of transformation (the sform transformation).

Also note that for now quite a lot of what is read from the NIfTI file is discarded. The idea is that eventually most of what is now discarded should be mapped to NRRD attributes as much as possible, with the rest mapping to key/value pairs (for example).

Example

To use with ndarray, proceed as follows:

file = nifti.parse(...);
array = ndarray(file.data, file.sizes.slice().reverse());
Install

Install using npm:

npm install nifti-js
API
require("nifti-js").parse(buffer)

Parses header and data from buffer, returning an object with NRRD-compatible properties. Expects an ArrayBuffer or Buffer object.

require("nifti-js").parseHeader(buffer)

Parses just the header from buffer, returning an object with NRRD-compatible properties. Expects an ArrayBuffer or Buffer object.

require("nifti-js").parseNIfTIHeader(buffer)

Parses just the header from buffer, returning an object with the raw NIfTI information. Expects an ArrayBuffer or Buffer object.

License

(c) 2015 Jasper van de Gronde. MIT License


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.