@niivue/niimath — licensing
============================

This npm package ships TWO independent WebAssembly builds of niimath, under
different licenses. Which license applies to YOUR use depends on which entry
point you import:

  * import { Niimath } from '@niivue/niimath'        -> BSD-2-Clause build
        (dist/index.js, dist/niimath.js, dist/niimath.wasm)
        Contains NO GPL code. Covered by the BSD 2-Clause License below.

  * import { Niimath } from '@niivue/niimath/gpl'     -> GPL-2.0-only build
        (dist/index-gpl.js, dist/niimath-gpl.js, dist/niimath-gpl.wasm)
        A COMBINED WORK that links the BSD niimath sources together with the
        optional GPL-2 spm_coreg module (the niimath_gpl submodule). As a
        combined work it is distributed under the GNU General Public License,
        version 2 — see LICENSE.GPL-2.0.txt and GPL-NOTICE.md. The full
        corresponding source and a written offer for it are described in
        GPL-NOTICE.md.

Distributing or bundling the '@niivue/niimath/gpl' build makes the resulting
work a GPL-2.0 work. If you must remain BSD-2-Clause, use only the default
'@niivue/niimath' import.

SPDX-License-Identifier: BSD-2-Clause AND GPL-2.0-only

--------------------------------------------------------------------------------
BSD 2-Clause License (applies to the default '@niivue/niimath' build and to all
niimath sources authored in the rordenlab/niimath repository)
--------------------------------------------------------------------------------

Copyright (c) 2020, Chris Rorden's Lab
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

3dUnifize, 3dAllineate, and tensor are from the AFNI team of Robert W. Cox, et al. and are provided by consent and as allowed by the National Institutes of Health Public Domain Notice found with the AFNI code.

The PolygoniseCube function comes from Cory Bloyd's public domain Marching Cubes Example Program described here http://paulbourke.net/geometry/polygonise/

The bwlabel.cpp file was written by Jesper Andersson, who has explicitly allowed this to be shared using the BSD 2-Clause license (above).

base64.cpp was written by Jouni Malinen and is distributed under the BSD license. For a performance evaluation, see https://github.com/gaspardpetit/base64

simplify.h was written by Sven Forstmann and distributed under the MIT license. It was ported from C++ to C by Chris Rorden. https://github.com/sp4cerat/Fast-Quadric-Mesh-Simplification

The software can be optionally compiled to use the radixsort files written by Cameron Hart (2014) using the zlib license. https://github.com/bitshifter/radixsort

Optional GPL module: the source in the rordenlab/niimath repository is BSD-2-Clause (above). The optional GPL-2 `spm_coreg` module (the niimath_gpl submodule, https://github.com/rordenlab/niimath_gpl) provides the `-spm_coreg` and `-spm_deface` commands, enabled only when compiled with -DHAVE_GPL (e.g. `make GPL=1`). A binary built with that module is a combined work and must be distributed under the GNU General Public License, version 2; binaries built without it remain BSD-2-Clause. The runtime version string ends in " GPL" or " BSD" to show which applies.
