open-index/open-npm huggingface dataset:
npm package: @niivue/cbor-loader
Description: itkwasm enables universal [image and mesh processing](https://wasm.itk.org/en/latest/introduction/packages.html) via WebAssembly (wasm). However, itkwasm uses its own [binary format for images (iwi) and meshes (iwm)](https://wasm.itk.org/en/latest/introdu
Author: NiiVue developers
Latest version: 1.2.1

# niivue-itk-wasm

itkwasm enables universal [image and mesh processing](https://wasm.itk.org/en/latest/introduction/packages.html) via WebAssembly (wasm). However, itkwasm uses its own [binary format for images (iwi) and meshes (iwm)](https://wasm.itk.org/en/latest/introduction/file_formats/index.html). Therefore, for other tools to use itkwasm, they must read and write these formats. This repository converts between the popular [NIfTI image format](https://brainder.org/2012/09/23/the-nifti-file-format/) and iwi, and converts between triangular meshes (defined by vertex position and vertex indices) and iwm. This allows tools like NiiVue to use itkwasm functions. To see this in action, try the [live demo](https://niivue.github.io/niivue-itk-wasm/)

## Creating validation IWI images

This repository is designed to convert between NIfTI and iwi. To validate this function, you can use a simple Python script with the itkwasm reference implementation to generate iwi images from a NIfTI input. This will work with any NIfTI image, but in this example we use the file `LAS.nii.gz` from the [NIfTIspace](https://github.com/rordenlab/NIfTIspace) repository.

```python
import itkwasm
from itkwasm_image_io import imread, imwrite
image = imread('LAS.nii.gz', component_type=itkwasm.int_types.IntTypes.UInt8)
imwrite(image, 'u8.iwi.cbor')
image = imread('LAS.nii.gz', component_type=itkwasm.int_types.IntTypes.UInt16)
imwrite(image, 'u16.iwi.cbor')
image = imread('LAS.nii.gz', component_type=itkwasm.int_types.IntTypes.Int16)
imwrite(image, 'i16.iwi.cbor')
image = imread('LAS.nii.gz', component_type=itkwasm.int_types.IntTypes.Int32)
imwrite(image, 'i32.iwi.cbor')
image = imread('LAS.nii.gz', component_type=itkwasm.float_types.FloatTypes.Float32)
imwrite(image, 'f32.iwi.cbor')
image = imread('LAS.nii.gz', component_type=itkwasm.float_types.FloatTypes.Float64)
imwrite(image, 'f64.iwi.cbor')
```

## Creating validation IWM meshes

We can also use the reference Python library to create iwm meshes. Here we convert the mesh [simplify_brain.obj](https://github.com/niivue/niivue/tree/main/tests/images) from WaveFront OBJ format to IWM.

```python
from itkwasm_mesh_io import meshread, meshwrite
mesh = meshread('simplify_brain.obj')
meshwrite(mesh, 'stl.stl')
meshwrite(mesh, 'iwm.iwm.cbor')
```
npm package: @niivue/itkwasm-loader
Description: An loader based on ITK-Wasm image and mesh IO to be used with the NiiVue useLoader method
Author: NiiVue developers
Latest version: 1.0.2

# itkwasm-loader

The itkwasm-loader is a [NiiVue](https://niivue.com/) plugin that converts [ITK-Wasm image IO-supported volumes]( https://docs.itk.org/projects/wasm/en/latest/introduction/file_formats/images.html) into NIfTI volumes and [ITK-Wasm mesh IO-supported meshes](https://docs.itk.org/projects/wasm/en/latest/introduction/file_formats/meshes.html) into MZ3 meshes. It uses the [@itk-wasm/image-io](https://www.npmjs.com/package/@itk-wasm/image-io) and [@itk-wasm/mesh-io](https://www.npmjs.com/package/@itk-wasm/mesh-io) libraries.

![Example image](./image-example.png)

![Example mesh](./mesh-example.png)

## Installation

```bash
npm install @niivue/itkwasm-loader
```

## Usage

### Quick Start

```javascript
import { Niivue } from '@niivue/niivue'
import { useItkWasmLoaders } from '@niivue/itkwasm-loader'

const nv = new Niivue()
await nv.attachToCanvas(document.getElementById('niivue-canvas'))

useItkWasmLoaders(nv)
```

This will add support for volume and mesh file formats not fully supported by default in NiiVue. To add support for all ITK-Wasm supported formats, call `useAllItkWasmLoaders` instead of `useItkWasmLoaders`.

### Custom Loaders

You can also create custom loaders for specific file formats using `createImageLoader` and `createMeshLoader`:

```javascript
import { Niivue } from '@niivue/niivue'
import { createImageLoader, createMeshLoader } from '@niivue/itkwasm-loader'

const nv = new Niivue()
await nv.attachToCanvas(document.getElementById('niivue-canvas'))

// Register a custom loader for TIFF images
nv.useLoader(createImageLoader('tif'), 'tif', 'nii')

// Register a custom loader for VTK meshes
nv.useLoader(createMeshLoader('vtk'), 'vtk', 'mz3')
```

This approach gives you fine-grained control over which formats to support and allows you to selectively register loaders for specific extensions.

See also the [NiiVue loader documentation](https://link-todo).

## Vite Configuration

If you are using Vite, you may need to add the following to your `vite.config.js`:

```javascript
import { defineConfig } from 'vite'

export default defineConfig({
  optimizeDeps: {
    exclude: ["itk-wasm", "@itk-wasm/mesh-io", "@itk-wasm/image-io", "@thewtex/zstddec"],
  },
});
```

## Local Browser Development

You can embed this loader into a hot-reloadable NiiVue web page to evaluate integration:

```
git clone git@github.com:niivue/itkwasm-loader.git
cd itkwasm-loader
npm install
npm run dev
```

## Alternative libraries

See also the [built-in NiiVue format support](https://niivue.com/docs/loading#supported-formats), [NiiVue ITK-Wasm cbor-loader](https://github.com/niivue/cbor-loader), which support ITK-Wasm's native CBOR format and in-memory [interface types](https://docs.itk.org/projects/wasm/en/latest/typescript/interface_types/index.html), [other NiiVue loaders and the NiiVue plugin documentation](https://niivue.com/docs/plugins).
npm package: @niivue/minc-loader
Description: A MINC voxel image loader to be used with the NiiVue useLoader method
Author: NiiVue developers
Latest version: 1.0.0

# minc-loader

The minc-loader is a NiiVue plugin that converts [MINC format](https://en.wikibooks.org/wiki/MINC/SoftwareDevelopment/MINC2.0_File_Format_Reference) .mnc volumes into NIfTI volumes. It adapts code from [brainbrowser](https://github.com/aces/brainbrowser) library to read .mnc files (stored in both the older NetCDF and the more recent HDF5 structures). 

## Local Development

To illustrate this library, `minc2nii.js` is a node.js converter that can be run from the command line. The command `npm run test` runs some regression tests. The command `npm run cli` converts a MINC file to NIfTI from the command line. Finally, the command `node ./src/minc2nii.js /path/to/minc/minc.mnc` allows you to specify specific files to convert.

```
git clone git@github.com:rordenlab/minc-loader.git
cd minc-loader
npm install
npm run test
npm run cli
node ./src/minc2nii.js ./tests/testData/ax.mnc
```

## Local Browser Development

You can also embed this loader into a hot-reloadable NiiVue web page to evaluate integration:

```
git clone git@github.com:rordenlab/minc-loader.git
cd minc-loader
npm install
npm run dev
```

## Links

 - [mnc2nii.py](https://github.com/neurolabusc/mnc2nii.py) provides a Python nibabel conversion script and sample images.
 - [brainbrowser](https://github.com/aces/brainbrowser) code for hdf5 and netcdf reading is used here.
 - [nii2mnc](https://bic-mni.github.io/man-pages/man/nii2mnc.html) command line tool to convert NIfTI images to MINC (e.g. `Original`->`In`)
 - [mnc2nii](https://bic-mni.github.io/man-pages/man/mnc2nii.html) reference command line tool to convert MINC images to NIfTI (e.g. `In`->`Ref`)
 - [mincconvert](https://bic-mni.github.io/man-pages/man/mincconvert.html) command line tool for converting between MINC1 (netcdf) and MINC2 (HDF5) formats.
 - [minc2.py](https://github.com/nipy/nibabel/blob/84294f4e05e0f10f9cc64d3474f94ad3e243f682/nibabel/minc2.py#L144) nibabel Python class for reading MINC2 (HDF5) images.
 - [minc1.py](https://github.com/nipy/nibabel/blob/84294f4e05e0f10f9cc64d3474f94ad3e243f682/nibabel/minc1.py) nibabel Python class for reading MINC1 (netcdf) images.
 - [minc_to_nifti.py](https://gist.github.com/ofgulban/46d5c51ea010611cbb53123bb5906ca9) is a minimal nibabel wrapper for converting MINC images to NIfTI, but unlike `mnc2nii.py` it does not preserve details such as the spatial transfomation affine matrix.
npm package: @niivue/niivue
Description: minimal webgl2 nifti image viewer
Author: niivue authors
Latest version: 0.68.1

# NiiVue

NiiVue is web-based visualization tool for neuroimaging that can run on any operating system and any web device (phone, tablet, computer). This repository contains only the **core NiiVue package** that can be embedded into other projects. See [niivue.com](https://niivue.com/) for examples and documentation. 

## Local Development

To run a hot-loading development that is updated whenever you save changes to any source files, you can run:

```
git clone git@github.com:niivue/niivue.git
cd niivue
npm install
npm run dev
```
npm package: @niivue/vox-loader
Description: A MagicaVoxel vox image loader to be used with the NiiVue useLoader method
Author: NiiVue developers
Latest version: 1.0.0

# vox-loader

The vox-loader is a NiiVue plugin that converts MagicaVoxel .vox volumes into NIfTI volumes. It uses the [vox-reader](https://www.npmjs.com/package/vox-reader) library to parse vox files. This is designed to be a minimal loader to illustrate NiiVue plugin loader design. Note that for more complex formats you would want to set the [spatial properties of the NIfTI header](https://brainder.org/2012/09/23/the-nifti-file-format/) (pixdim, sform).

![Example voxel-based monument](monument.jpg)

## Usage

```javascript
import { Niivue } from '@niivue/niivue'
import { vox2nii } from '@niivue/vox-loader'

const nv = new Niivue()
nv.attachToCanvas(document.getElementById('niivue-canvas'))
// supply loader function, fromExt, and toExt (without dots)
nv.useLoader(vox2nii, 'vox', 'nii')
await nv.loadImages([
  {
    url: '/example.vox'
  }
])
```

## Local Development

To illustrate this library, `vox2nii` is a node.js converter that can be run from the command line:

```
git clone git@github.com:niivue/niivue.git
cd packages/vox-loader
npm install
npm run build
npm run cli # tests the conversion
```

## Local Browser Development

You can also embed this loader into a hot-reloadable NiiVue web page to evaluate integration:

```
git clone git@github.com:niivue/niivue.git
cd packages/vox-loader
npm install
npm run dev
```

## Sample datasets

- [ephtracy provides sample models and the specification](https://github.com/ephtracy/voxel-model/tree/master). Note the sample model included in this repository is one of these models.

## Alternative libraries

Two similar libraries are provided. Both are equally simple for node usage, but the vox-reader is a bit simpler for web usage.

- [parse-magica-voxel](https://www.npmjs.com/package/parse-magica-voxel).
- [vox-reader](https://www.npmjs.com/package/vox-reader).