1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonOlder,
6 pytestCheckHook,
7 gdcm,
8 nibabel,
9 numpy,
10 pydicom,
11 scipy,
12 setuptools,
13}:
14
15buildPythonPackage rec {
16 pname = "dicom2nifti";
17 version = "2.4.11";
18 pyproject = true;
19
20 disabled = pythonOlder "3.6";
21
22 # no tests in PyPI dist
23 src = fetchFromGitHub {
24 owner = "icometrix";
25 repo = pname;
26 rev = "refs/tags/${version}";
27 hash = "sha256-/JauQZcCQDl1ukcSE3YPbf1SyhVxDNJUlqnFwdlwYQY=";
28 };
29
30 build-system = [ setuptools ];
31
32 propagatedBuildInputs = [
33 gdcm
34 nibabel
35 numpy
36 pydicom
37 scipy
38 ];
39
40 # python-gdcm just builds the python interface provided by the "gdcm" package, so
41 # we should be able to replace "python-gdcm" with "gdcm" but this doesn't work
42 # (similar to https://github.com/NixOS/nixpkgs/issues/84774)
43 postPatch = ''
44 substituteInPlace setup.py --replace-fail "python-gdcm" ""
45 substituteInPlace tests/test_generic.py --replace-fail "from common" "from dicom2nifti.common"
46 substituteInPlace tests/test_ge.py --replace-fail "import convert_generic" "import dicom2nifti.convert_generic as convert_generic"
47 '';
48
49 nativeCheckInputs = [ pytestCheckHook ];
50
51 pythonImportsCheck = [ "dicom2nifti" ];
52
53 meta = with lib; {
54 homepage = "https://github.com/icometrix/dicom2nifti";
55 description = "Library for converting dicom files to nifti";
56 mainProgram = "dicom2nifti";
57 license = licenses.mit;
58 maintainers = with maintainers; [ bcdarwin ];
59 };
60}