2022-09-01 17:49:38 +00:00
|
|
|
{ version, rev, sourceSha256 }:
|
|
|
|
|
2024-01-17 02:53:44 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake
|
2023-11-06 02:42:59 +00:00
|
|
|
, expat, fftw, gdcm, hdf5-cpp, libjpeg, libminc, libtiff, libpng
|
|
|
|
, libX11, libuuid, xz, vtk, zlib, Cocoa }:
|
2010-03-01 23:31:35 +00:00
|
|
|
|
2023-03-22 17:56:07 +00:00
|
|
|
let
|
itk: enable additional modules
Enable MGHIO, GenericLabelInterpolator, and AdaptiveDenoising ITK modules,
which are required by current versions of ANTs (e.g. 2.3.5 and 2.4.0);
see, e.g., https://github.com/ANTsX/ANTs/issues/1353#issuecomment-1117462739,
the Gentoo ANTs package, or the ANTs SuperBuild itself.
Updating ANTs will, in particular, allow removal of itk4 and vtk_7 from Nixpkgs.
Unfortunately, these ANTs releases do not build against the version of ITK (5.2.1)
current in tree, so we need to either add another ITK 5.x version or wait until ITK
is bumped to 5.3.x (currently still in beta) in Nixpkgs.
2022-08-15 03:29:02 +00:00
|
|
|
itkGenericLabelInterpolatorSrc = fetchFromGitHub {
|
|
|
|
owner = "InsightSoftwareConsortium";
|
|
|
|
repo = "ITKGenericLabelInterpolator";
|
|
|
|
rev = "2f3768110ffe160c00c533a1450a49a16f4452d9";
|
|
|
|
hash = "sha256-Cm3jg14MMnbr/sP+gqR2Rh25xJjoRvpmY/jP/DKH978=";
|
|
|
|
};
|
|
|
|
|
|
|
|
itkAdaptiveDenoisingSrc = fetchFromGitHub {
|
|
|
|
owner = "ntustison";
|
|
|
|
repo = "ITKAdaptiveDenoising";
|
|
|
|
rev = "24825c8d246e941334f47968553f0ae388851f0c";
|
|
|
|
hash = "sha256-deJbza36c0Ohf9oKpO2T4po37pkyI+2wCSeGL4r17Go=";
|
|
|
|
};
|
|
|
|
|
2023-03-22 17:56:07 +00:00
|
|
|
itkSimpleITKFiltersSrc = fetchFromGitHub {
|
|
|
|
owner = "InsightSoftwareConsortium";
|
|
|
|
repo = "ITKSimpleITKFilters";
|
|
|
|
rev = "bb896868fc6480835495d0da4356d5db009592a6";
|
|
|
|
hash = "sha256-MfaIA0xxA/pzUBSwnAevr17iR23Bo5iQO2cSyknS3o4=";
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
pname = "itk";
|
|
|
|
inherit version;
|
|
|
|
|
2019-08-13 15:08:04 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "InsightSoftwareConsortium";
|
|
|
|
repo = "ITK";
|
2022-09-01 17:49:38 +00:00
|
|
|
inherit rev;
|
|
|
|
sha256 = sourceSha256;
|
2010-03-01 23:31:35 +00:00
|
|
|
};
|
|
|
|
|
2024-04-24 16:45:35 +00:00
|
|
|
patches = lib.optionals (lib.versionOlder version "5.4") [
|
2024-01-17 02:53:44 +00:00
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-gcc13-build";
|
|
|
|
url = "https://github.com/InsightSoftwareConsortium/ITK/commit/9a719a0d2f5f489eeb9351b0ef913c3693147a4f.patch";
|
|
|
|
hash = "sha256-dDyqYOzo91afR8W7k2N64X6l7t6Ws1C9iuRkWHUe0fg=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2020-10-15 23:12:18 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace CMake/ITKSetStandardCompilerFlags.cmake \
|
|
|
|
--replace "-march=corei7" "" \
|
|
|
|
--replace "-mtune=native" ""
|
itk: enable additional modules
Enable MGHIO, GenericLabelInterpolator, and AdaptiveDenoising ITK modules,
which are required by current versions of ANTs (e.g. 2.3.5 and 2.4.0);
see, e.g., https://github.com/ANTsX/ANTs/issues/1353#issuecomment-1117462739,
the Gentoo ANTs package, or the ANTs SuperBuild itself.
Updating ANTs will, in particular, allow removal of itk4 and vtk_7 from Nixpkgs.
Unfortunately, these ANTs releases do not build against the version of ITK (5.2.1)
current in tree, so we need to either add another ITK 5.x version or wait until ITK
is bumped to 5.3.x (currently still in beta) in Nixpkgs.
2022-08-15 03:29:02 +00:00
|
|
|
ln -sr ${itkGenericLabelInterpolatorSrc} Modules/External/ITKGenericLabelInterpolator
|
|
|
|
ln -sr ${itkAdaptiveDenoisingSrc} Modules/External/ITKAdaptiveDenoising
|
2023-03-22 17:56:07 +00:00
|
|
|
ln -sr ${itkSimpleITKFiltersSrc} Modules/External/ITKSimpleITKFilters
|
2020-10-15 23:12:18 +00:00
|
|
|
'';
|
|
|
|
|
2014-03-15 00:18:17 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DBUILD_EXAMPLES=OFF"
|
|
|
|
"-DBUILD_SHARED_LIBS=ON"
|
itk: enable additional modules
Enable MGHIO, GenericLabelInterpolator, and AdaptiveDenoising ITK modules,
which are required by current versions of ANTs (e.g. 2.3.5 and 2.4.0);
see, e.g., https://github.com/ANTsX/ANTs/issues/1353#issuecomment-1117462739,
the Gentoo ANTs package, or the ANTs SuperBuild itself.
Updating ANTs will, in particular, allow removal of itk4 and vtk_7 from Nixpkgs.
Unfortunately, these ANTs releases do not build against the version of ITK (5.2.1)
current in tree, so we need to either add another ITK 5.x version or wait until ITK
is bumped to 5.3.x (currently still in beta) in Nixpkgs.
2022-08-15 03:29:02 +00:00
|
|
|
"-DITK_FORBID_DOWNLOADS=ON"
|
2023-11-06 02:42:59 +00:00
|
|
|
"-DITK_USE_SYSTEM_LIBRARIES=ON" # finds common libraries e.g. hdf5, libpng, libtiff, zlib, but not GDCM, NIFTI, MINC, etc.
|
|
|
|
# note ITK_USE_SYSTEM_EIGEN, part of ITK_USE_SYSTEM_LIBRARIES,
|
|
|
|
# causes "...-itk-5.2.1/include/ITK-5.2/itkSymmetricEigenAnalysis.h:23:31: fatal error: Eigen/Eigenvalues: No such file or directory"
|
|
|
|
# when compiling c3d, but maybe an ITK 5.2/eigen version issue:
|
|
|
|
"-DITK_USE_SYSTEM_EIGEN=OFF"
|
|
|
|
"-DITK_USE_SYSTEM_GOOGLETEST=OFF" # ANTs build failure due to https://github.com/ANTsX/ANTs/issues/1489
|
|
|
|
"-DITK_USE_SYSTEM_GDCM=ON"
|
|
|
|
"-DITK_USE_SYSTEM_MINC=ON"
|
|
|
|
"-DLIBMINC_DIR=${libminc}/lib/cmake"
|
2017-09-26 21:59:53 +00:00
|
|
|
"-DModule_ITKMINC=ON"
|
2017-03-02 01:55:42 +00:00
|
|
|
"-DModule_ITKIOMINC=ON"
|
2017-09-26 21:59:53 +00:00
|
|
|
"-DModule_ITKIOTransformMINC=ON"
|
2023-03-22 17:56:07 +00:00
|
|
|
"-DModule_SimpleITKFilters=ON"
|
2017-03-02 01:55:42 +00:00
|
|
|
"-DModule_ITKVtkGlue=ON"
|
|
|
|
"-DModule_ITKReview=ON"
|
itk: enable additional modules
Enable MGHIO, GenericLabelInterpolator, and AdaptiveDenoising ITK modules,
which are required by current versions of ANTs (e.g. 2.3.5 and 2.4.0);
see, e.g., https://github.com/ANTsX/ANTs/issues/1353#issuecomment-1117462739,
the Gentoo ANTs package, or the ANTs SuperBuild itself.
Updating ANTs will, in particular, allow removal of itk4 and vtk_7 from Nixpkgs.
Unfortunately, these ANTs releases do not build against the version of ITK (5.2.1)
current in tree, so we need to either add another ITK 5.x version or wait until ITK
is bumped to 5.3.x (currently still in beta) in Nixpkgs.
2022-08-15 03:29:02 +00:00
|
|
|
"-DModule_MGHIO=ON"
|
|
|
|
"-DModule_AdaptiveDenoising=ON"
|
|
|
|
"-DModule_GenericLabelInterpolator=ON"
|
2014-03-14 22:28:49 +00:00
|
|
|
];
|
2010-03-01 23:31:35 +00:00
|
|
|
|
2023-11-06 02:42:59 +00:00
|
|
|
nativeBuildInputs = [ cmake xz ];
|
|
|
|
buildInputs = [
|
|
|
|
libX11
|
|
|
|
libuuid
|
|
|
|
vtk
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [ Cocoa ];
|
2023-01-27 05:12:38 +00:00
|
|
|
# Due to ITKVtkGlue=ON and the additional dependencies needed to configure VTK 9
|
|
|
|
# (specifically libGL and libX11 on Linux),
|
|
|
|
# it's now seemingly necessary for packages that configure ITK to
|
|
|
|
# also include configuration deps of VTK, even if VTK is not required or available.
|
|
|
|
# These deps were propagated from VTK 9 in https://github.com/NixOS/nixpkgs/pull/206935,
|
|
|
|
# so we simply propagate them again from ITK.
|
|
|
|
# This admittedly is a hack and seems like an issue with VTK 9's CMake configuration.
|
2023-11-06 02:42:59 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
# The dependencies we've un-vendored from ITK, such as GDCM, must be propagated,
|
|
|
|
# otherwise other software built against ITK fails to configure since ITK headers
|
|
|
|
# refer to these previously vendored libraries:
|
|
|
|
expat
|
|
|
|
fftw
|
|
|
|
gdcm
|
|
|
|
hdf5-cpp
|
|
|
|
libjpeg
|
|
|
|
libminc
|
|
|
|
libpng
|
|
|
|
libtiff
|
|
|
|
zlib
|
|
|
|
] ++ vtk.propagatedBuildInputs;
|
2010-03-01 23:31:35 +00:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Insight Segmentation and Registration Toolkit";
|
2024-03-19 02:14:51 +00:00
|
|
|
mainProgram = "itkTestDriver";
|
2023-03-22 17:56:07 +00:00
|
|
|
homepage = "https://www.itk.org";
|
2021-01-21 17:00:13 +00:00
|
|
|
license = lib.licenses.asl20;
|
|
|
|
maintainers = with lib.maintainers; [viric];
|
2010-03-01 23:31:35 +00:00
|
|
|
};
|
|
|
|
}
|