1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonOlder,
6
7 # build system
8 setuptools,
9 setuptools-scm,
10
11 # dependencies
12 numpy,
13 scikit-image,
14 torchvision,
15 torch,
16 runstats,
17 pytorch-lightning,
18 h5py,
19 pyyaml,
20 torchmetrics,
21 pandas,
22
23 # tests
24 pytestCheckHook,
25}:
26
27buildPythonPackage rec {
28 pname = "fastmri";
29 version = "0.3.0";
30 pyproject = true;
31
32 disabled = pythonOlder "3.8";
33
34 src = fetchFromGitHub {
35 owner = "facebookresearch";
36 repo = "fastMRI";
37 tag = "v${version}";
38 hash = "sha256-0IJV8OhY5kPWQwUYPKfmdI67TyYzDAPlwohdc0jWcV4=";
39 };
40
41 # banding_removal folder also has a subfolder named "fastmri"
42 # and np.product is substituted with np.prod in new numpy versions
43 postPatch = ''
44 substituteInPlace tests/test_math.py \
45 --replace-fail "np.product" "np.prod"
46 substituteInPlace tests/conftest.py \
47 --replace-fail "np.product" "np.prod"
48
49 rm -rf banding_removal
50 '';
51
52 build-system = [
53 setuptools
54 setuptools-scm
55 ];
56
57 dependencies = [
58 numpy
59 scikit-image
60 torchvision
61 torch
62 runstats
63 pytorch-lightning
64 h5py
65 pyyaml
66 torchmetrics
67 pandas
68 ];
69
70 nativeCheckInputs = [ pytestCheckHook ];
71
72 disabledTestPaths = [
73 # much older version of pytorch-lightning is used
74 "tests/test_modules.py"
75 ];
76
77 pythonImportsCheck = [ "fastmri" ];
78
79 meta = {
80 description = "Pytorch-based MRI reconstruction tooling";
81 homepage = "https://github.com/facebookresearch/fastMRI";
82 changelog = "https://github.com/facebookresearch/fastMRI/releases/tag/v${version}";
83 license = lib.licenses.mit;
84 maintainers = with lib.maintainers; [ osbm ];
85 };
86}