diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 5f479a7..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,86 +0,0 @@ -version: 2 -jobs: - build-and-test: - working_directory: /ITKModuleTemplate-build - docker: - - image: insighttoolkit/module-ci:latest - steps: - - checkout: - path: /ITKModuleTemplateCookieCutter - - run: - name: Fetch CTest driver script - command: | - curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/dashboard/itk_common.cmake -O - - run: - name: Evaluate template - command: | - python -m pip install cookiecutter - cd / - python -m cookiecutter --no-input /ITKModuleTemplateCookieCutter - - run: - name: Configure CTest script - command: | - SHASNIP=$(echo $CIRCLE_SHA1 | cut -c1-7) - - # Only for testing the template - mkdir -p /ITKModuleTemplate/.git - - cat > dashboard.cmake << EOF - set(CTEST_SITE "CircleCI") - set(CTEST_BUILD_NAME "External-ITKModuleTemplate-${CIRCLE_BRANCH}-${CIRCLE_BUILD_NUM}-${SHASNIP}") - set(CTEST_BUILD_CONFIGURATION "MinSizeRel") - set(CTEST_CMAKE_GENERATOR "Unix Makefiles") - set(CTEST_BUILD_FLAGS: "-j5") - set(CTEST_SOURCE_DIRECTORY /ITKModuleTemplate) - set(CTEST_BINARY_DIRECTORY /ITKModuleTemplate-build) - set(dashboard_model Experimental) - set(dashboard_no_clean 1) - - # Only for testing the template - set(dashboard_no_update 1) - - set(dashboard_cache " - ITK_DIR:PATH=/ITK-build - BUILD_TESTING:BOOL=ON - ") - include(\${CTEST_SCRIPT_DIRECTORY}/itk_common.cmake) - EOF - - run: - name: Build and Test - no_output_timeout: 1.0h - command: | - ctest -j 2 -VV -S dashboard.cmake - package: - working_directory: ~/ - machine: true - steps: - - checkout: - path: ~/ITKModuleTemplateCookieCutter - - run: - name: Evaluate template - command: | - python -m pip install cookiecutter - cd ~/ - python -m cookiecutter --no-input ~/ITKModuleTemplateCookieCutter - - run: - name: Fetch build script - command: | - cd ~/ITKModuleTemplate - curl -L https://rawgit.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/dockcross-manylinux-download-cache-and-build-module-wheels.sh -O - chmod u+x dockcross-manylinux-download-cache-and-build-module-wheels.sh - - run: - name: Build Python packages - no_output_timeout: 1.0h - command: | - cd ~/ITKModuleTemplate - ./dockcross-manylinux-download-cache-and-build-module-wheels.sh - - store_artifacts: - path: dist - destination: dist - -workflows: - version: 2 - build-test-package: - jobs: - - build-and-test - - package diff --git a/.github/workflows/build-test-package.yml b/.github/workflows/build-test-package.yml new file mode 100644 index 0000000..4d794ca --- /dev/null +++ b/.github/workflows/build-test-package.yml @@ -0,0 +1,357 @@ +name: Build, test, package + +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + # v6.0a02 + itk-git-tag: "v6.0a02" + itk-wheel-tag: "v6.0a02" + # v6.0a02 + fixes + itk-python-package-tag: "v6.0a02" + itk-python-package-org: "InsightSoftwareConsortium" + +jobs: + build-test-cxx: + runs-on: ${{ matrix.os }} + strategy: + max-parallel: 3 + matrix: + # runners macos-13 is x86_64, macos-15 is arm64 by default + os: [ubuntu-24.04, windows-2022, macos-13, macos-15] + include: + - os: ubuntu-24.04 + c-compiler: "gcc" + cxx-compiler: "g++" + cmake-build-type: "MinSizeRel" + - os: windows-2022 + c-compiler: "cl.exe" + cxx-compiler: "cl.exe" + cmake-build-type: "Release" + - os: macos-13 + c-compiler: "clang" + cxx-compiler: "clang++" + cmake-build-type: "MinSizeRel" + deployment_target: '10.9' + - os: macos-15 + c-compiler: "clang" + cxx-compiler: "clang++" + cmake-build-type: "MinSizeRel" + deployment_target: '13.0' + + steps: + - uses: actions/checkout@v4.2.2 + + - name: Free Disk Space (Ubuntu) + if: matrix.os == 'ubuntu-24.04' + uses: jlumbroso/free-disk-space@v1.3.1 + with: + large-packages: false + + - name: Set up Python 3.11 + uses: actions/setup-python@v5.4.0 + with: + python-version: "3.11" + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + python -m pip install ninja + python -m pip install cookiecutter + + - name: Get specific version of CMake, Ninja + uses: lukka/get-cmake@v3.31.5 + + - name: 'Specific XCode version 14.3.1' + if: matrix.os == 'macos-13' + run: | + sudo xcode-select -s "/Applications/Xcode_14.3.1.app" + + - name: 'Specific XCode version 16.2' + if: matrix.os == 'macos-15' + run: | + sudo xcode-select -s "/Applications/Xcode_16.2.app" + + - name: Download ITK + run: | + cd .. + git clone https://github.com/InsightSoftwareConsortium/ITK.git + cd ITK + git checkout ${{ env.itk-git-tag }} + + - name: Build ITK + if: matrix.os != 'windows-2022' + shell: bash + run: | + cd .. + mkdir ITK-build + cd ITK-build + cmake -DCMAKE_C_COMPILER:FILEPATH="${{ matrix.c-compiler }}" -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_CXX_COMPILER="${{ matrix.cxx-compiler }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.cmake-build-type }} -DBUILD_TESTING:BOOL=OFF -GNinja ../ITK + ninja + + - name: Build ITK + if: matrix.os == 'windows-2022' + shell: pwsh + run: | + Set-PSDebug -Trace 1 + cd .. + mkdir ITK-build + cd ITK-build + & "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -SkipAutomaticLocation + cmake -DCMAKE_C_COMPILER:FILEPATH="${{ matrix.c-compiler }}" -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_CXX_COMPILER="${{ matrix.cxx-compiler }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.cmake-build-type }} -DBUILD_TESTING:BOOL=OFF -GNinja ../ITK + ninja + + - name: Fetch CTest driver script + run: | + curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/dashboard/itk_common.cmake -O + + - name: Evaluate template + shell: bash + run: | + python -m cookiecutter --no-input --output-dir "${GITHUB_WORKSPACE}/../Evaluated" "${GITHUB_WORKSPACE}" + mkdir "${GITHUB_WORKSPACE}/../Evaluated/ITKModuleTemplate/.git" + + - name: Configure CTest script + shell: bash + run: | + operating_system="${{ matrix.os }}" + cat > dashboard.cmake << EOF + set(CTEST_SITE "GitHubActions") + file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/.." CTEST_DASHBOARD_ROOT) + file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/../Evaluated/ITKModuleTemplate" CTEST_SOURCE_DIRECTORY) + file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/../build" CTEST_BINARY_DIRECTORY) + set(dashboard_source_name "${GITHUB_REPOSITORY}") + if(ENV{GITHUB_REF} MATCHES "main") + set(branch "-main") + set(dashboard_model "Continuous") + else() + set(branch "-${GITHUB_REF}") + set(dashboard_model "Experimental") + endif() + set(CTEST_BUILD_NAME "${GITHUB_REPOSITORY}-${operating_system}-\${branch}") + set(CTEST_UPDATE_VERSION_ONLY 1) + set(CTEST_TEST_ARGS \${CTEST_TEST_ARGS} PARALLEL_LEVEL \${PARALLEL_LEVEL}) + set(CTEST_BUILD_CONFIGURATION "Release") + set(CTEST_CMAKE_GENERATOR "Ninja") + set(CTEST_CUSTOM_WARNING_EXCEPTION + \${CTEST_CUSTOM_WARNING_EXCEPTION} + # macOS Azure VM Warning + "ld: warning: text-based stub file" + ) + set(dashboard_no_clean 1) + set(ENV{CC} ${{ matrix.c-compiler }}) + set(ENV{CXX} ${{ matrix.cxx-compiler }}) + if(WIN32) + set(ENV{PATH} "\${CTEST_DASHBOARD_ROOT}/ITK-build/bin;\$ENV{PATH}") + endif() + set(dashboard_cache " + ITK_DIR:PATH=\${CTEST_DASHBOARD_ROOT}/ITK-build + BUILD_TESTING:BOOL=ON + ") + string(TIMESTAMP build_date "%Y-%m-%d") + message("CDash Build Identifier: \${build_date} \${CTEST_BUILD_NAME}") + message("CTEST_SITE = \${CTEST_SITE}") + include(\${CTEST_SCRIPT_DIRECTORY}/itk_common.cmake) + EOF + cat dashboard.cmake + + - name: Build and test + if: matrix.os != 'windows-2022' + run: | + ctest --output-on-failure -j 2 -V -S dashboard.cmake + + - name: Build and test + if: matrix.os == 'windows-2022' + shell: pwsh + run: | + & "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -SkipAutomaticLocation + ctest --output-on-failure -j 2 -V -S dashboard.cmake + + build-linux-python-packages: + runs-on: ubuntu-24.04 + strategy: + max-parallel: 2 + matrix: + python-version: ["39", "310", "311","312","313"] + + steps: + - uses: actions/checkout@v4.2.2 + + - name: 'Free up disk space' + run: | + # Workaround for https://github.com/actions/virtual-environments/issues/709 + df -h + sudo apt-get clean + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + df -h + + - name: 'Fetch build dependencies' + shell: bash + run: | + sudo apt install zstd + unzstd --version + + - name: Set up Python 3.11 + uses: actions/setup-python@v5.4.0 + with: + python-version: "3.11" + + - name: Get specific version of CMake, Ninja + uses: lukka/get-cmake@v3.31.5 + + - name: Evaluate template + shell: bash + run: | + python -m pip install cookiecutter + python -m cookiecutter --no-input --output-dir "${GITHUB_WORKSPACE}/Evaluated" "${GITHUB_WORKSPACE}" + mkdir "${GITHUB_WORKSPACE}/Evaluated/ITKModuleTemplate/.git" + + - name: 'Fetch build script' + run: | + curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITKPythonPackage/${{ env.itk-python-package-tag }}/scripts/dockcross-manylinux-download-cache-and-build-module-wheels.sh -O + chmod u+x dockcross-manylinux-download-cache-and-build-module-wheels.sh + + - name: 'Build 🐍 Python 📦 package' + run: | + cd "${GITHUB_WORKSPACE}/Evaluated/ITKModuleTemplate" + export ITK_PACKAGE_VERSION=${{ env.itk-wheel-tag }} + export ITKPYTHONPACKAGE_TAG=${{ env.itk-python-package-tag }} + for manylinux_version in "_2_28" "2014"; do + rm -rf ITKPythonPackage + export MANYLINUX_VERSION=${manylinux_version} + echo "Building for manylinux specialization ${MANYLINUX_VERSION}" + ../../dockcross-manylinux-download-cache-and-build-module-wheels.sh cp${{ matrix.python-version }} + done + + - name: Publish Python package as GitHub Artifact + uses: actions/upload-artifact@v4.6.0 + with: + name: LinuxWheel3${{ matrix.python-version }} + path: Evaluated/ITKModuleTemplate/dist + + build-macos-python-packages: + runs-on: macos-13 + strategy: + max-parallel: 2 + matrix: + python3-minor-version: ["9", "10", "11", "12", "13"] + + steps: + - uses: actions/checkout@v4.2.2 + + - name: 'Specific XCode version' + run: | + sudo xcode-select -s "/Applications/Xcode_14.3.1.app" + + - name: Get specific version of CMake, Ninja + uses: lukka/get-cmake@v3.31.5 + + - name: 'Fetch build script' + run: | + curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITKPythonPackage/${{ env.itk-python-package-tag }}/scripts/macpython-download-cache-and-build-module-wheels.sh -O + chmod u+x macpython-download-cache-and-build-module-wheels.sh + + - name: Set up Python 3.11 + uses: actions/setup-python@v5.4.0 + with: + python-version: "3.11" + + - name: Evaluate template + shell: bash + run: | + python -m pip install cookiecutter + python -m cookiecutter --no-input --output-dir "${GITHUB_WORKSPACE}/Evaluated" "${GITHUB_WORKSPACE}" + mkdir "${GITHUB_WORKSPACE}/Evaluated/ITKModuleTemplate/.git" + + - name: 'Build 🐍 Python 📦 package' + run: | + cd "${GITHUB_WORKSPACE}/Evaluated/ITKModuleTemplate" + export ITK_PACKAGE_VERSION=${{ env.itk-wheel-tag }} + export ITKPYTHONPACKAGE_TAG=${{ env.itk-python-package-tag }} + export ITKPYTHONPACKAGE_ORG=${{ env.itk-python-package-org }} + # For Xcode 16.2, the recommended "MACOSX_DEPLOYMENT_TARGET" is "13.0"; this means your application should be built to run on macOS Ventura (version 13.0) or later. + export MACOSX_DEPLOYMENT_TARGET=${{ matrix.deployment_target || '13.0' }} + ../../macpython-download-cache-and-build-module-wheels.sh "3.${{ matrix.python3-minor-version }}" + + - name: Publish Python package as GitHub Artifact + uses: actions/upload-artifact@v4.6.0 + with: + name: MacOSWheel3${{ matrix.python3-minor-version }} + path: Evaluated/ITKModuleTemplate/dist + + build-windows-python-packages: + runs-on: windows-2022 + strategy: + max-parallel: 2 + matrix: + python-version-minor: ["9", "10", "11"] + + steps: + - uses: actions/checkout@v4.2.2 + + - name: 'Install Python' + run: | + $pythonArch = "64" + $pythonVersion = "3.${{ matrix.python-version-minor }}" + iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/scikit-build/scikit-ci-addons/master/windows/install-python.ps1')) + + - uses: actions/setup-python@v5.4.0 + with: + python-version: '3.x' + + - name: Get specific version of CMake, Ninja + uses: lukka/get-cmake@v3.31.5 + + - name: Set up Python 3.11/ + uses: actions/setup-python@v5.4.0 + with: + python-version: "3.11" + + - name: Evaluate template + shell: bash + run: | + python -m pip install cookiecutter + python -m cookiecutter --no-input --output-dir "${GITHUB_WORKSPACE}/Evaluated" "${GITHUB_WORKSPACE}" + mkdir "${GITHUB_WORKSPACE}/Evaluated/ITKModuleTemplate/.git" + + - name: 'Fetch build dependencies' + shell: bash + run: | + cd Evaluated/ITKModuleTemplate + curl -L "https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/download/${{ env.itk-wheel-tag }}/ITKPythonBuilds-windows.zip" -o "ITKPythonBuilds-windows.zip" + 7z x ITKPythonBuilds-windows.zip -o/c/P -aoa -r + curl -L "https://data.kitware.com/api/v1/file/5c0ad59d8d777f2179dd3e9c/download" -o "doxygen-1.8.11.windows.bin.zip" + 7z x doxygen-1.8.11.windows.bin.zip -o/c/P/doxygen -aoa -r + curl -L "https://data.kitware.com/api/v1/file/5bbf87ba8d777f06b91f27d6/download/grep-win.zip" -o "grep-win.zip" + 7z x grep-win.zip -o/c/P/grep -aoa -r + + # Update step for skbuild issue in v5.3.0 build archive + echo "Updating ITKPythonPackage build scripts to ${{ env.itk-python-package-tag }}" + pushd /c/P/IPP + git remote add InsightSoftwareConsortium https://github.com/InsightSoftwareConsortium/ITKPythonPackage.git --tags + git fetch InsightSoftwareConsortium + git checkout ${{ env.itk-python-package-tag }} + git status + popd + + - name: 'Build 🐍 Python 📦 package' + shell: cmd + run: | + cd Evaluated/ITKModuleTemplate + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + set PATH=C:\P\grep;%PATH% + set CC=cl.exe + set CXX=cl.exe + C:\Python3${{ matrix.python-version-minor }}-x64\python.exe C:\P\IPP\scripts\windows_build_module_wheels.py --py-envs "3${{ matrix.python-version-minor }}-x64" + + - name: Publish Python package as GitHub Artifact + uses: actions/upload-artifact@v4.6.0 + with: + name: WindowsWheel3.${{ matrix.python-version-minor }} + path: Evaluated/ITKModuleTemplate/dist diff --git a/.github/workflows/clang-format-linter.yml b/.github/workflows/clang-format-linter.yml new file mode 100644 index 0000000..65169b0 --- /dev/null +++ b/.github/workflows/clang-format-linter.yml @@ -0,0 +1,12 @@ +name: clang-format linter + +on: [push,pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + + - uses: InsightSoftwareConsortium/ITKClangFormatLinterAction@main diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7cdbdf6..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -sudo: true -language: cpp -os: -- osx -compiler: -- gcc -cache: - directories: - - "$HOME/Library/Caches/Homebrew" -script: -- python -m pip install cookiecutter -- cookiecutter --no-input . -- cd ITKModuleTemplate -- curl -L https://rawgit.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/macpython-download-cache-and-build-module-wheels.sh -O -- chmod u+x macpython-download-cache-and-build-module-wheels.sh -- ./macpython-download-cache-and-build-module-wheels.sh -- tar -zcvf dist.tar.gz dist/ -- curl -F file="@dist.tar.gz" https://filebin.ca/upload.php diff --git a/LICENSE b/LICENSE index d645695..62589ed 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ Apache License Version 2.0, January 2004 - http://www.apache.org/licenses/ + https://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION @@ -193,7 +193,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/README.md b/README.md new file mode 100644 index 0000000..9113dd7 --- /dev/null +++ b/README.md @@ -0,0 +1,149 @@ +ITKModuleTemplate +================= + +[![][gha-img]][gha-link] + +[gha-img]: https://github.com/InsightSoftwareConsortium/ITKModuleTemplate/actions/workflows/build-test-package.yml/badge.svg +[gha-link]: https://github.com/InsightSoftwareConsortium/ITKModuleTemplate/actions/workflows/build-test-package.yml + + +Overview +-------- + +This is a module for the [Insight Toolkit (ITK)](https://itk.org) for +segmentation and registration. It is designed to work with the ITK +modular system. + +This module is a template to be used as a starting point for a new ITK +module. + +Getting Started +--------------- + +The following will get an external module started in a new repository: + + python -m pip install cookiecutter + python -m cookiecutter gh:InsightSoftwareConsortium/ITKModuleTemplate + # Fill in the information requested at the prompts + +Reasonable defaults will be provided for all of the parameters. The +parameters are: + +
+
full_name
+
Your full name.
+ +
email
+
Your email.
+ +
project_name
+
This is a name for the project, which is ITK followed by the module +name, by convention. Examples include ITKIsotropicWavelets or +ITKBoneMorphometry.
+ +
module_name
+
This is the name of the module. Since this is an external module, it +does not start with the ITK prefix. It is in CamelCase, by convention. +Examples include IsotropicWavelets and BoneMorphometry.
+ +
filter_name
+
The skeleton of an itk::ImageToImageFilter will be created by default. +Optionally specify this value, if you will be adding an +itk::ImageToImageFilter to your module. + +
python_package_name
+
This is the name of the Python package that will be created from the +module. By convention, this is itk- +For example, itk-isotropicwavelets or itk-bonemorphometry.
+ +
download_url
+
This is the download url added to the Python package metadata. This can +be the GitHub repository URL.
+ +
project_short_description
+
A short description to use in the project README, module Doxygen +documentation, and Python package documentation.
+ +
project_long_description
+
A long description to use in the project README, module Doxygen +documentation, and Python package documentation.
+
+ +The output of the cookiecutter is a buildable ITK external module with +example classes. Remove or replace the classes with your new classes. +Push your new module to GitHub. Cross-platform C++ testing and Python +packaging is provided via the [ITKRemoteModuleBuildTestPackageAction] +reusable GitHub Action. + +Documentation on [how to populate the +module](https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide-Book1ch9.html#x50-1430009) +can be found in the [ITK Software +Guide](https://itk.org/ITKSoftwareGuide/html/). + +To improve the discoverability of your module on GitHub, first push the +associated repository, then add +[itk-module](https://github.com/topics/itk-module) to the project's +[GitHub Topics](https://help.github.com/articles/about-topics/) . + +Remote Module +------------- + +After an [Insight Journal](https://www.insight-journal.org/) article has +been submitted, the module can be included in ITK as a [remote +module](https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide-Book1ch9.html#x55-1640009.7). +Add a file in "ITK/Modules/Remote" called "YourModule.remote.cmake", for +this module it would be "ExternalExample.remote.cmake" with the +followlowing contents: + + itk_fetch_module(MyModule + "A description of the a module." + GIT_REPOSITORY https://github.com/myuser/ITKMyModule.git + GIT_TAG abcdef012345 + ) + +CI Testing and Python Packages +------------------------------ + +Continuous integration service configurations are included to build +and test the C++ core of packages across platforms and build binary +Python packages for Linux, macOS, and Windows. For more information, see +the [ITKRemoteModuleBuildTestPackageAction] documentation. + +pyproject.toml migration +------------------------ + +ITK 5.4 added support for [scikit-build-core](https://scikit-build-core.readthedocs.io/en/latest/), +an update to scikit-build classic that supports [PEP +517](https://peps.python.org/pep-0517/) and other modern Python packaging +standards configured in the declarative *pyproject.toml* file. While the +*setup.py* file is still supported in ITK 5.4, migration to *pyproject.toml* +is encouraged. One important advantage is the generation of Stable ABI wheels +for Python 3.11+; these packages work with Python 3.11, 3.12, +3.13, 3.14, etc. To migrate to scikit-build-core, use the pyproject.toml +template in this repository and remove the *setup.py* file. + +ITKv4 Branch +------------ + +In the transition to the major release of ITKv5 your module might want +to be compatible with both versions: ITKv4 and ITKv5. In order to do +that, keep the master branch for development with ITKv5, and create +another branch, named `ITKv4`, or `release`, that is compatible with the +version 4.13 of ITK. For examples and updated information on how to do +this: please [check the discourse +conversation](https://discourse.itk.org/t/itk-external-module-github-builds-for-4-x-and-5-x/900). + +License +------- + +This software is distributed under the Apache 2.0 license. Please see +the *LICENSE* file for details. + +Authors +------- + +- Bradley Lowekamp +- Matt McCormick +- Jean-Baptiste VIMORT + +[ITKRemoteModuleBuildTestPackageAction]: https://github.com/InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction diff --git a/README.rst b/README.rst deleted file mode 100644 index caecc2b..0000000 --- a/README.rst +++ /dev/null @@ -1,76 +0,0 @@ -ITKModuleTemplate -================= - - -.. image:: https://circleci.com/gh/InsightSoftwareConsortium/ITKModuleTemplate.svg?style=shield - :target: https://circleci.com/gh/InsightSoftwareConsortium/ITKModuleTemplate - -.. image:: https://travis-ci.org/InsightSoftwareConsortium/ITKModuleTemplate.svg?branch=master - :target: https://travis-ci.org/InsightSoftwareConsortium/ITKModuleTemplate - -.. image:: https://img.shields.io/appveyor/ci/itkrobot/itkmoduletemplate.svg - :target: https://ci.appveyor.com/project/itkrobot/itkmoduletemplate - -This is a module for the `Insight Toolkit (ITK) `_ for -segmentation and registration. It is designed to work with the ITKv4 modular -system. - -This module is a template to be used as a starting point for a new ITK module. - - -Getting Started ---------------- - -The following will get an external module started in a new repository:: - - python -m pip install cookiecutter - python -m cookiecutter gh:InsightSoftwareConsortium/ITKModuleTemplate - # Fill in the information requested at the prompts - -Documentation on `how to populate the module -`_ -can be found in the `ITK Software Guide -`_. - - - -Remote Module -------------- - -After an `Insight Journal `_ article has been -submitted, the module can be included in ITK as a `remote module -`_. -Add a file in "ITK/Modules/Remote" called "YourModule.remote.cmake", for this -module it would be "ExternalExample.remote.cmake" with the followlowing -contents:: - - itk_fetch_module(MyModule - "A description of the a module." - GIT_REPOSITORY http://github.com/myuser/ITKMyModule.git - GIT_TAG abcdef012345 - ) - - -Python Packages ---------------- - -Continuous integration service configurations are included to build Python -packages for Linux, macOS, and Windows. These packages can be `downloaded -`_ -and `uploaded to the Python Package Index (PyPI) -`_. - - -License -------- - -This software is distributed under the Apache 2.0 license. Please see -the *LICENSE* file for details. - - -Authors -------- - -* Bradley Lowekamp -* Matt McCormick -* Jean-Baptiste VIMORT diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index f06e4cc..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,24 +0,0 @@ -branches: - only: - - master - -version: "0.0.1.{build}" - -install: - - - python -m pip install cookiecutter - - cookiecutter --no-input . - - cd ITKModuleTemplate - - curl -L https://rawgit.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/windows-download-cache-and-build-module-wheels.ps1 -O - - ps: .\windows-download-cache-and-build-module-wheels.ps1 - -build: off - -test: off - -artifacts: - - # pushing entire folder as a zip archive - - path: dist\* - -deploy: off diff --git a/cookiecutter.json b/cookiecutter.json index b16db1a..11ff7e4 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -1,10 +1,11 @@ { "full_name": "Insight Software Consortium", "email": "itk+community@discourse.itk.org", - "github_username": "itkrobot", "project_name": "ITKModuleTemplate", "module_name": "{{ cookiecutter.project_name[3:] }}", + "filter_name": "MyFilter", "python_package_name": "itk-{{ cookiecutter.project_name[3:].lower() }}", + "example_name": "MyFilterApplicationWholePipeline", "download_url": "https://github.com/InsightSoftwareConsortium/{{ cookiecutter.project_name }}", "project_short_description": "This is a template that serves as a starting point for a new module.", "project_long_description": "ITK is an open-source, cross-platform library that provides developers with an extensive suite of software tools for image analysis. Developed through extreme programming methodologies, ITK employs leading-edge algorithms for registering and segmenting multidimensional scientific images." diff --git a/{{cookiecutter.project_name}}/.circleci/config.yml b/{{cookiecutter.project_name}}/.circleci/config.yml deleted file mode 100644 index 1371317..0000000 --- a/{{cookiecutter.project_name}}/.circleci/config.yml +++ /dev/null @@ -1,63 +0,0 @@ -version: 2 -jobs: - build-and-test: - working_directory: /{{ cookiecutter.project_name }}-build - docker: - - image: insighttoolkit/module-ci:latest - steps: - - checkout: - path: /{{ cookiecutter.project_name }} - - run: - name: Fetch CTest driver script - command: | - curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/dashboard/itk_common.cmake -O - - run: - name: Configure CTest script - command: | - SHASNIP=$(echo $CIRCLE_SHA1 | cut -c1-7) - cat > dashboard.cmake << EOF - set(CTEST_SITE "CircleCI") - set(CTEST_BUILD_NAME "External-{{ cookiecutter.project_name }}-${CIRCLE_BRANCH}-${CIRCLE_BUILD_NUM}-${SHASNIP}") - set(CTEST_BUILD_CONFIGURATION "MinSizeRel") - set(CTEST_CMAKE_GENERATOR "Unix Makefiles") - set(CTEST_BUILD_FLAGS: "-j5") - set(CTEST_SOURCE_DIRECTORY /{{ cookiecutter.project_name }}) - set(CTEST_BINARY_DIRECTORY /{{ cookiecutter.project_name }}-build) - set(dashboard_model Experimental) - set(dashboard_no_clean 1) - set(dashboard_cache " - ITK_DIR:PATH=/ITK-build - BUILD_TESTING:BOOL=ON - ") - include(\${CTEST_SCRIPT_DIRECTORY}/itk_common.cmake) - EOF - - run: - name: Build and Test - no_output_timeout: 1.0h - command: | - ctest -j 2 -VV -S dashboard.cmake - package: - working_directory: ~/{{ cookiecutter.project_name }} - machine: true - steps: - - checkout - - run: - name: Fetch build script - command: | - curl -L https://rawgit.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/dockcross-manylinux-download-cache-and-build-module-wheels.sh -O - chmod u+x dockcross-manylinux-download-cache-and-build-module-wheels.sh - - run: - name: Build Python packages - no_output_timeout: 1.0h - command: | - ./dockcross-manylinux-download-cache-and-build-module-wheels.sh - - store_artifacts: - path: dist - destination: dist - -workflows: - version: 2 - build-test-package: - jobs: - - build-and-test - - package diff --git a/{{cookiecutter.project_name}}/.clang-format b/{{cookiecutter.project_name}}/.clang-format new file mode 100644 index 0000000..45b9502 --- /dev/null +++ b/{{cookiecutter.project_name}}/.clang-format @@ -0,0 +1,318 @@ +## This config file is only relevant for clang-format version 19.1.4 +## +## Examples of each format style can be found on the in the clang-format documentation +## See: https://clang.llvm.org/docs/ClangFormatStyleOptions.html for details of each option +## +## The clang-format binaries can be downloaded as part of the clang binary distributions +## from https://releases.llvm.org/download.html +## +## Use the script Utilities/Maintenance/clang-format.bash to faciliate +## maintaining a consistent code style. +## +## EXAMPLE apply code style enforcement before commit: +# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_19.1.4} --modified +## EXAMPLE apply code style enforcement after commit: +# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_19.1.4} --last +--- +# This configuration requires clang-format version 19.1.4 exactly. +Language: Cpp +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseArrows: false + AlignCaseColons: false +AlignConsecutiveTableGenBreakingDAGArgColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenCondOperatorColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenDefinitionColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowBreakBeforeNoexceptSpecifier: Never +AllowShortBlocksOnASingleLine: Never +AllowShortCaseExpressionOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: true +#AllowShortFunctionsOnASingleLine: Inline Only merge functions defined inside a class. Implies empty. +#AllowShortFunctionsOnASingleLine: None (in configuration: None) Never merge functions into a single line. +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AttributeMacros: + - __capability +BinPackArguments: false +BinPackParameters: false +BitFieldColonSpacing: Both +BraceWrapping: + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: Always + AfterEnum: true + AfterExternBlock: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Leave +BreakAfterJavaFieldAnnotations: false +BreakAfterReturnType: All +BreakArrays: true +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Custom +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeComma +BreakFunctionDefinitionParameters: false +BreakInheritanceList: BeforeComma +BreakStringLiterals: true +BreakTemplateDeclarations: Yes +## The following line allows larger lines in non-documentation code +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: true +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: AfterHash +IndentRequiresClause: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: false +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLines: + AtEndOfFile: false + AtStartOfBlock: true + AtStartOfFile: true +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: '' +MacroBlockEnd: '' +MainIncludeChar: Quote +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: false +PackConstructorInitializers: BinPack +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +## The following line allows larger lines in non-documentation code +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakScopeResolution: 500 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Middle +PPIndentWidth: -1 +QualifierAlignment: Custom +QualifierOrder: + - friend + - static + - inline + - constexpr + - const + - type +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false +# We may want to sort the includes as a separate pass +SortIncludes: Never +SortJavaStaticImport: Before +# We may want to revisit this later +SortUsingDeclarations: Never +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + AfterPlacementOperator: true + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInContainerLiterals: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + ExceptDoubleParentheses: false + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION + - ITK_GCC_PRAGMA_PUSH + - ITK_GCC_PRAGMA_POP + - ITK_GCC_SUPPRESS_Wfloat_equal + - ITK_GCC_SUPPRESS_Wformat_nonliteral + - ITK_GCC_SUPPRESS_Warray_bounds + - ITK_CLANG_PRAGMA_PUSH + - ITK_CLANG_PRAGMA_POP + - ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant + - CLANG_PRAGMA_PUSH + - CLANG_PRAGMA_POP + - CLANG_SUPPRESS_Wfloat_equal + - INTEL_PRAGMA_WARN_PUSH + - INTEL_PRAGMA_WARN_POP + - INTEL_SUPPRESS_warning_1292 + - itkTemplateFloatingToIntegerMacro + - itkLegacyMacro +TableGenBreakInsideDAGArg: DontBreak +TabWidth: 2 +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE +... diff --git a/{{cookiecutter.project_name}}/.editorconfig b/{{cookiecutter.project_name}}/.editorconfig new file mode 100644 index 0000000..648b969 --- /dev/null +++ b/{{cookiecutter.project_name}}/.editorconfig @@ -0,0 +1,19 @@ +# https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Apply to all code files +[*] +# A newline ending every file +insert_final_newline = true + +# Set default charset +charset = utf-8 + +# 4 space indentation +indent_style = space +indent_size = 2 + +# Various options +trim_trailing_whitespace = true diff --git a/{{cookiecutter.project_name}}/.github/workflows/build-test-package.yml b/{{cookiecutter.project_name}}/.github/workflows/build-test-package.yml new file mode 100644 index 0000000..1651a0b --- /dev/null +++ b/{{cookiecutter.project_name}}/.github/workflows/build-test-package.yml @@ -0,0 +1,20 @@ +name: Build, test, package + +on: + push: + branches: + - main + tags: + - 'v*' + pull_request: + branches: + - main + +jobs: + cxx-build-workflow: + uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@v5.4.4 + + python-build-workflow: + uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@v5.4.4 + secrets: + pypi_password: ${{ "{{" }} secrets.pypi_password {{ "}}" }} diff --git a/{{cookiecutter.project_name}}/.github/workflows/clang-format-linter.yml b/{{cookiecutter.project_name}}/.github/workflows/clang-format-linter.yml new file mode 100644 index 0000000..65169b0 --- /dev/null +++ b/{{cookiecutter.project_name}}/.github/workflows/clang-format-linter.yml @@ -0,0 +1,12 @@ +name: clang-format linter + +on: [push,pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + + - uses: InsightSoftwareConsortium/ITKClangFormatLinterAction@main diff --git a/{{cookiecutter.project_name}}/.travis.yml b/{{cookiecutter.project_name}}/.travis.yml deleted file mode 100644 index 4289354..0000000 --- a/{{cookiecutter.project_name}}/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -sudo: true -language: cpp -os: -- osx -compiler: -- gcc -cache: - directories: - - "$HOME/Library/Caches/Homebrew" -script: -- curl -L https://rawgit.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/macpython-download-cache-and-build-module-wheels.sh -O -- chmod u+x macpython-download-cache-and-build-module-wheels.sh -- ./macpython-download-cache-and-build-module-wheels.sh -- tar -zcvf dist.tar.gz dist/ -- curl -F file="@dist.tar.gz" https://filebin.ca/upload.php diff --git a/{{cookiecutter.project_name}}/CMakeLists.txt b/{{cookiecutter.project_name}}/CMakeLists.txt index d93d807..c06d3a0 100644 --- a/{{cookiecutter.project_name}}/CMakeLists.txt +++ b/{{cookiecutter.project_name}}/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.22.1...3.29.0 FATAL_ERROR) project({{ cookiecutter.module_name }}) set({{ cookiecutter.module_name }}_LIBRARIES {{ cookiecutter.module_name }}) @@ -8,5 +8,8 @@ if(NOT ITK_SOURCE_DIR) list(APPEND CMAKE_MODULE_PATH ${ITK_CMAKE_DIR}) include(ITKModuleExternal) else() + set(ITK_DIR ${CMAKE_BINARY_DIR}) itk_module_impl() endif() + +itk_module_examples() diff --git a/{{cookiecutter.project_name}}/CTestConfig.cmake b/{{cookiecutter.project_name}}/CTestConfig.cmake index 62f68ac..efccad4 100644 --- a/{{cookiecutter.project_name}}/CTestConfig.cmake +++ b/{{cookiecutter.project_name}}/CTestConfig.cmake @@ -1,7 +1,7 @@ set(CTEST_PROJECT_NAME "ITK") set(CTEST_NIGHTLY_START_TIME "1:00:00 UTC") -set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_METHOD "https") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=Insight") set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/{{cookiecutter.project_name}}/LICENSE b/{{cookiecutter.project_name}}/LICENSE index d645695..62589ed 100644 --- a/{{cookiecutter.project_name}}/LICENSE +++ b/{{cookiecutter.project_name}}/LICENSE @@ -1,7 +1,7 @@ Apache License Version 2.0, January 2004 - http://www.apache.org/licenses/ + https://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION @@ -193,7 +193,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/{{cookiecutter.project_name}}/README.md b/{{cookiecutter.project_name}}/README.md new file mode 100644 index 0000000..b365823 --- /dev/null +++ b/{{cookiecutter.project_name}}/README.md @@ -0,0 +1,13 @@ +# {{ cookiecutter.project_name }} + +[![Build Status]({{ cookiecutter.download_url }}/actions/workflows/build-test-package.yml/badge.svg)]({{ cookiecutter.download_url }}/actions/workflows/build-test-package.yml) + +[![PyPI Version](https://img.shields.io/pypi/v/{{ cookiecutter.python_package_name }}.svg)](https://pypi.python.org/pypi/{{ cookiecutter.python_package_name }}) + +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)]({{ cookiecutter.download_url }}/blob/main/LICENSE) + +## Overview + +{{ cookiecutter.project_short_description }} + +{{ cookiecutter.project_long_description }} diff --git a/{{cookiecutter.project_name}}/README.rst b/{{cookiecutter.project_name}}/README.rst deleted file mode 100644 index 345a3d3..0000000 --- a/{{cookiecutter.project_name}}/README.rst +++ /dev/null @@ -1,15 +0,0 @@ -{{ cookiecutter.project_name }} -================================= - -.. image:: https://circleci.com/gh/InsightSoftwareConsortium/{{ cookiecutter.project_name }}.svg?style=shield - :target: https://circleci.com/gh/InsightSoftwareConsortium/{{ cookiecutter.project_name }} - -.. image:: https://travis-ci.org/InsightSoftwareConsortium/{{ cookiecutter.project_name }}.svg?branch=master - :target: https://travis-ci.org/InsightSoftwareConsortium/{{ cookiecutter.project_name }} - -.. image:: https://img.shields.io/appveyor/ci/{{ cookiecutter.github_username }}/{{ cookiecutter.project_name.lower() }}.svg - :target: https://ci.appveyor.com/project/{{ cookiecutter.github_username }}/{{ cookiecutter.project_name.lower() }} - -{{ cookiecutter.project_short_description }} - -{{ cookiecutter.project_long_description }} diff --git a/{{cookiecutter.project_name}}/appveyor.yml b/{{cookiecutter.project_name}}/appveyor.yml deleted file mode 100644 index fa24b5d..0000000 --- a/{{cookiecutter.project_name}}/appveyor.yml +++ /dev/null @@ -1,21 +0,0 @@ -branches: - only: - - master - -version: "0.0.1.{build}" - -install: - - - curl -L https://rawgit.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/windows-download-cache-and-build-module-wheels.ps1 -O - - ps: .\windows-download-cache-and-build-module-wheels.ps1 - -build: off - -test: off - -artifacts: - - # pushing entire folder as a zip archive - - path: dist\* - -deploy: off diff --git a/{{cookiecutter.project_name}}/examples/CMakeLists.txt b/{{cookiecutter.project_name}}/examples/CMakeLists.txt new file mode 100644 index 0000000..eb5c2c3 --- /dev/null +++ b/{{cookiecutter.project_name}}/examples/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.22.1...3.29.0 FATAL_ERROR) +project({{ cookiecutter.module_name }}Examples) + +set(ExampleSpecificComponents + {{ cookiecutter.module_name }} + ) + +if(NOT ITK_SOURCE_DIR) + find_package(ITK REQUIRED COMPONENTS ITKImageIO ITKTransformIO ${ExampleSpecificComponents}) +else() + # When being built as part of ITK, ITKImageIO and ITKTransformIO + # lists of modules are not yet ready, causing a configure error + find_package(ITK REQUIRED COMPONENTS ${ExampleSpecificComponents}) +endif() +include(${ITK_USE_FILE}) + +add_executable({{ cookiecutter.example_name }} {{ cookiecutter.example_name }}.cxx ) +target_link_libraries({{ cookiecutter.example_name }} ${ITK_LIBRARIES}) diff --git a/{{cookiecutter.project_name}}/examples/{{ cookiecutter.example_name }}.cxx b/{{cookiecutter.project_name}}/examples/{{ cookiecutter.example_name }}.cxx new file mode 100644 index 0000000..5341795 --- /dev/null +++ b/{{cookiecutter.project_name}}/examples/{{ cookiecutter.example_name }}.cxx @@ -0,0 +1,45 @@ +/*========================================================================= + * + * Copyright NumFOCUS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ + +#include "itk{{cookiecutter.filter_name}}.h" + +#include "itkCommand.h" +#include "itkImageFileReader.h" +#include "itkImageFileWriter.h" + + +int main( int argc, char * argv[] ) +{ + if( argc < 4 ) + { + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << argv[0] + << " inputImage" + << " outputImage" + << " parameters" << std::endl; + return EXIT_FAILURE; + } + + + // Please, write a complete, self-containted and useful example that + // demonstrate a class when being used along with other ITK classes or in + // the context of a wider or specific application. + + + return EXIT_SUCCESS; +} diff --git a/{{cookiecutter.project_name}}/examples/{{ cookiecutter.example_name }}.py b/{{cookiecutter.project_name}}/examples/{{ cookiecutter.example_name }}.py new file mode 100644 index 0000000..0185a0e --- /dev/null +++ b/{{cookiecutter.project_name}}/examples/{{ cookiecutter.example_name }}.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +# Copyright NumFOCUS +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0.txt +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Run with: +# ./{{ cookiecutter.example_name }}.py +# +# e.g. +# ./{{ cookiecutter.example_name }}.py MyImage.mha Output.mha 2 0.2 +# (A rule of thumb is to set the Threshold to be about 1 / 100 of the Level.) +# +# parameter_1: absolute minimum... +# The assumption is that... +# parameter_2: controls the.. +# A tradeoff between... + +import argparse + +import itk + + +parser = argparse.ArgumentParser(description="Example short description.") +parser.add_argument("input_image") +parser.add_argument("output_image") +parser.add_argument("parameter_1") +args = parser.parse_args() + +# Please, write a complete, self-containted and useful example that +# demonstrate a class when being used along with other ITK classes or in +# the context of a wider or specific application. diff --git a/{{cookiecutter.project_name}}/include/itkMinimalStandardRandomVariateGenerator.h b/{{cookiecutter.project_name}}/include/itkMinimalStandardRandomVariateGenerator.h index 6f66bc1..15c4854 100644 --- a/{{cookiecutter.project_name}}/include/itkMinimalStandardRandomVariateGenerator.h +++ b/{{cookiecutter.project_name}}/include/itkMinimalStandardRandomVariateGenerator.h @@ -1,12 +1,12 @@ /*========================================================================= * - * Copyright Insight Software Consortium + * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0.txt + * https://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -40,7 +40,7 @@ namespace Statistics * where \f$a\f$ is the Multiplier \f$c\f$ is the Increment and \f$m\f$ is * the Modulus. * - * http://en.wikipedia.com/wiki/Linear_congruential_generator + * https://en.wikipedia.com/wiki/Linear_congruential_generator * * The random numbers generated have a period \f$m\f$. * @@ -50,41 +50,43 @@ namespace Statistics * * \ingroup {{ cookiecutter.module_name }} */ -class {{ cookiecutter.module_name }}_EXPORT MinimalStandardRandomVariateGenerator: - public RandomVariateGeneratorBase +class {{ cookiecutter.module_name }}_EXPORT MinimalStandardRandomVariateGenerator : public RandomVariateGeneratorBase { public: - /** Standard class typedefs. */ - typedef MinimalStandardRandomVariateGenerator Self; - typedef RandomVariateGeneratorBase Superclass; - typedef SmartPointer< Self > Pointer; - typedef SmartPointer< const Self > ConstPointer; + ITK_DISALLOW_COPY_AND_MOVE(MinimalStandardRandomVariateGenerator); - typedef uint32_t IntegerType; + /** Standard class aliases. */ + using Self = MinimalStandardRandomVariateGenerator; + using Superclass = RandomVariateGeneratorBase; + using Pointer = SmartPointer; + using ConstPointer = SmartPointer; - typedef itk::Statistics::NormalVariateGenerator NormalGeneratorType; + using IntegerType = uint32_t; + + using NormalGeneratorType = itk::Statistics::NormalVariateGenerator; /** Run-time type information (and related methods). */ - itkTypeMacro( MinimalStandardRandomVariateGenerator, RandomVariateGeneratorBase); + itkOverrideGetNameOfClassMacro(MinimalStandardRandomVariateGenerator); /** Method for creation through the object factory. */ - itkNewMacro( Self ); + itkNewMacro(Self); /** initialize with a simple IntegerType */ - void Initialize(int randomSeed); + void + Initialize(int randomSeed); /** Get a variate in the range [0, 1] */ - virtual double GetVariate() ITK_OVERRIDE; + double + GetVariate() override; protected: MinimalStandardRandomVariateGenerator(); - virtual ~MinimalStandardRandomVariateGenerator() {} + ~MinimalStandardRandomVariateGenerator() override = default; - virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE; + void + PrintSelf(std::ostream & os, Indent indent) const override; private: - ITK_DISALLOW_COPY_AND_ASSIGN(MinimalStandardRandomVariateGenerator); - NormalGeneratorType::Pointer m_NormalGenerator; }; diff --git a/{{cookiecutter.project_name}}/include/itkNormalDistributionImageSource.h b/{{cookiecutter.project_name}}/include/itkNormalDistributionImageSource.h deleted file mode 100644 index 76e94ff..0000000 --- a/{{cookiecutter.project_name}}/include/itkNormalDistributionImageSource.h +++ /dev/null @@ -1,88 +0,0 @@ -/*========================================================================= - * - * Copyright Insight Software Consortium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ -#ifndef itkNormalDistributionImageSource_h -#define itkNormalDistributionImageSource_h - -#include "itkGenerateImageSource.h" - -namespace itk -{ - -/** \class NormalDistributionImageSource - * - * \brief Generate a image of pixels sampled from a normal distribution. - * - * Real-valued pixels are sampled from a normal distribution. - * - * The pixels, \f$x > 0\f$ follow - * - * \f[ - * f(x) = \frac{1}{sx\sqrt{2 \pi}} e^{\left( \frac{-(ln x - m)^2}{2s^2} \right)} - * \f] - * - * where \f$s\f$ is the StandardDeviation and \f$m\f$ is the Mean of the - * underlying normal distribution. - * - * \ingroup {{ cookiecutter.module_name }} - * - */ -template< typename TImage > -class NormalDistributionImageSource: public GenerateImageSource< TImage > -{ -public: - typedef TImage ImageType; - typedef typename ImageType::PixelType PixelType; - - /** Standard class typedefs. */ - typedef NormalDistributionImageSource Self; - typedef GenerateImageSource< ImageType > Superclass; - typedef SmartPointer< Self > Pointer; - typedef SmartPointer< const Self > ConstPointer; - - itkStaticConstMacro( ImageDimension, unsigned int, ImageType::ImageDimension ); - - /** Run-time type information. */ - itkTypeMacro( NormalDistributionImageSource, GenerateImageSource ); - - /** Standard New macro. */ - itkNewMacro( Self ); - -protected: - NormalDistributionImageSource(); - virtual ~NormalDistributionImageSource() {} - - void PrintSelf( std::ostream& os, Indent indent ) const ITK_OVERRIDE; - - typedef typename ImageType::RegionType OutputRegionType; - - virtual void ThreadedGenerateData( const OutputRegionType & outputRegion, ThreadIdType threadId ) ITK_OVERRIDE; - -private: - ITK_DISALLOW_COPY_AND_ASSIGN(NormalDistributionImageSource); - -#ifdef ITK_USE_CONCEPT_CHECKING - itkConceptMacro( FloatingPointPixel, ( itk::Concept::IsFloatingPoint< typename ImageType::PixelType > ) ); -#endif -}; -} - -#ifndef ITK_MANUAL_INSTANTIATION -#include "itkNormalDistributionImageSource.hxx" -#endif - -#endif // itkNormalDistributionImageSource_h diff --git a/{{cookiecutter.project_name}}/include/itkNormalDistributionImageSource.hxx b/{{cookiecutter.project_name}}/include/itkNormalDistributionImageSource.hxx deleted file mode 100644 index ef98746..0000000 --- a/{{cookiecutter.project_name}}/include/itkNormalDistributionImageSource.hxx +++ /dev/null @@ -1,82 +0,0 @@ -/*========================================================================= - * - * Copyright Insight Software Consortium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ -#ifndef itkNormalDistributionImageSource_hxx -#define itkNormalDistributionImageSource_hxx - -#include "itkNormalDistributionImageSource.h" -#include "itkNormalVariateGenerator.h" - -#include "itkImageScanlineIterator.h" -#include "itkProgressReporter.h" - -namespace itk -{ - -template< typename TImage > -NormalDistributionImageSource< TImage > -::NormalDistributionImageSource() -{ -} - - -template< typename TImage > -void -NormalDistributionImageSource< TImage > -::PrintSelf( std::ostream& os, Indent indent ) const -{ - Superclass::PrintSelf( os, indent ); -} - - -template< typename TImage > -void -NormalDistributionImageSource< TImage > -::ThreadedGenerateData( const OutputRegionType & outputRegion, ThreadIdType threadId ) -{ - ImageType * output = this->GetOutput(); - - typedef itk::Statistics::NormalVariateGenerator NormalGeneratorType; - NormalGeneratorType::Pointer normalGenerator = NormalGeneratorType::New(); - normalGenerator->Initialize( 101 ); - - const SizeValueType size0 = outputRegion.GetSize( 0 ); - if( size0 == 0 ) - { - return; - } - const SizeValueType numberOfLinesToProcess = outputRegion.GetNumberOfPixels() / size0; - - typedef ImageScanlineIterator< ImageType > IteratorType; - IteratorType it( output, outputRegion ); - ProgressReporter progress( this, threadId, numberOfLinesToProcess ); - - while( !it.IsAtEnd() ) - { - while( !it.IsAtEndOfLine() ) - { - it.Set( normalGenerator->GetVariate() ); - ++it; - } - it.NextLine(); - progress.CompletedPixel(); - } -} - -} // end namespace itk - -#endif // itkNormalDistributionImageSource_hxx diff --git a/{{cookiecutter.project_name}}/include/itk{{cookiecutter.filter_name}}.h b/{{cookiecutter.project_name}}/include/itk{{cookiecutter.filter_name}}.h new file mode 100644 index 0000000..ad2d661 --- /dev/null +++ b/{{cookiecutter.project_name}}/include/itk{{cookiecutter.filter_name}}.h @@ -0,0 +1,86 @@ +/*========================================================================= + * + * Copyright NumFOCUS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ +#ifndef itk{{ cookiecutter.filter_name }}_h +#define itk{{ cookiecutter.filter_name }}_h + +#include "itkImageToImageFilter.h" + +namespace itk +{ + +/** \class {{ cookiecutter.filter_name }} + * + * \brief Filters a image by iterating over its pixels. + * + * Filters a image by iterating over its pixels in a multi-threaded way + * and {to be completed by the developer}. + * + * \ingroup {{ cookiecutter.module_name }} + * + */ +template +class {{ cookiecutter.filter_name }} : public ImageToImageFilter +{ +public: + ITK_DISALLOW_COPY_AND_MOVE({{ cookiecutter.filter_name }}); + + static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension; + static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension; + + using InputImageType = TInputImage; + using OutputImageType = TOutputImage; + using InputPixelType = typename InputImageType::PixelType; + using OutputPixelType = typename OutputImageType::PixelType; + + /** Standard class aliases. */ + using Self = {{ cookiecutter.filter_name }}; + using Superclass = ImageToImageFilter; + using Pointer = SmartPointer; + using ConstPointer = SmartPointer; + + /** Run-time type information. */ + itkOverrideGetNameOfClassMacro({{ cookiecutter.filter_name }}); + + /** Standard New macro. */ + itkNewMacro(Self); + +protected: + {{ cookiecutter.filter_name }}(); + ~{{ cookiecutter.filter_name }}() override = default; + + void + PrintSelf(std::ostream & os, Indent indent) const override; + + using OutputRegionType = typename OutputImageType::RegionType; + + void + DynamicThreadedGenerateData(const OutputRegionType & outputRegion) override; + +private: +#ifdef ITK_USE_CONCEPT_CHECKING + // Add concept checking such as + // itkConceptMacro( FloatingPointPixel, ( itk::Concept::IsFloatingPoint< typename InputImageType::PixelType > ) ); +#endif +}; +} // namespace itk + +#ifndef ITK_MANUAL_INSTANTIATION +# include "itk{{ cookiecutter.filter_name }}.hxx" +#endif + +#endif // itk{{ cookiecutter.filter_name }} diff --git a/{{cookiecutter.project_name}}/include/itk{{cookiecutter.filter_name}}.hxx b/{{cookiecutter.project_name}}/include/itk{{cookiecutter.filter_name}}.hxx new file mode 100644 index 0000000..0f1946a --- /dev/null +++ b/{{cookiecutter.project_name}}/include/itk{{cookiecutter.filter_name}}.hxx @@ -0,0 +1,65 @@ +/*========================================================================= + * + * Copyright NumFOCUS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ +#ifndef itk{{ cookiecutter.filter_name }}_hxx +#define itk{{ cookiecutter.filter_name }}_hxx + +#include "itk{{ cookiecutter.filter_name }}.h" + +#include "itkImageRegionIterator.h" +#include "itkImageRegionConstIterator.h" + +namespace itk +{ + +template +{{ cookiecutter.filter_name }} +::{{ cookiecutter.filter_name }}() +{} + + +template +void +{{ cookiecutter.filter_name }} +::PrintSelf(std::ostream & os, Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} + + +template +void +{{ cookiecutter.filter_name }} +::DynamicThreadedGenerateData(const OutputRegionType & outputRegion) +{ + OutputImageType * output = this->GetOutput(); + const InputImageType * input = this->GetInput(); + using InputRegionType = typename InputImageType::RegionType; + InputRegionType inputRegion = InputRegionType(outputRegion.GetSize()); + + itk::ImageRegionConstIterator in(input, inputRegion); + itk::ImageRegionIterator out(output, outputRegion); + + for (in.GoToBegin(), out.GoToBegin(); !in.IsAtEnd() && !out.IsAtEnd(); ++in, ++out) + { + out.Set(in.Get()); + } +} + +} // end namespace itk + +#endif // itk{{ cookiecutter.filter_name }}_hxx diff --git a/{{cookiecutter.project_name}}/itk-module.cmake b/{{cookiecutter.project_name}}/itk-module.cmake index 9a38e04..462b4a9 100644 --- a/{{cookiecutter.project_name}}/itk-module.cmake +++ b/{{cookiecutter.project_name}}/itk-module.cmake @@ -1,7 +1,7 @@ # the top-level README is used for describing this module, just # re-used it for documentation here get_filename_component(MY_CURRENT_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) -file(READ "${MY_CURRENT_DIR}/README.rst" DOCUMENTATION) +file(READ "${MY_CURRENT_DIR}/README.md" DOCUMENTATION) # itk_module() defines the module dependencies in {{ cookiecutter.module_name }} # {{ cookiecutter.module_name }} depends on ITKCommon diff --git a/{{cookiecutter.project_name}}/pyproject.toml b/{{cookiecutter.project_name}}/pyproject.toml new file mode 100644 index 0000000..e5f3d71 --- /dev/null +++ b/{{cookiecutter.project_name}}/pyproject.toml @@ -0,0 +1,108 @@ +[build-system] +requires = ["scikit-build-core"] +build-backend = "scikit_build_core.build" + +[project] +name = "{{ cookiecutter.python_package_name }}" +version = "0.1.0" +description = "{{ cookiecutter.project_short_description }}" +readme = "README.md" +license = {file = "LICENSE"} +authors = [ + { name = "{{ cookiecutter.full_name }}", email = "{{ cookiecutter.email }}" }, +] +keywords = [ + "itk", +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Healthcare Industry", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: Apache Software License", + "Operating System :: Android", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Programming Language :: C++", + "Programming Language :: Python", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Information Analysis", + "Topic :: Scientific/Engineering :: Medical Science Apps.", + "Topic :: Software Development :: Libraries", +] +requires-python = ">=3.9" +dependencies = [ + "itk == 5.4.*", +] + +[project.urls] +Download = "{{ cookiecutter.download_url }}" +Homepage = "{{ cookiecutter.download_url }}" + +[tool.scikit-build] +# The versions of CMake to allow. If CMake is not present on the system or does +# not pass this specifier, it will be downloaded via PyPI if possible. An empty +# string will disable this check. +cmake.version = ">=3.22.1" + +# A list of args to pass to CMake when configuring the project. Setting this in +# config or envvar will override toml. See also ``cmake.define``. +cmake.args = [] + +# A table of defines to pass to CMake when configuring the project. Additive. +cmake.define = {} + +# Verbose printout when building. +cmake.verbose = true + +# The build type to use when building the project. Valid options are: "Debug", +# "Release", "RelWithDebInfo", "MinSizeRel", "", etc. +cmake.build-type = "Release" + +# The source directory to use when building the project. Currently only affects +# the native builder (not the setuptools plugin). +cmake.source-dir = "." + +# The versions of Ninja to allow. If Ninja is not present on the system or does +# not pass this specifier, it will be downloaded via PyPI if possible. An empty +# string will disable this check. +ninja.version = ">=1.11" + +# The logging level to display, "DEBUG", "INFO", "WARNING", and "ERROR" are +# possible options. +logging.level = "INFO" + +# Files to include in the SDist even if they are skipped by default. Supports +# gitignore syntax. +sdist.include = [] + +# Files to exclude from the SDist even if they are included by default. Supports +# gitignore syntax. +sdist.exclude = [] + +# A list of license files to include in the wheel. Supports glob patterns. +wheel.license-files = ["LICEN[CS]E*",] + +# Target the platlib or the purelib. If not set, the default is to target the +# platlib if wheel.cmake is true, and the purelib otherwise. +wheel.platlib = "false" + +# If CMake is less than this value, backport a copy of FindPython. Set to 0 +# disable this, or the empty string. +backport.find-python = "3.26.1" + +# Select the editable mode to use. Can be "redirect" (default) or "inplace". +editable.mode = "redirect" + +# Rebuild the project when the package is imported. The build-directory must be +# set. +editable.rebuild = false + +# If set, this will provide a method for scikit-build-core backward compatibility. +minimum-version = "0.8.2" + +# The build directory. Defaults to a temporary directory, but can be set. +build-dir = "build/{wheel_tag}" diff --git a/{{cookiecutter.project_name}}/setup.py b/{{cookiecutter.project_name}}/setup.py deleted file mode 100644 index 4225e8d..0000000 --- a/{{cookiecutter.project_name}}/setup.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function -from os import sys - -try: - from skbuild import setup -except ImportError: - print('scikit-build is required to build from source.', file=sys.stderr) - print('Please run:', file=sys.stderr) - print('', file=sys.stderr) - print(' python -m pip install scikit-build') - sys.exit(1) - -setup( - name='{{ cookiecutter.python_package_name }}', - version='0.1.0', - author='{{ cookiecutter.full_name }}', - author_email='{{ cookiecutter.email }}', - packages=['itk'], - package_dir={'itk': 'itk'}, - download_url=r'{{ cookiecutter.download_url }}', - description=r'{{ cookiecutter.project_short_description }}', - long_description='{{ cookiecutter.project_long_description }}', - classifiers=[ - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", - "Programming Language :: C++", - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "Intended Audience :: Education", - "Intended Audience :: Healthcare Industry", - "Intended Audience :: Science/Research", - "Topic :: Scientific/Engineering", - "Topic :: Scientific/Engineering :: Medical Science Apps.", - "Topic :: Scientific/Engineering :: Information Analysis", - "Topic :: Software Development :: Libraries", - "Operating System :: Android", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Operating System :: Unix", - "Operating System :: MacOS" - ], - license='Apache', - keywords='ITK InsightToolkit', - url=r'https://itk.org/', - install_requires=[ - r'itk' - ] - ) diff --git a/{{cookiecutter.project_name}}/src/itkMinimalStandardRandomVariateGenerator.cxx b/{{cookiecutter.project_name}}/src/itkMinimalStandardRandomVariateGenerator.cxx index a9ce459..a34635f 100644 --- a/{{cookiecutter.project_name}}/src/itkMinimalStandardRandomVariateGenerator.cxx +++ b/{{cookiecutter.project_name}}/src/itkMinimalStandardRandomVariateGenerator.cxx @@ -1,12 +1,12 @@ /*========================================================================= * - * Copyright Insight Software Consortium + * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0.txt + * https://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -22,32 +22,28 @@ namespace itk namespace Statistics { -MinimalStandardRandomVariateGenerator -::MinimalStandardRandomVariateGenerator() +MinimalStandardRandomVariateGenerator ::MinimalStandardRandomVariateGenerator() { this->m_NormalGenerator = NormalGeneratorType::New(); - this->Initialize( 1 ); + this->Initialize(1); } void -MinimalStandardRandomVariateGenerator -::Initialize(int randomSeed) +MinimalStandardRandomVariateGenerator ::Initialize(int randomSeed) { - this->m_NormalGenerator->Initialize( randomSeed ); + this->m_NormalGenerator->Initialize(randomSeed); } double -MinimalStandardRandomVariateGenerator -::GetVariate() +MinimalStandardRandomVariateGenerator ::GetVariate() { return this->m_NormalGenerator->GetVariate(); } void -MinimalStandardRandomVariateGenerator -::PrintSelf(std::ostream & os, Indent indent) const +MinimalStandardRandomVariateGenerator ::PrintSelf(std::ostream & os, Indent indent) const { Superclass::PrintSelf(os, indent); } diff --git a/{{cookiecutter.project_name}}/test/Baseline/itkNormalDistributionImageSourceTestOutput.mha.sha512 b/{{cookiecutter.project_name}}/test/Baseline/itkNormalDistributionImageSourceTestOutput.mha.sha512 deleted file mode 100644 index 5091c18..0000000 --- a/{{cookiecutter.project_name}}/test/Baseline/itkNormalDistributionImageSourceTestOutput.mha.sha512 +++ /dev/null @@ -1 +0,0 @@ -38a102c75d4e30f57834fd3dc1ba61e30943714da9a9d27e4b77ee5fb58c1e34269a44c2af3cfd3a0b738de0f5ea293f0f609b8a66eede3f299703548ed57608 \ No newline at end of file diff --git a/{{cookiecutter.project_name}}/test/Baseline/itk{{cookiecutter.filter_name}}TestOutput.mha.sha512 b/{{cookiecutter.project_name}}/test/Baseline/itk{{cookiecutter.filter_name}}TestOutput.mha.sha512 new file mode 100644 index 0000000..c811785 --- /dev/null +++ b/{{cookiecutter.project_name}}/test/Baseline/itk{{cookiecutter.filter_name}}TestOutput.mha.sha512 @@ -0,0 +1 @@ +34cdd2aafce413dcf7efc692a707d53b7b57ebb006d0fbc20ecb42343f8a078b2252eff2137b17d3ab583d133f780438e247241ebf213c3289bd9ba1525081b7 diff --git a/{{cookiecutter.project_name}}/test/CMakeLists.txt b/{{cookiecutter.project_name}}/test/CMakeLists.txt index cde5454..0f6e566 100644 --- a/{{cookiecutter.project_name}}/test/CMakeLists.txt +++ b/{{cookiecutter.project_name}}/test/CMakeLists.txt @@ -2,7 +2,7 @@ itk_module_test() set({{ cookiecutter.module_name }}Tests itkMinimalStandardRandomVariateGeneratorTest.cxx - itkNormalDistributionImageSourceTest.cxx + itk{{ cookiecutter.filter_name }}Test.cxx ) CreateTestDriver({{ cookiecutter.module_name }} "${{ '{' }}{{ cookiecutter.module_name -}}-Test_LIBRARIES}" "${{ '{' }}{{ cookiecutter.module_name }}Tests}") @@ -11,11 +11,11 @@ itk_add_test(NAME itkMinimalStandardRandomVariateGeneratorTest COMMAND {{ cookiecutter.module_name }}TestDriver itkMinimalStandardRandomVariateGeneratorTest ) -itk_add_test(NAME itkNormalDistributionImageSourceTest - COMMAND {{ cookiecutter.module_name }}TestDriver --without-threads - --compare - ${ITK_TEST_OUTPUT_DIR}/itkNormalDistributionImageSourceTestOutput.mha - DATA{Baseline/itkNormalDistributionImageSourceTestOutput.mha} - itkNormalDistributionImageSourceTest - ${ITK_TEST_OUTPUT_DIR}/itkNormalDistributionImageSourceTestOutput.mha +itk_add_test(NAME itk{{ cookiecutter.filter_name }}Test + COMMAND {{ cookiecutter.module_name }}TestDriver + --compare + DATA{Baseline/itk{{ cookiecutter.filter_name }}TestOutput.mha} + ${ITK_TEST_OUTPUT_DIR}/itk{{ cookiecutter.filter_name }}TestOutput.mha + itk{{ cookiecutter.filter_name }}Test + ${ITK_TEST_OUTPUT_DIR}/itk{{ cookiecutter.filter_name }}TestOutput.mha ) diff --git a/{{cookiecutter.project_name}}/test/itkMinimalStandardRandomVariateGeneratorTest.cxx b/{{cookiecutter.project_name}}/test/itkMinimalStandardRandomVariateGeneratorTest.cxx index fdc2b1f..a7494a6 100644 --- a/{{cookiecutter.project_name}}/test/itkMinimalStandardRandomVariateGeneratorTest.cxx +++ b/{{cookiecutter.project_name}}/test/itkMinimalStandardRandomVariateGeneratorTest.cxx @@ -1,12 +1,12 @@ /*========================================================================= * - * Copyright Insight Software Consortium + * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0.txt + * https://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -21,16 +21,17 @@ #include "itkTestingMacros.h" #include "itkMath.h" -int itkMinimalStandardRandomVariateGeneratorTest( int, char * [] ) +int +itkMinimalStandardRandomVariateGeneratorTest(int, char *[]) { typedef itk::Statistics::MinimalStandardRandomVariateGenerator GeneratorType; - GeneratorType::Pointer generator = GeneratorType::New(); - - EXERCISE_BASIC_OBJECT_METHODS( generator, MinimalStandardRandomVariateGenerator, RandomVariateGeneratorBase ); + GeneratorType::Pointer generator = GeneratorType::New(); - generator->Initialize( 324 ); + ITK_EXERCISE_BASIC_OBJECT_METHODS(generator, MinimalStandardRandomVariateGenerator, RandomVariateGeneratorBase); - TEST_EXPECT_TRUE( itk::Math::FloatAlmostEqual( generator->GetVariate(), 1.35581 , 4 , 0.0001)); + generator->Initialize(324); + + ITK_TEST_EXPECT_TRUE(itk::Math::FloatAlmostEqual(generator->GetVariate(), 1.35581, 4, 0.0001)); return EXIT_SUCCESS; } diff --git a/{{cookiecutter.project_name}}/test/itkNormalDistributionImageSourceTest.cxx b/{{cookiecutter.project_name}}/test/itkNormalDistributionImageSourceTest.cxx deleted file mode 100644 index c246f66..0000000 --- a/{{cookiecutter.project_name}}/test/itkNormalDistributionImageSourceTest.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/*========================================================================= - * - * Copyright Insight Software Consortium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ - -#include "itkNormalDistributionImageSource.h" - -#include "itkImageFileWriter.h" -#include "itkTestingMacros.h" - -int itkNormalDistributionImageSourceTest( int argc, char * argv[] ) -{ - if( argc < 2 ) - { - std::cerr << "Usage: " << argv[0]; - std::cerr << " outputImage"; - std::cerr << std::endl; - return EXIT_FAILURE; - } - const char * outputImageFileName = argv[1]; - - const unsigned int Dimension = 2; - typedef float PixelType; - typedef itk::Image< PixelType, Dimension > ImageType; - - typedef itk::NormalDistributionImageSource< ImageType > DistributionSourceType; - DistributionSourceType::Pointer distributionSource = DistributionSourceType::New(); - - EXERCISE_BASIC_OBJECT_METHODS( distributionSource, NormalDistributionImageSource , GenerateImageSource ); - - - ImageType::SizeType size; - size.Fill( 128 ); - distributionSource->SetSize( size ); - - std::cout << distributionSource << std::endl; - - typedef itk::ImageFileWriter< ImageType > WriterType; - WriterType::Pointer writer = WriterType::New(); - writer->SetFileName( outputImageFileName ); - writer->SetInput( distributionSource->GetOutput() ); - try - { - writer->Update(); - } - catch( itk::ExceptionObject & error ) - { - std::cerr << "Error: " << error << std::endl; - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} diff --git a/{{cookiecutter.project_name}}/test/itk{{cookiecutter.filter_name}}Test.cxx b/{{cookiecutter.project_name}}/test/itk{{cookiecutter.filter_name}}Test.cxx new file mode 100644 index 0000000..7022a88 --- /dev/null +++ b/{{cookiecutter.project_name}}/test/itk{{cookiecutter.filter_name}}Test.cxx @@ -0,0 +1,100 @@ +/*========================================================================= + * + * Copyright NumFOCUS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ + +#include "itk{{ cookiecutter.filter_name }}.h" + +#include "itkCommand.h" +#include "itkImageFileWriter.h" +#include "itkTestingMacros.h" + +namespace +{ +class ShowProgress : public itk::Command +{ +public: + itkNewMacro(ShowProgress); + + void + Execute(itk::Object * caller, const itk::EventObject & event) override + { + Execute((const itk::Object *)caller, event); + } + + void + Execute(const itk::Object * caller, const itk::EventObject & event) override + { + if (!itk::ProgressEvent().CheckEvent(&event)) + { + return; + } + const auto * processObject = dynamic_cast(caller); + if (!processObject) + { + return; + } + std::cout << " " << processObject->GetProgress(); + } +}; +} // namespace + +int +itk{{ cookiecutter.filter_name }}Test(int argc, char * argv[]) +{ + if (argc < 2) + { + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv); + std::cerr << " outputImage"; + std::cerr << std::endl; + return EXIT_FAILURE; + } + const char * outputImageFileName = argv[1]; + + constexpr unsigned int Dimension = 2; + using PixelType = float; + using ImageType = itk::Image; + + using FilterType = itk::{{ cookiecutter.filter_name }}; + FilterType::Pointer filter = FilterType::New(); + + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, {{ cookiecutter.filter_name }}, ImageToImageFilter); + + // Create input image to avoid test dependencies. + ImageType::SizeType size; + size.Fill(128); + ImageType::Pointer image = ImageType::New(); + image->SetRegions(size); + image->Allocate(); + image->FillBuffer(1.1f); + + ShowProgress::Pointer showProgress = ShowProgress::New(); + filter->AddObserver(itk::ProgressEvent(), showProgress); + filter->SetInput(image); + + using WriterType = itk::ImageFileWriter; + WriterType::Pointer writer = WriterType::New(); + writer->SetFileName(outputImageFileName); + writer->SetInput(filter->GetOutput()); + writer->SetUseCompression(true); + + ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); + + + std::cout << "Test finished." << std::endl; + return EXIT_SUCCESS; +} diff --git a/{{cookiecutter.project_name}}/wrapping/itkNormalDistributionImageSource.wrap b/{{cookiecutter.project_name}}/wrapping/itkNormalDistributionImageSource.wrap deleted file mode 100644 index 44c934f..0000000 --- a/{{cookiecutter.project_name}}/wrapping/itkNormalDistributionImageSource.wrap +++ /dev/null @@ -1,7 +0,0 @@ -itk_wrap_class("itk::NormalDistributionImageSource" POINTER) - foreach(d ${ITK_WRAP_IMAGE_DIMS}) - itk_wrap_template("${ITKM_I${ITKM_F}${d}}" - "${ITKT_I${ITKM_F}${d}}") - - endforeach() -itk_end_wrap_class() diff --git a/{{cookiecutter.project_name}}/wrapping/itk{{cookiecutter.filter_name}}.wrap b/{{cookiecutter.project_name}}/wrapping/itk{{cookiecutter.filter_name}}.wrap new file mode 100644 index 0000000..ffa5e79 --- /dev/null +++ b/{{cookiecutter.project_name}}/wrapping/itk{{cookiecutter.filter_name}}.wrap @@ -0,0 +1,4 @@ +itk_wrap_class("itk::{{ cookiecutter.filter_name }}" POINTER) + itk_wrap_image_filter("${WRAP_ITK_SCALAR}" 2) +itk_end_wrap_class() +