{"_id":"@cmi-dair/nifti-stream","name":"@cmi-dair/nifti-stream","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@cmi-dair/nifti-stream","displayName":"nifti-stream","type":"module","version":"0.1.0","description":"Async streaming NIFTI file reader","scripts":{"build":"node build.js","test":"vitest","test:watch":"vitest --watch","lint":"eslint .","lint:fix":"eslint . --fix","format":"prettier --write \"src/**/*.ts\" \"test/**/*.ts\"","prepare":"npm run build","dev":"npx http-server . -o demo/index.html --no-clipboard -c-1","docs":"typedoc"},"types":"./dist/index.d.ts","module":"dist/index.js","browser":"dist/nifti-stream.js","exports":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"private":false,"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"repository":{"type":"git","url":"git+https://github.com/cmi-dair/nifti-stream.git"},"bugs":{"url":"https://github.com/cmi-dair/nifti-stream/issues"},"devDependencies":{"@types/node":"^22.10.2","@typescript-eslint/eslint-plugin":"^8.18.0","@typescript-eslint/parser":"^8.18.0","esbuild":"^0.24.0","eslint":"^9.16.0","eslint-config-prettier":"^9.1.0","prettier":"^3.4.2","typedoc":"^0.27.4","typescript":"^5.7.2","vitest":"^2.1.8"},"_id":"@cmi-dair/nifti-stream@0.1.0","gitHead":"c8b0c6ac36afa4f84da2e6eb3e0a6d93968238b3","homepage":"https://github.com/cmi-dair/nifti-stream#readme","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-DlCcjRGrN2R2E6AzmzzcuCFNG1fhgrBsIo2h1UjDsGpwfcz2SQaOklxkTW+6eVnPIXrR/offtcKo6AFa+h50JQ==","shasum":"1b153c8b8458cb8d89ce3675e4e9a8708dc49157","tarball":"https://registry.npmjs.org/@cmi-dair/nifti-stream/-/nifti-stream-0.1.0.tgz","fileCount":15,"unpackedSize":306693,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD7UZHxlVNZgmvitCgSZXbP6PWV36txtcsYPcrKaJmtqQIgPCGUkz4gtriFI8cT6gv0yyFzAARVyXyiT5iqXauYyhQ="}]},"_npmUser":{"name":"nx10","email":"floruppr@gmail.com"},"directories":{},"maintainers":[{"name":"reindervdw","email":"reinder.vosdewael@gmail.com"},{"name":"nx10","email":"floruppr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nifti-stream_0.1.0_1734029230853_0.5002854610982055"},"_hasShrinkwrap":false}},"time":{"created":"2024-12-12T18:47:10.710Z","0.1.0":"2024-12-12T18:47:11.071Z","modified":"2024-12-12T18:47:11.344Z"},"maintainers":[{"name":"reindervdw","email":"reinder.vosdewael@gmail.com"},{"name":"nx10","email":"floruppr@gmail.com"}],"description":"Async streaming NIFTI file reader","homepage":"https://github.com/cmi-dair/nifti-stream#readme","repository":{"type":"git","url":"git+https://github.com/cmi-dair/nifti-stream.git"},"bugs":{"url":"https://github.com/cmi-dair/nifti-stream/issues"},"readme":"# nifti-stream\n\nA streaming parser for NIFTI-1 and NIFTI-2 neuroimaging files, designed for efficient client-side processing and progressive loading in web applications.\n\nBased on [NIFTI-Reader-JS](https://github.com/rii-mango/NIFTI-Reader-JS).\n\n## Features\n\n- 🚰 **True Streaming**: Process NIFTI files as they download, no need to wait for complete file\n- 🔄 **Progressive Loading**: Load and display slices as they arrive\n- 📊 **Flexible Dimension Handling**: Stream 2D slices, 3D volumes, or 4D timeseries\n- 🗜️ **Automatic Decompression**: Handles gzipped NIFTI files transparently\n- 🎯 **Selective Loading**: Read only the header, or stop after specific slices\n- 💻 **Browser-Ready**: Works directly in modern browsers\n- 📦 **Lightweight**: ~17kB minified, no dependencies\n\n### Live demo\n\nSee our [live demo](https://childmindresearch.github.io/nifti-stream/demo) and check out the [demo source code](https://github.com/childmindresearch/nifti-stream/tree/main/demo).\n\n## Installation\n\n```bash\nnpm install @cmi-dair/nifti-stream\n```\n\n## Quick Start\n\n```javascript\nimport { NiftiStream } from 'nifti-stream';\n\n// Get a ReadableStream from fetch\nconst response = await fetch('brain.nii.gz');\nconst reader = new NiftiStream(response.body, {\n  sliceDimension: 2,  // Stream 2D slices\n  onHeader: (header) => {\n    console.log('Dimensions:', header.dims);\n  },\n  onSlice: (data, indices) => {\n    // Process each slice as it arrives\n    displaySlice(data, indices);\n  }\n});\n\nawait reader.start();\n```\n\n## Usage\n\n### Streaming Options\n\n```javascript\nconst reader = new NiftiStream(stream, {\n  // Choose how to slice the data\n  sliceDimension: 2,  // 2 for XY slices, 3 for volumes, 4 for timeseries\n\n  // Get header metadata\n  onHeader: (header) => {\n    console.log(header.dims);        // Image dimensions\n    console.log(header.pixDims);     // Voxel sizes\n    console.log(header.datatype);    // Data type\n    return false;  // Return true to stop after header\n  },\n\n  // Handle extensions if present\n  onExtension: (extension) => {\n    if (extension) {\n      console.log(extension.ecode);  // Extension code\n      console.log(extension.edata);  // Extension data\n    }\n  },\n\n  // Process image data\n  onSlice: (data, indices, header) => {\n    // data: ArrayBuffer containing raw slice data\n    // indices: Position of slice in dataset\n    // header: Reference to NIFTI header\n  },\n\n  // Handle any errors\n  onError: (error) => {\n    console.error('Error:', error);\n  }\n});\n```\n\n### Control Flow\n\nStop streaming at any time:\n```javascript\nawait reader.stop();\n```\n\n## API Documentation\n\nFull API documentation is available at [childmindresearch.github.io/nifti-stream](https://childmindresearch.github.io/nifti-stream).\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}