Skip to content

Commit

Permalink
Merge branch 'master' into BumpITKv4.5rc2
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex authored Apr 16, 2024
2 parents 6fb73c0 + d4df8ff commit 77aa1f7
Show file tree
Hide file tree
Showing 23 changed files with 3,824 additions and 0 deletions.
101 changes: 101 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Documentation

on:
push:
branches:
- master

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:


# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build-wasm-documentation:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install
uses: pnpm/action-setup@v2
with:
version: 8
run_install: true

- uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Build
run: |
pnpm build
- name: Build package typescript documentation
run: |
mkdir -p docs/ts/docs
mkdir -p docs//ts/app
sed "s% basePath:.*% basePath: '/ITKMorphologicalContourInterpolation/ts/docs',%" wasm/typescript/index.html > docs/ts/docs/index.html
cp wasm/typescript/README.md docs/ts/docs/
mkdir -p docs/ts/docs/test/browser/demo-app
cp wasm/typescript/test/browser/demo-app/logo.svg docs/ts/docs/test/browser/demo-app/
pushd wasm/typescript
rm -rf demo-app node_modules/.vite
export VITE_BASE_URL="/ITKMorphologicalContourInterpolation/ts/app/"
pnpm build
popd
rsync -a wasm/typescript/demo-app/ docs/ts/app/
- name: Build package python documentation
run: |
mkdir -p docs/py/docs
mkdir -p docs/py/app
export SPHINX_BASE_URL="/ITKMorphologicalContourInterpolation/py/docs/"
pushd wasm/python/itkwasm-morphological-contour-interpolation/docs
pip install -r requirements.txt
make html
popd
rsync -a wasm/python/itkwasm-morphological-contour-interpolation/docs/_build/html/ docs/py/docs/
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs
retention-days: 7

deploy-gh-pages:
needs: build-wasm-documentation
runs-on: ubuntu-22.04

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
contents: read
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# with:
# preview: true <-> currently not available to the public
36 changes: 36 additions & 0 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: WebAssembly

on: [push,pull_request]

jobs:
build-wasm:
name: "Build WebAssembly"
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install
uses: pnpm/action-setup@v2
with:
version: 8
run_install: true

- uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Build
run: |
pnpm build
- name: Test
run: |
pnpm test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@
*.exe
*.out
*.app

# wasm build
node_modules/
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,34 @@ if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()

if(CMAKE_CXX_STANDARD EQUAL "11" )
message(FATAL_ERROR "CMAKE_CXX_STANDARD:STRING=11 is not supported in ITK version 5.3 and greater.")
endif()

if(NOT CMAKE_CXX_STANDARD)
if (WASI OR EMSCRIPTEN)
set(CMAKE_CXX_STANDARD 20) # Supported values are ``14``, ``17``, and ``20``.
else()
set(CMAKE_CXX_STANDARD 17) # Supported values are ``14``, ``17``, and ``20``.
endif()
endif()
if(NOT CMAKE_CXX_STANDARD_REQUIRED)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
if(NOT CMAKE_CXX_EXTENSIONS)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()

project(MorphologicalContourInterpolation)

if(NOT ITK_SOURCE_DIR)
find_package(ITK REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${ITK_CMAKE_DIR})
include(ITKModuleExternal)
if(WASI OR EMSCRIPTEN)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory(wasm)
endif()
else()
set(ITK_DIR ${CMAKE_BINARY_DIR})
itk_module_impl()
Expand Down
77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# ITKMorphologicalContourInterpolation

![Build, test, package](https://github.com/KitwareMedical/ITKMorphologicalContourInterpolation/workflows/Build,%20test,%20package/badge.svg)

[![PyPI](https://img.shields.io/pypi/v/itk-morphologicalcontourinterpolation.svg)](https://pypi.python.org/pypi/itk-morphologicalcontourinterpolation)

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/KitwareMedical/ITKMorphologicalContourInterpolation/blob/master/LICENSE)

## Overview

An [ITK](https://itk.org)-based implementation of morphological contour interpolation based off the paper:

Albu AB1, Beugeling T, Laurendeau D.
"A morphology-based approach for interslice interpolation of anatomical slices from volumetric images."
IEEE Trans Biomed Eng.
2008 Aug;55(8):2022-38.
doi: 10.1109/TBME.2008.921158.

👨‍💻 [`Live API Demo`]

Documentation can be found in the [Insight Journal article](https://www.insight-journal.org/browse/publication/977):

Zukić D., Vicory J., McCormick M., Wisse L., Gerig G., Yushkevich P., Aylward S.
"ND Morphological Contour Interpolation",
The Insight Journal. January-December, 2016.
https://hdl.handle.net/10380/3563
https://insight-journal.org/browse/publication/977

- 🕮 [`Wasm Python Documentation`] 📚
- 🕮 [`JavaScript Documentation`] 📚

## Installation

### Python

To install the wasm Python packages:

```sh
pip install itkwasm-morphological-contour-interpolation
```

To install the native Python packages:

```sh
python -m pip install --upgrade pip
python -m pip install itk-morphologicalcontourinterpolation
```

### JavaScript

Install the JavaScript/TypeScript package:

```sh
npm install @itk-wasm/morphological-contour-interpolation
```

### C++

Since ITK 4.11.0, this module is available in the ITK source tree as a remote module. To enable it, set:

```
Module_MorphologicalContourInterpolation:BOOL=ON
```

in ITK's CMake build configuration.

## License

This software is distributed under the Apache 2.0 license. Please see the *LICENSE* file for details.

## Acknowledgements

This work is supported by NIH grant R01 EB014346, "Continued development and maintenance of the ITK-SNAP 3D image segmentation software."

[`Live API Demo`]: https://kitwaremedical.github.io/ITKMorphologicalContourInterpolation/ts/app/
[`Wasm Python Documentation`]: https://kitwaremedical.github.io/ITKMorphologicalContourInterpolation/py/docs/
[`JavaScript Documentation`]: https://kitwaremedical.github.io/ITKMorphologicalContourInterpolation/ts/docs/
10 changes: 10 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: morphological-contour-interpolation
channels:
- conda-forge
dependencies:
- pytest
- python=3.11
- pip
- pip:
- hatch
- itkwasm-image-io
4 changes: 4 additions & 0 deletions include/itkMorphologicalContourInterpolator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -713,13 +713,17 @@ MorphologicalContourInterpolator< TImage >::Interpolate1to1( int axis, TImage* o
}
}

#if !defined( __wasi__ ) && !defined( __EMSCRIPTEN__ )
static std::mutex mutexLock;
#endif
if ( withinReq ) // else we should not write it
{
seqIt.GoToBegin();
// writing through one RLEImage iterator invalidates all the others
// so this whole writing loop needs to be serialized
#if !defined( __wasi__ ) && !defined( __EMSCRIPTEN__ )
std::lock_guard< std::mutex > mutexHolder( mutexLock );
#endif
ImageRegionIterator< TImage > outIt( out, outRegion );
while ( !outIt.IsAtEnd() )
{
Expand Down
45 changes: 45 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@itk-wasm/morphological-contour-interpolation-build",
"version": "1.0.0",
"description": "npm scripts to generate itk-wasm artifacts.",
"private": true,
"type": "module",
"itk-wasm": {
"typescript-package-name": "@itk-wasm/morphological-contour-interpolation",
"typescript-output-dir": "wasm/typescript",
"python-package-name": "itkwasm-morphological-contour-interpolation",
"python-output-dir": "wasm/python",
"package-description": "Morphology-based approach for interslice interpolation of anatomical slices from volumetric images.",
"repository": "https://github.com/KitwareMedical/ITKMorphologicalContourInterpolation"
},
"scripts": {
"build": "pnpm build:gen:typescript && pnpm -r build && pnpm build:gen:python",
"build:emscripten": "itk-wasm pnpm-script build:emscripten",
"build:emscripten:debug": "itk-wasm pnpm-script build:emscripten:debug",
"build:wasi": "itk-wasm pnpm-script build:wasi",
"build:wasi:debug": "itk-wasm pnpm-script build:wasi:debug",
"build:python:wasi": "itk-wasm pnpm-script build:python:wasi",
"bindgen:typescript": "itk-wasm pnpm-script bindgen:typescript",
"bindgen:python": "itk-wasm pnpm-script bindgen:python",
"build:gen:typescript": "itk-wasm pnpm-script build:gen:typescript",
"build:gen:python": "itk-wasm pnpm-script build:gen:python",
"build:micromamba": "itk-wasm pnpm-script build:micromamba",
"build:python:versionSync": "itk-wasm pnpm-script build:python:versionSync",
"publish:python": "itk-wasm pnpm-script publish:python",
"test": "pnpm test:data:download && pnpm -r test && pnpm test:python",
"test:data:download": "echo \"not needed\"",
"test:data:pack": "dam pack test/data test/data.tar.gz",
"test:python:wasi": "itk-wasm pnpm-script test:python:wasi",
"test:python:emscripten": "itk-wasm pnpm-script test:python:emscripten",
"test:python:dispatch": "itk-wasm pnpm-script test:python:dispatch",
"test:python": "itk-wasm pnpm-script test:python",
"test:wasi": "itk-wasm pnpm-script test:wasi -- -V",
"clean": "git clean -fdx -e node_modules"
},
"license": "Apache-2.0",
"devDependencies": {
"@itk-wasm/dam": "^1.1.0",
"@thewtex/setup-micromamba": "^1.9.7",
"itk-wasm": "^1.0.0-b.166"
}
}
Loading

0 comments on commit 77aa1f7

Please sign in to comment.