From f53b641f701d015ffd3aa6e552d067e24b82539e Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Fri, 13 Mar 2026 21:31:17 +0100 Subject: [PATCH] gnu: Add elastix. * gnu/packages/image-processing.scm (elastix): New variable. * gnu/packages/patches/elastix-1404.patch: New file. * gnu/local.mk (dist_patch_DATA): Record it. Change-Id: Ic3b76c70afe2fc7ddb0f2516204f76e5690143a9 --- gnu/local.mk | 1 + gnu/packages/image-processing.scm | 52 ++++++++++++++++++++++++- gnu/packages/patches/elastix-1404.patch | 32 +++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/elastix-1404.patch diff --git a/gnu/local.mk b/gnu/local.mk index e8e144294e..a348b2916f 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1220,6 +1220,7 @@ dist_patch_DATA = \ %D%/packages/patches/dwarves-threading-reproducibility.patch \ %D%/packages/patches/efitools-riscv64-support.patch \ %D%/packages/patches/efivar-fix-fprint-format.patch \ + %D%/packages/patches/elastix-1404.patch \ %D%/packages/patches/eigen-fix-strict-aliasing-bug.patch \ %D%/packages/patches/einstein-build.patch \ %D%/packages/patches/elfutils-tests-ptrace.patch \ diff --git a/gnu/packages/image-processing.scm b/gnu/packages/image-processing.scm index 01d829e72a..06452038db 100644 --- a/gnu/packages/image-processing.scm +++ b/gnu/packages/image-processing.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 John Darrington -;;; Copyright © 2017, 2019, 2022, 2024 Ricardo Wurmus +;;; Copyright © 2017, 2019, 2021-2026 Ricardo Wurmus ;;; Copyright © 2014, 2021-2023, 2026 Ludovic Courtès ;;; Copyright © 2014 Mark H Weaver ;;; Copyright © 2016 Eric Bavier @@ -1771,6 +1771,56 @@ full-featured UI aimed at clinical researchers.") ;; This includes the submodules greedy, c3d and digestible. (license license:gpl3+)))) +(define-public elastix + (package + (name "elastix") + (version "5.3.0") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/SuperElastix/elastix") + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 "0sgw4cz4x6f78n6iqn87ll6wad32y67lmzvqfdfw1pzjkxbwzwyr")) + (patches + (search-patches "elastix-1404.patch")))) + (properties '((tunable? . #t))) + (build-system cmake-build-system) + (arguments + (list + #:configure-flags + #~(list "-DELASTIX_USE_EIGEN=ON" + "-DELASTIX_ENABLE_PACKAGER:BOOL=OFF" + "-DELASTIX_BUILD_EXECUTABLE:BOOL=ON" + "-DCMAKE_CXX_FLAGS=-fPIC" + "-DCMAKE_CXX_STANDARD=17" + "-DBUILD_TESTING:BOOL=ON") + ;; These tests fail and are skipped in upstream CI. + #:test-exclude (string-join + (list "elastix_run_example_COMPARE_IM" + (string-append "elastix_run_3DCT_lung.MI.bspline." + "ASGD.001_COMPARE_TP")) + "|"))) + (inputs (list charls + dcmtk + eigen + fftw + insight-toolkit + libpng + libtiff + zlib)) + (home-page "https://elastix.dev/") + (synopsis "Image registration toolbox") + (description + "Elastix is a toolbox for rigid and nonrigid registration of images. The +software consists of a collection of algorithms that are commonly used to +perform (medical) image registration: the task of finding a spatial +transformation, mapping one image (the fixed image) to another (the moving +image), by optimizing relevant image similarity metrics.") + (license license:asl2.0))) + (define-public metapixel ;; Follow stable branch. (let ((commit "98ee9daa093b6c334941242e63f90b1c2876eb4f")) diff --git a/gnu/packages/patches/elastix-1404.patch b/gnu/packages/patches/elastix-1404.patch new file mode 100644 index 0000000000..c98940c05f --- /dev/null +++ b/gnu/packages/patches/elastix-1404.patch @@ -0,0 +1,32 @@ +From b54984063cd61636c57add80522bad23f70bb00a Mon Sep 17 00:00:00 2001 +From: Niels Dekker +Date: Tue, 3 Feb 2026 14:03:06 +0100 +Subject: [PATCH] ENH: Add relative path to lib directory to RPATH on Linux and + MacOS + +Addresses issue #1402, Avoid "error while loading shared libraries" on Linux +--- + Core/CMakeLists.txt | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt +index 3b70abf12..204782b29 100644 +--- a/Core/CMakeLists.txt ++++ b/Core/CMakeLists.txt +@@ -277,8 +277,14 @@ set(ELASTIX_LIBRARIES elastix_lib transformix_lib PARENT_SCOPE) + + if(ELASTIX_BUILD_EXECUTABLE AND NOT WIN32) + # Tell the executables where to find the required .so files. +- set_target_properties(elastix_exe transformix_exe +- PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:${ITK_DIR}") ++ # Supports having the executables in bin, and the .so files in the lib directory next to the bin. ++ if (APPLE) ++ set_target_properties(elastix_exe transformix_exe ++ PROPERTIES BUILD_RPATH "@executable_path/../lib" INSTALL_RPATH "@executable_path/../lib:${CMAKE_INSTALL_PREFIX}/lib:${ITK_DIR}") ++ else() ++ set_target_properties(elastix_exe transformix_exe ++ PROPERTIES BUILD_RPATH "\$ORIGIN/../lib" INSTALL_RPATH "\$ORIGIN/../lib:${CMAKE_INSTALL_PREFIX}/lib:${ITK_DIR}") ++ endif() + endif() + + if(ELASTIX_BUILD_EXECUTABLE AND NOT ELASTIX_NO_INSTALL_EXECUTABLES)