gnu: emacs-sly: Update to 20200228.
[jackhill/guix/guix.git] / gnu / packages / image-processing.scm
index 792259c..f5d67c8 100644 (file)
@@ -1,10 +1,10 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 John Darrington <jmd@gnu.org>
-;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2017, 2019 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
-;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
 ;;; Copyright © 2018 Lprndn <guix@lprndn.info>
 ;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
   #:use-module (guix packages)
   #:use-module (guix utils)
   #:use-module (guix download)
+  #:use-module (guix git-download)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
   #:use-module (gnu packages)
   #:use-module (gnu packages algebra)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
+  #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages curl)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages flex)
   #:use-module (gnu packages fontutils)
+  #:use-module (gnu packages geo)
   #:use-module (gnu packages ghostscript)
   #:use-module (gnu packages gl)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages protobuf)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages python-xyz)
+  #:use-module (gnu packages qt)
   #:use-module (gnu packages serialization)
+  #:use-module (gnu packages tbb)
+  #:use-module (gnu packages tls)
   #:use-module (gnu packages video)
   #:use-module (gnu packages xiph)
   #:use-module (gnu packages xml)
-  #:use-module (gnu packages xorg))
+  #:use-module (gnu packages xorg)
+  #:use-module (ice-9 match)
+  #:use-module (srfi srfi-1))
 
-;; We use the latest snapshot of this package because the latest release is
-;; from 2011 and has known vulnerabilities that cannot easily be fixed by
-;; applying patches.
 (define-public dcmtk
   (package
     (name "dcmtk")
-    (version "3.6.1_20170228")
-    (source (origin
-              (method url-fetch)
-              (uri (string-append "ftp://dicom.offis.de/pub/dicom/offis/"
-                                  "software/dcmtk/snapshot/dcmtk-"
-                                  version ".tar.gz"))
-              (sha256
-               (base32
-                "04cwfx8yrscqcd59mxk2fh6314ckayi9cp68iql5a57pf2pg5qld"))))
-    (build-system gnu-build-system)
+    (version "3.6.5")
+    (source
+     (origin
+       (method url-fetch)
+       (uri
+        (string-append "ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/"
+                       "dcmtk" (string-join (string-split version #\.) "")
+                       "/dcmtk-" version ".tar.gz"))
+       (sha256
+        (base32 "1fdyz5wwjp4grys61mxb2ia9fi6i3ax6s43l16xnv291bxk7hld0"))))
+    (build-system cmake-build-system)
     (inputs
-     `(("libtiff" ,libtiff)
+     `(;; Our ICU is too recent: “error: ‘UChar’ does not name a type“.
+       ;; ("icu4c" ,icu4c)
+       ("libjpeg" ,libjpeg)
        ("libpng" ,libpng)
-       ("doxygen" ,doxygen)
+       ("libtiff" ,libtiff)
+       ("libxml2" ,libxml2)
+       ("openssl" ,openssl)
        ("zlib" ,zlib)))
     (native-inputs
-     `(("perl" ,perl)))
-    (home-page "http://dcmtk.org")
+     `(("doxygen" ,doxygen)))           ; for HTML documentation
+    (home-page "https://dcmtk.org")
     (synopsis "Libraries and programs implementing parts of the DICOM standard")
     (description "DCMTK is a collection of libraries and applications
 implementing large parts the DICOM standard.  It includes software for
@@ -152,15 +164,15 @@ of external libraries that provide additional functionality.")
 (define-public vtk
   (package
     (name "vtk")
-    (version "7.1.0")
+    (version "8.2.0")
     (source (origin
               (method url-fetch)
-              (uri (string-append "http://www.vtk.org/files/release/"
+              (uri (string-append "https://vtk.org/files/release/"
                                   (version-major+minor version)
                                   "/VTK-" version ".tar.gz"))
               (sha256
                (base32
-                "0yj96z58haan77gzilnqp7xpf8hg5jk11a3jx55p2ksd400s0gjz"))))
+                "1fspgp8k0myr6p2a6wkc21ldcswb4bvmb484m12mxgk1a9vxrhrl"))))
     (build-system cmake-build-system)
     (arguments
      '(#:build-type "Release"           ;Build without '-g' to save space.
@@ -193,7 +205,7 @@ of external libraries that provide additional functionality.")
        ("png" ,libpng)
        ("tiff" ,libtiff)
        ("zlib" ,zlib)))
-    (home-page "http://www.vtk.org/")
+    (home-page "https://vtk.org/")
     (synopsis "Libraries for 3D computer graphics")
     (description
      "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
@@ -206,18 +218,35 @@ a suite of 3D interaction widgets, supports parallel processing, and
 integrates with various databases on GUI toolkits such as Qt and Tk.")
     (license license:bsd-3)))
 
+;; itksnap needs an older variant of VTK.
+(define-public vtk-6
+  (package (inherit vtk)
+    (version "6.3.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://vtk.org/files/release/"
+                                  (version-major+minor version)
+                                  "/VTK-" version ".tar.gz"))
+              (sha256
+               (base32
+                "0pla1r5mvkgl4sl213gfdhzrypdgai0h3z5mfgm6p9jz9hsr794j"))))
+    (inputs
+     `(("jsoncpp" ,jsoncpp-for-tensorflow)
+       ,@(alist-delete "jsoncpp" (package-inputs vtk))))))
+
 (define-public opencv
   (package
     (name "opencv")
     (version "3.4.3")
     (source (origin
-              (method url-fetch)
-              (uri (string-append "https://github.com/opencv/opencv/archive/"
-                                  version ".zip"))
-              (file-name (string-append name "-" version ".zip"))
+              (method git-fetch)
+              (uri (git-reference
+                     (url "https://github.com/opencv/opencv")
+                     (commit version)))
+              (file-name (git-file-name name version))
               (sha256
                (base32
-                "0pycx1pz8lj794q32mlalyc3ijqxwsyin65r26nh4yc0p71xiirp"))
+                "06bc61r8myym4s8im10brdjfg4wxkrvsbhhl7vr1msdan2xddzi3"))
               (modules '((guix build utils)))
               (snippet
                '(begin
@@ -230,7 +259,8 @@ integrates with various databases on GUI toolkits such as Qt and Tk.")
                   ;; Some jars found:
                   (for-each delete-file
                             '("modules/java/test/pure_test/lib/junit-4.11.jar"
-                              "samples/java/sbt/sbt/sbt-launch.jar"))))))
+                              "samples/java/sbt/sbt/sbt-launch.jar"))
+                  #t))))
     (build-system cmake-build-system)
     (arguments
      `(#:configure-flags
@@ -244,26 +274,29 @@ integrates with various databases on GUI toolkits such as Qt and Tk.")
              ;; (CPU_ALL_OPTIMIZATIONS) for a list of all optimizations
              ;; BASELINE is the minimum optimization all CPUs must support
              ;;
-             ;; DISPATCH is the list of optional dispatches. We add them all.
-             "-DCPU_BASELINE=SSE2, NEON"
+             ;; DISPATCH is the list of optional dispatches.
+             "-DCPU_BASELINE=SSE2"
 
-             "-DCPU_DISPATCH=NEON;VFPV3;FP16;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX"
-             ,@(if (string-prefix? "x86_64" (or (%current-target-system)
-                                                (%current-system)))
-                   '("-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2")
-                   '())
+             ,@(match (%current-system)
+                 ("x86_64-linux"
+                  '("-DCPU_DISPATCH=NEON;VFPV3;FP16;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX"
+                    "-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2"))
+                 ("armhf-linux"
+                  '("-DCPU_BASELINE_DISABLE=NEON")) ; causes build failures
+                 ("aarch64-linux"
+                  '("-DCPU_BASELINE=NEON"
+                    "-DCPU_DISPATCH=NEON;VFPV3;FP16"))
+                 (_ '()))
 
              "-DBUILD_PERF_TESTS=OFF"
              "-DBUILD_TESTS=ON"
 
              (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
-                            "/opencv-contrib/opencv_contrib-" ,version
-                            "/modules")
+                            "/opencv-contrib/modules")
 
              ;;Define test data:
              (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
-                            "/opencv-extra/opencv_extra-" ,version
-                            "/testdata")
+                            "/opencv-extra/testdata")
 
              ;; Is ON by default and would try to rebuild 3rd-party protobuf,
              ;; which we had removed, which would lead to an error:
@@ -296,35 +329,28 @@ integrates with various databases on GUI toolkits such as Qt and Tk.")
 
              ;; This one fails with "unknown file: Failure"
              ;; But I couldn't figure out which file was missing:
-             (substitute* (list (string-append
-                                 "../opencv-contrib/opencv_contrib-"
-                                 ,version
-                                 "/modules/face/test/test_face_align.cpp"))
+             (substitute* "../opencv-contrib/modules/face/test/test_face_align.cpp"
                (("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)"
                  all pre post)
                 (string-append pre "DISABLED_" post)))
 
              ;; Failure reason: Bad accuracy
              ;; Incorrect count of accurate poses [2nd case]: 90.000000 / 94.000000
-             (substitute* (list (string-append
-                                 "../opencv-contrib/opencv_contrib-"
-                                 ,version
-                                 "/modules/rgbd/test/test_odometry.cpp"))
+             (substitute* "../opencv-contrib/modules/rgbd/test/test_odometry.cpp"
                (("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post)
                 (string-append pre "DISABLED_" post)))
              #t))
 
-         ;; Idea copied from ldc.scm (ldc-bootstrap):
          (add-after 'unpack 'unpack-submodule-sources
            (lambda* (#:key inputs #:allow-other-keys)
              (mkdir "../opencv-extra")
              (mkdir "../opencv-contrib")
-             (let ((unpack (lambda (source target)
-                             (with-directory-excursion target
-                               (apply invoke "unzip"
-                                      (list (assoc-ref inputs source)))))))
-               (unpack "opencv-extra" "../opencv-extra")
-               (unpack "opencv-contrib" "../opencv-contrib"))))
+             (copy-recursively (assoc-ref inputs "opencv-extra")
+                               "../opencv-extra")
+             (invoke "tar" "xvf"
+                     (assoc-ref inputs "opencv-contrib")
+                     "--strip-components=1"
+                     "-C" "../opencv-contrib")))
 
          (add-after 'set-paths 'add-ilmbase-include-path
            (lambda* (#:key inputs #:allow-other-keys)
@@ -346,25 +372,27 @@ integrates with various databases on GUI toolkits such as Qt and Tk.")
              ;; Therefore we must do it.
              (zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp)))))))))
     (native-inputs
-     `(("unzip" ,unzip)
-       ("pkg-config" ,pkg-config)
-       ("xorg-server" ,xorg-server) ; For running the tests
+     `(("pkg-config" ,pkg-config)
+       ("xorg-server" ,xorg-server-for-tests) ; For running the tests
        ("opencv-extra"
         ,(origin
-           (method url-fetch)
-           (uri (string-append "https://codeload.github.com/"
-                               "opencv/opencv_extra/zip/" version))
-           (file-name (string-append "opencv-extra-" version ".zip"))
+           (method git-fetch)
+           (uri (git-reference
+                  (url "https://github.com/opencv/opencv_extra")
+                  (commit version)))
+           (file-name (git-file-name "opencv_extra" version))
            (sha256
-            (base32 "0yd1vidzbg6himxyh4yzivywijg8548kfmcn421khabnipm7l74y"))))
+            (base32 "08p5xnq8n1jw8svvz0fnirfg7q8dm3p4a5dl7527s5xj0f9qn7lp"))))
        ("opencv-contrib"
         ,(origin
-           (method url-fetch)
-           (uri (string-append "https://codeload.github.com/"
-                               "opencv/opencv_contrib/zip/" version))
-           (file-name (string-append "opencv-contrib-" version ".zip"))
+           (method git-fetch)
+           (uri (git-reference
+                  (url "https://github.com/opencv/opencv_contrib")
+                  (commit version)))
+           (file-name (git-file-name "opencv_contrib" version))
+           (patches (search-patches "opencv-rgbd-aarch64-test-fix.patch"))
            (sha256
-           (base32 "0j0ci6ia1qwklp9hq07ypl0vkngj1wrgh6n98n657m5d0pyp4m0g"))))))
+            (base32 "1f334glf39nk42mpqq6j732h3ql2mpz89jd4mcl678s8n73nfjh2"))))))
     (inputs `(("libjpeg" ,libjpeg)
               ("libpng" ,libpng)
               ("jasper" ,jasper)
@@ -411,14 +439,15 @@ vision algorithms.  It can be used to do things like:
 (define-public vips
   (package
     (name "vips")
-    (version "8.7.1")
-    (source (origin
-              (method url-fetch)
-              (uri (string-append
-                    "https://github.com/libvips/libvips/releases/download/v"
-                    version "/vips-" version ".tar.gz"))
-              (sha256
-               (base32 "1w3b90pdw7nj2p0gb4f96h6zhmga513f968ldfhz1rkhg7y81c0s"))))
+    (version "8.7.4")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "https://github.com/libvips/libvips/releases/download/v"
+             version "/vips-" version ".tar.gz"))
+       (sha256
+        (base32 "01gjhcrl6zj7mcj1al717v5jsniahplqhz1xkfh2j78vyfl1hxff"))))
     (build-system gnu-build-system)
     (native-inputs
      `(("pkg-config" ,pkg-config)
@@ -446,27 +475,33 @@ vision algorithms.  It can be used to do things like:
        ("expat" ,expat)
        ("hdf5" ,hdf5)))
     (home-page "https://libvips.github.io/libvips/")
-    (synopsis "Image processing system")
+    (synopsis "Multithreaded image processing system with low memory needs")
     (description
-     "vips is a demand-driven, horizontally threaded image processing library.")
+     "VIPS is a demand-driven, horizontally threaded image processing library.
+It's particularly good at processing large images, working with colour,
+scientific analysis, and general research & development.
+
+Compared to most image processing libraries VIPS needs little RAM and runs
+quickly, especially on machines with more than one CPU core.  This is primarily
+due to its architecture which automatically parallelises the image workflows.")
     (license license:lgpl2.1+)))
 
 (define-public nip2
   (package
     (name "nip2")
-    (version "8.7.0")
+    (version "8.7.1")
     (source
      (origin
        (method url-fetch)
        (uri (string-append "https://github.com/libvips/nip2/releases/download/v"
                            version "/nip2-" version ".tar.gz" ))
        (sha256
-        (base32 "08dxfds4n1vxdilxcw01741a2r6fxyhawi656b7f0hy6znnkbsbc"))))
+        (base32 "0l7n427njif53npqn02gfjjly8y3khbrkzqxp10j5vp9h97psgiw"))))
     (build-system gnu-build-system)
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         ;; test_conv.ws keep failing so disabling for now
+         ;; test_conv.ws keep failing so disabling for now.
          (add-after 'unpack 'disable-test-conv
            (lambda _
              (delete-file "test/workspaces/test_conv.ws")
@@ -481,7 +516,7 @@ vision algorithms.  It can be used to do things like:
        ("gtk+-2" ,gtk+-2)
        ("libxml2" ,libxml2)
        ("libexif" ,libexif)
-       ("libjpeg" ,libjpeg)                       ;required by vips.pc
+       ("libjpeg" ,libjpeg)             required by vips.pc
        ("librsvg" ,librsvg)
        ("fftw" ,fftw)
        ("libgsf" ,libgsf)
@@ -504,3 +539,304 @@ the VIPS image processing library.  It's a little like a spreadsheet: you
 create a set of formula connecting your objects together, and on a change nip2
 recalculates.")
     (license license:gpl2+)))
+
+(define-public vxl
+  (package
+    (name "vxl")
+    (version "2.0.2")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/vxl/vxl.git")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0949hw57szq8943f1whwqaz591xjmb19kj803hcv74hdai2b0ycg"))
+       (modules '((guix build utils)))
+       ;; TODO: vxl includes an old version of dcmtk.  It won't build with
+       ;; version 3.6.x.
+       (snippet
+        '(begin
+           (for-each delete-file-recursively
+                     '("v3p/bzlib/"
+                       "v3p/geotiff/"
+                       "v3p/jpeg/"
+                       "v3p/png/"
+                       "v3p/tiff/"
+                       "v3p/zlib/"))
+           (substitute* "v3p/CMakeLists.txt"
+             (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
+              ""))
+           #t))))
+    (build-system cmake-build-system)
+    (inputs
+     `(("libgeotiff" ,libgeotiff)
+       ("libtiff" ,libtiff)
+       ("libjpeg" ,libjpeg)
+       ("libpng" ,libpng)
+       ("zlib" ,zlib)))
+    (home-page "https://github.com/vxl/vxl/")
+    (synopsis "Collection of C++ libraries for computer vision")
+    (description "VXL (the Vision-something-Libraries) is a collection of C++
+libraries designed for computer vision research and implementation.")
+    (license license:bsd-3)))
+
+(define-public vxl-1
+  (package (inherit vxl)
+    (name "vxl")
+    (version "1.18.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/vxl/vxl.git")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1g4mr2cc58jwm0vasscbd4y5380wj3ahkvq121z4gs83fhavvxgz"))
+       (modules '((guix build utils)))
+       (snippet
+        '(begin
+           (for-each delete-file-recursively
+                     '("v3p/bzlib/"
+                       "v3p/geotiff/"
+                       "v3p/png/"
+                       "v3p/tiff/"
+                       "v3p/zlib/"))
+           (substitute* "v3p/CMakeLists.txt"
+             (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
+              ""))
+           #t))))
+    (arguments
+     `(#:configure-flags
+       ;; Needed for itk-snap
+       (list "-DVNL_CONFIG_LEGACY_METHODS=ON")))))
+
+(define-public insight-toolkit
+  (package
+    (name "insight-toolkit")
+    (version "5.0.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/InsightSoftwareConsortium/ITK/"
+                           "releases/download/v" version "/InsightToolkit-"
+                           version ".tar.xz"))
+       (sha256
+        (base32 "0bs63mk4q8jmx38f031jy5w5n9yy5ng9x8ijwinvjyvas8cichqi"))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:tests? #f            ; tests require network access and external data
+       #:configure-flags
+       '("-DITK_USE_GPU=ON"
+         "-DITK_USE_SYSTEM_LIBRARIES=ON"
+         "-DITK_USE_SYSTEM_GOOGLETEST=ON"
+         "-DITK_BUILD_SHARED=ON"
+         ;; This prevents "GTest::GTest" from being added to the ITK_LIBRARIES
+         ;; variable in the installed CMake files.  This is necessary as other
+         ;; packages using insight-toolkit could not be configured otherwise.
+         "-DGTEST_ROOT=gtest")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'do-not-tune
+           (lambda _
+             (substitute* "CMake/ITKSetStandardCompilerFlags.cmake"
+               (("-mute=native") ""))
+             #t)))))
+    (inputs
+     `(("eigen" ,eigen)
+       ("expat" ,expat)
+       ("fftw" ,fftw)
+       ("fftwf" ,fftwf)
+       ("hdf5" ,hdf5)
+       ("libjpeg" ,libjpeg)
+       ("libpng" ,libpng)
+       ("libtiff" ,libtiff)
+       ("mesa" ,mesa-opencl)
+       ("perl" ,perl)
+       ("python" ,python)
+       ("tbb" ,tbb)
+       ("vxl" ,vxl-1)
+       ("zlib" ,zlib)))
+    (native-inputs
+     `(("googletest" ,googletest)
+       ("pkg-config" ,pkg-config)))
+    (home-page "https://github.com/InsightSoftwareConsortium/ITK/")
+    (synopsis "Scientific image processing, segmentation and registration")
+    (description "The Insight Toolkit (ITK) is a toolkit for N-dimensional
+scientific image processing, segmentation, and registration.  Segmentation is
+the process of identifying and classifying data found in a digitally sampled
+representation.  Typically the sampled representation is an image acquired
+from such medical instrumentation as CT or MRI scanners.  Registration is the
+task of aligning or developing correspondences between data.  For example, in
+the medical environment, a CT scan may be aligned with a MRI scan in order to
+combine the information contained in both.")
+    (license license:asl2.0)))
+
+(define-public insight-toolkit-4
+  (package (inherit insight-toolkit)
+    (version "4.13.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/InsightSoftwareConsortium/ITK/"
+                           "releases/download/v" version "/InsightToolkit-"
+                           version ".tar.xz"))
+       (sha256
+        (base32 "19cgfpd63gqrvc3m27m394gy2d7w79g5y6lvznb5qqr49lihbgns"))))
+    (arguments
+     `(#:tests? #f            ; tests require network access and external data
+       #:configure-flags
+       '("-DITKV3_COMPATIBILITY=ON"     ; needed for itk-snap
+         "-DITK_USE_GPU=ON"
+         "-DITK_USE_SYSTEM_LIBRARIES=ON"
+         "-DITK_USE_SYSTEM_GOOGLETEST=ON"
+         "-DITK_USE_SYSTEM_VXL=ON")))))
+
+(define-public insight-toolkit-4.12
+  (package (inherit insight-toolkit-4)
+    (version "4.12.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "mirror://sourceforge/itk/itk/4.12/"
+                           "InsightToolkit-" version ".tar.xz"))
+       (sha256
+        (base32 "1qw9mxbh083siljygahl4gdfv91xvfd8hfl7ghwii19f60xrvn2w"))))))
+
+(define-public itk-snap
+  (package
+    (name "itk-snap")
+    (version "3.8.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.code.sf.net/p/itk-snap/src")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "15i5ixpryfrbf3vrrb5rici8fb585f25k0v1ljds16bp1f1msr4q"))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:configure-flags
+       (list "-DSNAP_VERSION_GIT_SHA1=release"
+             "-DSNAP_VERSION_GIT_BRANCH=release"
+             "-DSNAP_VERSION_GIT_TIMESTAMP=0"
+             "-DSNAP_PACKAGE_QT_PLUGINS=OFF"
+             "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
+       #:phases
+       (modify-phases %standard-phases
+         ;; During the installation phase all libraries provided by all
+         ;; dependencies will be copied to the lib directory.  That's insane,
+         ;; so we disable this.
+         (add-after 'unpack 'do-not-copy-dependencies
+           (lambda _
+             (substitute* "CMakeLists.txt"
+               (("install_qt5_executable\
+\\(\\$\\{SNAP_MAIN_INSTALL_DIR\\}/\\$\\{SNAP_EXE\\}\\)")
+                ""))
+             #t))
+         (add-after 'unpack 'disable-gui-tests
+           (lambda _
+             ;; The GUI tests just time out.
+             (substitute* "CMakeLists.txt"
+               (("  (Workspace|DiffSpace|ProbeIntensity|RegionCompetition\
+|RandomForest|RandomForestBailOut)")
+                ""))
+             #t))
+         (add-after 'unpack 'make-reproducible
+           (lambda _
+             (substitute* "CMakeLists.txt"
+               (("TODAY\\(SNAP_VERSION_COMPILE_DATE\\)")
+                "SET(SNAP_VERSION_COMPILE_DATE \"(removed for reproducibility)\")"))
+             #t))
+         (add-after 'unpack 'prepare-submodules
+           (lambda* (#:key inputs #:allow-other-keys)
+             (rmdir "Submodules/c3d")
+             (copy-recursively (assoc-ref inputs "c3d-src")
+                               "Submodules/c3d")
+             (substitute* '("Submodules/c3d/adapters/BiasFieldCorrectionN4.cxx"
+                            "Submodules/c3d/adapters/ApplyMetric.cxx")
+               (("vcl_") "std::"))
+             (rmdir "Submodules/greedy")
+             (symlink (assoc-ref inputs "greedy-src")
+                      "Submodules/greedy")
+             #t))
+         (add-after 'unpack 'fix-includes
+           (lambda _
+             (substitute* "GUI/Model/RegistrationModel.cxx"
+               (("<vnl_symmetric_eigensystem.h>")
+                "<vnl/algo/vnl_symmetric_eigensystem.h>"))
+             #t))
+         (add-before 'check 'prepare-tests
+           (lambda _
+             ;; Needed by at least one test.
+             (setenv "HOME" "/tmp")
+             #t))
+         (add-after 'install 'wrap-executable
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (wrap-program (string-append out "/bin/itksnap")
+                 `("QT_PLUGIN_PATH" ":" prefix
+                   ,(map (lambda (label)
+                           (string-append (assoc-ref inputs label)
+                                          "/lib/qt5/plugins"))
+                         '("qtbase" "qtdeclarative"))))
+               #t))))))
+    (inputs
+     `(("curl" ,curl)
+       ("fftw" ,fftw)
+       ("fftwf" ,fftwf)
+       ("glu" ,glu)
+       ("hdf5" ,hdf5)
+       ("mesa" ,mesa-opencl)
+       ;; This package does not build with either insight-toolkit 5.0.0 and
+       ;; not with 4.13.  It really needs to be 4.12.
+       ("itk" ,insight-toolkit-4.12)
+       ("vtk" ,vtk-6)
+       ("qtbase" ,qtbase)
+       ("qtdeclarative" ,qtdeclarative)
+       ("qttools" ,qttools)
+       ("vxl" ,vxl-1)
+       ("zlib" ,zlib)))
+    (native-inputs
+     `(("googletest" ,googletest)
+       ("pkg-config" ,pkg-config)
+       ("c3d-src"
+        ,(let* ((commit "f521358db26e00002c911cc47bf463b043942ad3")
+                (revision "1")
+                (version (git-version "0" revision commit)))
+           (origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/pyushkevich/c3d.git")
+                   (commit commit)))
+             (file-name (git-file-name "c3d" version))
+             (sha256
+              (base32
+               "0kyv3rxrxwr8c3sa9zv01lsnhk95b27gx1s870k3yi8qp52h7bx3")))))
+       ;; We are using an arbitrary commit from 2017 because the latest
+       ;; version breaks the build...
+       ("greedy-src"
+        ,(let* ((commit "97e340f7e8e66597599144947775e6039e79a0d3")
+                (revision "1")
+                (version (git-version "0" revision commit)))
+           (origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/pyushkevich/greedy.git")
+                   (commit commit)))
+             (file-name (git-file-name "greedy" version))
+             (sha256
+              (base32
+               "0k5bc9za4jrc8z9dj08z1rkcp5xf0gnd1d2jmi1w9ny4vxh2q2ab")))))))
+    (home-page "https://sourceforge.net/p/itk-snap/")
+    (synopsis "Medical image segmentation")
+    (description "ITK-SNAP is a tool for segmenting anatomical structures in
+medical images.  It provides an automatic active contour segmentation
+pipeline, along with supporting a manual segmentation toolbox.  ITK-SNAP has a
+full-featured UI aimed at clinical researchers.")
+    ;; This includes the submodules greedy and c3d.
+    (license license:gpl3+)))