JSPM

@niivue/vox-loader

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 7
    • Score
      100M100P100Q41524F
    • License BSD-2-Clause

    A MagicaVoxel vox image loader to be used with the NiiVue useLoader method

    Package Exports

    • @niivue/vox-loader

    Readme

    vox-loader

    The vox-loader is a NiiVue plugin that converts MagicaVoxel .vox volumes into NIfTI volumes. It uses the 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 (pixdim, sform).

    Example voxel-based monument

    Usage

    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

    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.