summaryrefslogtreecommitdiff
path: root/gnu/packages/image-processing.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/image-processing.scm')
-rw-r--r--gnu/packages/image-processing.scm199
1 files changed, 189 insertions, 10 deletions
diff --git a/gnu/packages/image-processing.scm b/gnu/packages/image-processing.scm
index ab30dfa31d..a4a73b9435 100644
--- a/gnu/packages/image-processing.scm
+++ b/gnu/packages/image-processing.scm
@@ -88,6 +88,7 @@
#:use-module (gnu packages image)
#:use-module (gnu packages imagemagick)
#:use-module (gnu packages linux)
+ #:use-module (gnu packages lua)
#:use-module (gnu packages maths)
#:use-module (gnu packages mpi)
#:use-module (gnu packages opencl)
@@ -108,6 +109,7 @@
#:use-module (gnu packages sphinx)
#:use-module (gnu packages sqlite)
#:use-module (gnu packages ssh)
+ #:use-module (gnu packages statistics)
#:use-module (gnu packages swig)
#:use-module (gnu packages tbb)
#:use-module (gnu packages textutils)
@@ -1286,9 +1288,16 @@ libraries designed for computer vision research and implementation.")
;; For a remote MODULE, use the commit in
;; 'Modules/Remote/MODULE.remote.cmake'.
;; MorphologicalContourInterpolation is required by itk-snap.
- (let* ((module-commit "821bf9b3ef8eaaab10391ed060dc9ca5e4d37b39")
- (module-file (git-file-name "ITKMorphologicalContourInterpolation"
- module-commit)))
+ ;; SimpleITKFilters and GenericLabelInterpolator are required by simpleitk.
+ (let* ((module-mci-commit "821bf9b3ef8eaaab10391ed060dc9ca5e4d37b39")
+ (module-mci-file (git-file-name "ITKMorphologicalContourInterpolation"
+ module-mci-commit))
+ (module-sitkf-commit "bb896868fc6480835495d0da4356d5db009592a6")
+ (module-sitkf-file (git-file-name "ITKSimpleITKFilters"
+ module-sitkf-commit))
+ (module-gli-commit "ebf2436469ccf82c08fab54b7446f699ad0eae01")
+ (module-gli-file (git-file-name "ITKGenericLabelInterpolator"
+ module-gli-commit)))
(package
(name "insight-toolkit")
(version "5.4.4")
@@ -1309,7 +1318,11 @@ libraries designed for computer vision research and implementation.")
(outputs '("out" "python"))
(arguments
(list
- #:tests? #f ;tests require network access and external data
+ #:imported-modules (append %cmake-build-system-modules
+ %pyproject-build-system-modules)
+ #:modules '(((guix build pyproject-build-system) #:prefix py:)
+ (guix build cmake-build-system)
+ (guix build utils))
#:configure-flags
#~(list "-DITK_USE_GPU=ON"
"-DITK_USE_SYSTEM_LIBRARIES=ON"
@@ -1339,6 +1352,8 @@ libraries designed for computer vision research and implementation.")
;; Python is not built with Py_LIMITED_API.
"-DITK_USE_PYTHON_LIMITED_API=OFF"
"-DModule_MorphologicalContourInterpolation=ON"
+ "-DModule_SimpleITKFilters=ON"
+ "-DModule_GenericLabelInterpolator=ON"
"-DCMAKE_CXX_STANDARD=17"
"-DBUILD_TESTING=OFF")
@@ -1372,12 +1387,33 @@ libraries designed for computer vision research and implementation.")
(lambda _
;; ITK module MorphologicalContourInterpolation
;; is for ITK-SNAP.
- (symlink #$(this-package-native-input module-file)
+ (symlink #$(this-package-native-input module-mci-file)
"Modules/Remote/MorphologicalContourInterpolation")
(delete-file
(string-append
"Modules/Remote/"
- "MorphologicalContourInterpolation.remote.cmake")))))))
+ "MorphologicalContourInterpolation.remote.cmake"))
+ ;; ITK modules SimpleITKFilters and GenericLabelInterpolator
+ ;; are for SimpleITK.
+ (symlink #$(this-package-native-input module-sitkf-file)
+ "Modules/Remote/SimpleITKFilters")
+ (delete-file "Modules/Remote/SimpleITKFilters.remote.cmake")
+ (symlink #$(this-package-native-input module-gli-file)
+ "Modules/Remote/GenericLabelInterpolator")
+ (delete-file
+ "Modules/Remote/GenericLabelInterpolator.remote.cmake")))
+ (add-after 'unpack 'fix-numpy-bool
+ (lambda _
+ ;; <https://github.com/InsightSoftwareConsortium/ITK/pull/5402>
+ (substitute* (string-append "Wrapping/Generators/"
+ "Python/itk/support/types.py")
+ (("np\\.bool") "np.bool_"))))
+ (delete 'check) ;tests require network access and external data
+ (add-after 'install 'python-sanity-check
+ (lambda* (#:key inputs outputs tests? #:allow-other-keys)
+ (when tests?
+ (py:add-installed-pythonpath inputs outputs)
+ (invoke "python3" "-c" "import itk")))))))
(inputs (list eigen
expat
fftw
@@ -1397,6 +1433,7 @@ libraries designed for computer vision research and implementation.")
gcc-13
git-minimal
pkg-config
+ python-numpy ;for phase 'python-sanity-check
swig-next
which
(origin
@@ -1406,11 +1443,33 @@ libraries designed for computer vision research and implementation.")
(url (string-append
"https://github.com/KitwareMedical/"
"ITKMorphologicalContourInterpolation"))
- (commit module-commit)))
- (file-name module-file)
+ (commit module-mci-commit)))
+ (file-name module-mci-file)
(sha256
(base32
- "00myhgvlk3n062i8bnknz1d10zkv3jlvs7f4jnk24727gd4v2n4i")))))
+ "00myhgvlk3n062i8bnknz1d10zkv3jlvs7f4jnk24727gd4v2n4i")))
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url (string-append
+ "https://github.com/InsightSoftwareConsortium/"
+ "ITKSimpleITKFilters"))
+ (commit module-sitkf-commit)))
+ (file-name module-sitkf-file)
+ (sha256
+ (base32
+ "13nys94wl4k77f89i8y1dm3y4pmgmw3rrc0la1rzl0vi9h1qixii")))
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url (string-append
+ "https://github.com/InsightSoftwareConsortium/"
+ "ITKGenericLabelInterpolator"))
+ (commit module-gli-commit)))
+ (file-name module-gli-file)
+ (sha256
+ (base32
+ "1khakqh6pzdg6csli8jypzrhcdr9xmhnzgwz265krv8r5mbnndrg")))))
;; The 'CMake/ITKSetStandardCompilerFlags.cmake' file normally sets
;; '-mtune=native -march=corei7', suggesting there's something to be
@@ -1454,11 +1513,15 @@ combine the information contained in both.")
(string-prefix? "-DITK_USE_PYTHON_LIMITED_API=" flag)
(string-prefix? "-DITK_USE_SYSTEM_CASTXML=" flag)
(string-prefix? "-DITK_USE_SYSTEM_SWIG=" flag))))
- #$cf))))
+ #$cf))
+ ((#:phases phases #~%standard-phases)
+ #~(modify-phases #$phases
+ (delete 'python-sanity-check)))))
(inputs (modify-inputs (package-inputs insight-toolkit)
(delete "python")))
(native-inputs (modify-inputs (package-native-inputs insight-toolkit)
(delete "castxml")
+ (delete "python-numpy")
(delete "swig"))))))
(define-public itk-snap
@@ -1687,6 +1750,122 @@ Scan Tailer Advanced is a fork of Scan Tailer that merges Scan Tailor Featured
and Scan Tailor Enhanced versions as well as including many more bug fixes.")
(license license:gpl3+))))
+(define-public simpleitk
+ (package
+ (name "simpleitk")
+ (version "2.5.2")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/SimpleITK/SimpleITK")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1ykrfrfh2012cg1122689w23pan2y731sszfpb701zhsb6fwv7j7"))))
+ (build-system cmake-build-system)
+ (outputs '("out" "python" "r"))
+ (arguments
+ (list
+ #:configure-flags
+ #~(list "-DBUILD_SHARED_LIBS=ON"
+ "-DWRAP_LUA=OFF"
+ "-DWRAP_PYTHON=ON"
+ "-DWRAP_R=ON"
+ "-DSimpleITK_PYTHON_USE_VIRTUALENV=OFF")
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'early-GTest-discovery
+ (lambda _
+ ;; Find GTest before targets link to 'GTest::GTest'.
+ (substitute* "Testing/Unit/CMakeLists.txt"
+ (("add_subdirectory\\(TestBase\\)" anchor)
+ (string-append "find_package(GTest REQUIRED)\n" anchor)))))
+ (add-after 'unpack 'extract-test-data
+ (lambda _
+ (invoke "tar" "xvf"
+ #$(this-package-native-input
+ (string-append "SimpleITKData-" version ".tar.gz"))
+ "--strip-components=1")))
+ (add-after 'unpack 'fix-runpath
+ (lambda _
+ ;; The SWIG-generated shared libraries do not have SimpleITK's
+ ;; libraries in their RUNPATH.
+ (define (cmake-snippet start)
+ (string-append
+ start
+ "set_target_properties(${SWIG_MODULE_SimpleITK_TARGET_NAME} "
+ "PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE "
+ "INSTALL_RPATH \"" #$output "/lib\")\n"))
+ (substitute* "Wrapping/Python/CMakeLists.txt"
+ (("^set\\(SWIG_MODULE_SimpleITKPython.*" anchor)
+ (cmake-snippet anchor)))
+ (substitute* "Wrapping/R/CMakeLists.txt"
+ (("^set\\(SWIG_MODULE_SimpleITKR.*" anchor)
+ (cmake-snippet anchor)))))
+ (add-after 'unpack 'patch-cmake-config-itk-path
+ (lambda _
+ ;; Allow building SimpleITK C++ projects without ITK installed
+ ;; in the profile.
+ #$(let*
+ ((itk (this-package-input "insight-toolkit"))
+ (itk-version (package-version itk))
+ (itk-version-major+minor
+ (version-major+minor itk-version)))
+ #~(substitute* "SimpleITKConfig.cmake.in"
+ (((string-append
+ "find_package\\(ITK \"@ITK_VERSION@\" "
+ "EXACT REQUIRED\\)"))
+ (string-append
+ "find_package(ITK \"" #$itk-version
+ "\" EXACT REQUIRED PATHS " #$itk
+ "/lib/cmake/ITK-"
+ #$itk-version-major+minor ")"))))))
+ (add-after 'install 'install-language-extension-modules
+ (lambda _
+ (with-directory-excursion "Wrapping/Python"
+ (invoke "python3" "setup.py" "bdist_wheel")
+ (apply invoke "pip" "--no-cache-dir" "--no-input" "install"
+ "--no-deps" "--prefix" #$output:python
+ (find-files "dist" "\\.whl$")))
+ (let ((r-package-path
+ (string-append #$output:r "/site-library/SimpleITK")))
+ (mkdir-p r-package-path)
+ (copy-recursively "Wrapping/R/R_libs/SimpleITK"
+ r-package-path))))
+ (delete 'check)
+ (add-after 'install 'check-after-install
+ ;; Run the tests when the SimpleITK libraries are where the
+ ;; language extension modules expect them to be.
+ (assoc-ref %standard-phases 'check)))))
+ (home-page "https://simpleitk.org")
+ (inputs (list insight-toolkit python r-minimal))
+ (native-inputs
+ (list googletest
+ lua
+ python-numpy ;for tests
+ python-pip
+ python-setuptools
+ python-wheel
+ swig-next
+ (origin
+ (method url-fetch)
+ (uri (string-append
+ "https://github.com/SimpleITK/SimpleITK/releases/download/v"
+ version "/SimpleITKData-" version ".tar.gz"))
+ (sha256
+ (base32
+ "13y44qqsgsvbrm84073i8clhggdgk8f36i6102sjg4j3fq790gal")))))
+ (synopsis "Simplified interface to @acronym{ITK, Insight Toolkit}")
+ (description
+ "SimpleITK is an image analysis toolkit built on top of @acronym{ITK,
+Insight Toolkit}. It provides a simplified interface to most of the
+image filters and the input/output and registration frameworks in
+@acronym{ITK, Insight Toolkit}. It is written in C++ and provides
+bindings for interpreted languages. This package includes the C++,
+Python and R interfaces.")
+ (license license:asl2.0)))
+
(define-public stiff
(package
(name "stiff")