Skip to content

Commit

Permalink
Merge pull request #21 from rordenlab/development
Browse files Browse the repository at this point in the history
New stable release (v1.0.20220720)
  • Loading branch information
neurolabusc committed Aug 9, 2022
2 parents a2f2d28 + f94fd1d commit 9044a34
Show file tree
Hide file tree
Showing 41 changed files with 7,542 additions and 271 deletions.
88 changes: 88 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
environment:
matrix:
- job_name: win
appveyor_build_worker_image: Visual Studio 2019

- job_name: linux
appveyor_build_worker_image: Ubuntu2004

- job_name: mac
appveyor_build_worker_image: macos-catalina

matrix:
fast_finish: true

version: build-{build}

configuration: Release

platform: x64

clone_depth: 1

init:
- ps: >-
$env:DATE = $(Get-Date -Format d-MMM-yyyy)
$githash = $env:APPVEYOR_REPO_COMMIT.Substring(0, 7)
$gittag = if ($env:APPVEYOR_REPO_TAG -eq $True) {"_$($env:APPVEYOR_REPO_TAG_NAME)"} else {""}
Update-AppveyorBuild -Version "$($env:DATE)_g${githash}${gittag}"
$env:RELEASE_VERSION = $(Get-Date -Format d-MMMM-yyyy)
for:
-
matrix:
only:
- job_name: win

build_script:
- cmake -Wno-dev -B build
- cmake --build build --config %configuration%

after_build:
- 7z a niimath_win.zip .\build\bin\* >$null
- appveyor PushArtifact niimath_win.zip

-
matrix:
only:
- job_name: linux

build_script:
- export CC=gcc-8 CXX=g++-8
- cmake -Wno-dev -B build
- cmake --build build

after_build:
- 7z a niimath_lnx.zip ./build/bin/* &>/dev/null
- appveyor PushArtifact niimath_lnx.zip

-
matrix:
only:
- job_name: mac

build_script:
- sudo xcode-select -s /Applications/Xcode-11.3.1.app
- cmake -Wno-dev -B build
- cmake --build build

after_build:
- 7z a niimath_macos.zip ./build/bin/* &>/dev/null
- appveyor PushArtifact niimath_macos.zip

deploy:
- provider: GitHub
tag: $(APPVEYOR_REPO_TAG_NAME)
release: version $(RELEASE_VERSION) ($(APPVEYOR_REPO_TAG_NAME))
description: ""
auth_token:
secure: hz/FloIhbQHhqmi2KhuKhO59uahHgTnx2tpnpTGSQetrZ5A9o/l6n1dY1a7DKAAc
artifact: /niimath_.*\.zip/
draft: false
prerelease: false
on:
APPVEYOR_REPO_TAG: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/bin/
/src/niimath
niimath
/dist
/node_modules
47 changes: 0 additions & 47 deletions .travis.yml

This file was deleted.

10 changes: 10 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,13 @@ 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.

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
34 changes: 27 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[![Build Status](https://travis-ci.org/rordenlab/dcm2niix.svg?branch=master)](https://travis-ci.org/rordenlab/niimath)
[![Build status](https://ci.appveyor.com/api/projects/status/7o0xp2fgbhadkgn1?svg=true)](https://ci.appveyor.com/project/neurolabusc/niimath)

## About
Expand Down Expand Up @@ -51,12 +50,12 @@ cl /Feniimath niimath.c core.c tensor.c core32.c core64.c bwlabel.c niftilib/ni
Simply running `make` in the `src` folder should compile niimath on Linux. This should work regardless of if you use the Clang/LLVM or gcc compiler. However, the resulting executable will only work with specific versions of Linux. If you want to make a universal Linux release you can use [holy-build-box](https://github.com/FooBarWidget/holy-build-box). Be aware that this uses an old version of the gcc compiler (4.8.5), so the resulting performance may not be optimized for your system.

```
cd ~/holy-build-box
git clone https://github.com/rordenlab/niimath
#start docker
sudo docker run --mount src="$(pwd)",target=/test_container,type=bind -t -i --rm ghcr.io/foobarwidget/holy-build-box-x64 bash
cd ./test_container/niimath/src
make -j
sudo docker run -t -i --rm -v `pwd`:/io ghcr.io/foobarwidget/holy-build-box-x64 /hbb_exe/activate-exec bash
cd /io/niimath/src
make
exit
sudo chown $(whoami) ./niimath/src/niimath
```

## Usage
Expand Down Expand Up @@ -97,6 +96,7 @@ niimath has a few features not provided by fslmaths:
- dogx <sPos> <sNeg> : as dog, zero-crossing for 2D sagittal slices
- dogy <sPos> <sNeg> : as dog, zero-crossing for 2D coronal slices
- dogz <sPos> <sNeg> : as dog, zero-crossing for 2D axial slices
- mesh : see separate section below
- `--compare` <ref> : report if images are identical, terminates without saving new image\n");
- filename.nii : mimic fslhd (can also export to a txt file: 'niimath T1.nii 2> T1.txt') report header and terminate without saving new image

Expand Down Expand Up @@ -156,9 +156,29 @@ Here are the same testson a desktop computer with twelve cores (24 threads, Ryze
| niimath rest -demean out (same output as above) | 2.6x (2.6x) | 3.0x (10.8x) |
| fslmaths rest -bptf 77 8.68 out : 887 (1019) | 2.6x (2.5x) | 23x (23.0x) |

## Converting voxelwise images to a triangulated mesh

niimath can convert NIfTI images to meshes, suitable for viewing in Surfice, blender, SUMA, FreeSurfer and other tools. The features are based on [nii2mesh](https://github.com/neurolabusc/nii2mesh) and the features are almost identical. However, the order of arguments is different to match the expectations of fslmaths/niimath. So the call `nii2mesh -r 1 bet.nii.gz r100.ply` becomes `niimath bet.nii.gz -mesh -r 1 r100.ply`. As described on the nii2mesh page, you can create independent meshes for each area in an atlas using the command:

```
niimath D99_atlas_v2.0_right.nii.gz -mesh -p 0 -s 10 -a D99_v2.0_labels_semicolon.txt ./gii/D99s10roi.gii
```
Both programs allow you to explicitly set the isolevel using the `-i` value, so `-i 128` we render a surface for voxels brighter than 128. One minor difference between the programs is that niimath allows you also request `dark`, `medium` and `bright` using the `-i d`, `-i m` and `-i b` commands respectively. These use Otsu's method, and typically identify pleasing values. Also, if the user does not specify an isolevel be aware that nii2mesh chooses the middle brightness (the midpoint between the darkest and brightest value) while niimath uses the medium Otsu threshold. The latter is more robust to outliers. Here are examples illustrating this usage:

```
niimath bet.nii.gz -mesh -i 128 Isolevel128.gii
niimath bet.nii.gz -mesh -i d darkIsolevel.gii
niimath bet.nii.gz -mesh -i m medIsolevel.gii
niimath bet.nii.gz -mesh -i b brightIsolevel.gii
```

## WebAssembly

niimath can also be compiled to WebAssembly (Wasm) allowing it to be inserted into web pages and Node.js projects. Here is a [live demo](https://niivue.github.io/niivue-niimath/) with links to source code and instructions.

## License

niimath is licensed under the 2-Clause BSD License. Except where noted, the code was written by Chris Rorden in 2020. The code in `tensor.c` was written by Daniel Glen (2004) from the US National Institutes of Health and is not copyrighted (though it is included here with the permission of the author). The FSL team graciously allowed the text strings (help, warning and error messages) to be copied verbatim. The Butterworth Filter Coefficients in `bw.c` are from [Exstrom Labs](http://www.exstrom.com/journal/sigproc/) and the authors provided permission for it to be included in this project under the [LGPL](https://www.gnu.org/licenses/lgpl-3.0.en.html), the file provides additional details. Taylor Hanayik from the FSL group provided pseudo-code for some functions where there is little available documentation.
niimath is licensed under the 2-Clause BSD License. Except where noted, the code was written by Chris Rorden in 2020-2022. The code in `tensor.c` was written by Daniel Glen (2004) from the US National Institutes of Health and is not copyrighted (though it is included here with the permission of the author). The FSL team graciously allowed the text strings (help, warning and error messages) to be copied verbatim. The Butterworth Filter Coefficients in `bw.c` are from [Exstrom Labs](http://www.exstrom.com/journal/sigproc/) and the authors provided permission for it to be included in this project under the [LGPL](https://www.gnu.org/licenses/lgpl-3.0.en.html), the file provides additional details. Taylor Hanayik from the FSL group provided pseudo-code for some functions where there is little available documentation. The PolygoniseCube function comes from Cory Bloyd's public domain [Marching Cubes example](http://paulbourke.net/geometry/polygonise/) program described here. The bwlabel.cpp file was written by Jesper Andersson, who has explicitly allowed this to be shared using the BSD 2-Clause license. The [high performance](https://github.com/gaspardpetit/base64) base64.cpp was written by Jouni Malinen and is distributed under the BSD license. The mesh simplification was written by [Sven Forstmann](https://github.com/sp4cerat/Fast-Quadric-Mesh-Simplification) and distributed under the MIT license. It was ported from C++ to C by Chris Rorden. The [radixsort.c](https://github.com/bitshifter/radixsort) was written by Cameron Hart (2014) using the zlib license.

## Links

Expand Down
2 changes: 1 addition & 1 deletion SuperBuild/External-CLOUDFLARE-ZLIB.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(CLOUDFLARE_BRANCH gcc.amd64) # Cloudflare zlib branch

ExternalProject_Add(zlib
GIT_REPOSITORY "${git_protocol}://github.com/ningfei/zlib.git"
GIT_REPOSITORY "${git_protocol}github.com/ningfei/zlib.git"
GIT_TAG "${CLOUDFLARE_BRANCH}"
SOURCE_DIR cloudflare-zlib
BINARY_DIR cloudflare-zlib-build
Expand Down
11 changes: 7 additions & 4 deletions SuperBuild/SuperBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ if(NOT GIT_FOUND)
endif()

# Use git protocol or not
option(USE_GIT_PROTOCOL "If behind a firewall turn this off to use http instead." ON)
option(USE_GIT_PROTOCOL "If behind a firewall turn this off to use https instead." OFF)
if(USE_GIT_PROTOCOL)
set(git_protocol "git")
set(git_protocol "ssh://git@")
else()
set(git_protocol "https")
set(git_protocol "https://")
endif()

#emulate fslmaths behavior, add pigz support
Expand All @@ -29,7 +29,10 @@ endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

option(USE_STATIC_RUNTIME "Use static runtime" ON)
option(OPENMP_XCODE "Build the static library" OFF)

if(${CMAKE_C_COMPILER_ID} STREQUAL "AppleClang")
option(OPENMP_XCODE "Build with OpenMP support" OFF)
endif()

include(ExternalProject)

Expand Down
62 changes: 0 additions & 62 deletions appveyor.yml

This file was deleted.

39 changes: 39 additions & 0 deletions node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: rm package-lock.json
- run: npm install
- run: npm i puppeteer-core
- run: npm run build --if-present
- run: sudo apt-get install xvfb
- run: xvfb-run --auto-servernum npm run test
- uses: actions/upload-artifact@v2
if: failure()
with:
name: test_data_and_screenshots
path: tests
Loading

0 comments on commit 9044a34

Please sign in to comment.