summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/dicom2nifti/default.nix
blob: 034aed37401ca8a1972bdf5c3e7855aae2b7a03d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  setuptools,

  # dependencies
  gdcm,
  nibabel,
  numpy,
  pydicom,
  scipy,

  # tests
  pillow,
  pylibjpeg,
  pylibjpeg-libjpeg,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "dicom2nifti";
  version = "2.6.2";
  pyproject = true;

  # no tests in PyPI dist
  src = fetchFromGitHub {
    owner = "icometrix";
    repo = "dicom2nifti";
    tag = version;
    hash = "sha256-VS1ad7sAgVWkFkTPLxzloj0dvweW5wqBlQpFqD9uZLs=";
  };

  postPatch = ''
    substituteInPlace tests/test_generic.py --replace-fail "from common" "from dicom2nifti.common"
    substituteInPlace tests/test_ge.py --replace-fail "import convert_generic" "import dicom2nifti.convert_generic as convert_generic"
  '';

  build-system = [ setuptools ];

  dependencies = [
    gdcm
    nibabel
    numpy
    pydicom
    scipy
  ];

  pythonImportsCheck = [ "dicom2nifti" ];

  nativeCheckInputs = [
    pillow
    pylibjpeg
    pylibjpeg-libjpeg
    pytestCheckHook
  ];

  disabledTests = [
    # OverflowError: Python integer -1024 out of bounds for uint16
    "test_not_a_volume"
    "test_resampling"
    "test_validate_orthogonal_disabled"

    # RuntimeError: Unable to decompress 'JPEG 2000 Image Compression (Lossless O...
    "test_anatomical"
    "test_compressed_j2k"
    "test_main_function"
    "test_rgb"

    # Missing script 'dicom2nifti_scrip'
    "test_gantry_option"
    "test_gantry_resampling"
  ];

  meta = {
    homepage = "https://github.com/icometrix/dicom2nifti";
    description = "Library for converting dicom files to nifti";
    mainProgram = "dicom2nifti";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ bcdarwin ];
  };
}