1.0.0 • Published 2 months ago

varian-converter v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

varian-converter

Load and parse varian NMR native format.

NPM version build status npm download

Parse varian NMR native format.

The code currently parses 1-dimensional NMR only.

Installation

npm i varian-converter filelist-utils

Usage

The convert1D function expects a FileCollection. There are normally 4 files in a 1D fid directory:

  1. fid
  2. procpar
  3. text
  4. log

1 and 2 must exist or convert1D will error out.

FileCollections are returned from the filelist-utils package which runs both in NodeJS and the browser.

For passing multiple directories the convert1D should run in a loop, each time passing a FileCollection corresponding to the 1D (fid and procpar must exist), pushing the result object elsewhere.

Use in Browser

The user may upload:

  • a zip file with the fid directory compressed
  • a fid directory

See the example folder.

Use in NodeJS

  • Compressed fid directory
import { join } from 'path';
import { readFileSync } from 'fs';
// allows us to load a directory in NodeJS
import { fileCollectionFromZip } from 'filelist-utils';
import { convert1D as cv } from 'varian-converter';

const zipBuffer = readFileSync(join(__dirname, 'path/to/compressed.fid.zip'));
fileCollectionFromZip(zipBuffer)
  .then((fileCollection) => cv(fileCollection))
  .then((result) => console.log(result))
  .catch((e) => console.log(e));
  • Standard fid directory
import { join } from 'path';
import { fileCollectionFromPath } from 'filelist-utils';
import { convert1D as cv } from 'varian-converter';

const fileCollection = fileCollectionFromPath(
  join(__dirname, 'path/to/dir.fid'),
);
cv(fileCollection)
  .then((result) => console.log(result))
  .catch((e) => console.log(e));

Output

convert1D returns an object with the signature

{
  meta: Record<string,any>
  procpar: Record<string,any>
  fid: [data1, data2, data3..]
  x: Float64Array (time values)
}

License

MIT

1.0.0

2 months ago

0.3.5

3 months ago

0.3.4

4 months ago

0.3.3

7 months ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago