cornucopia 0.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cornucopia-0.0.0/LICENSE +21 -0
- cornucopia-0.0.0/PKG-INFO +92 -0
- cornucopia-0.0.0/README.md +62 -0
- cornucopia-0.0.0/cornucopia/__init__.py +73 -0
- cornucopia-0.0.0/cornucopia/base.py +1915 -0
- cornucopia-0.0.0/cornucopia/baseutils.py +575 -0
- cornucopia-0.0.0/cornucopia/contrast.py +260 -0
- cornucopia-0.0.0/cornucopia/ctx.py +25 -0
- cornucopia-0.0.0/cornucopia/fov.py +707 -0
- cornucopia-0.0.0/cornucopia/geometric.py +2068 -0
- cornucopia-0.0.0/cornucopia/intensity.py +1358 -0
- cornucopia-0.0.0/cornucopia/io.py +161 -0
- cornucopia-0.0.0/cornucopia/kspace.py +505 -0
- cornucopia-0.0.0/cornucopia/labels.py +1872 -0
- cornucopia-0.0.0/cornucopia/noise.py +508 -0
- cornucopia-0.0.0/cornucopia/psf.py +463 -0
- cornucopia-0.0.0/cornucopia/qmri.py +1288 -0
- cornucopia-0.0.0/cornucopia/random.py +1480 -0
- cornucopia-0.0.0/cornucopia/special.py +159 -0
- cornucopia-0.0.0/cornucopia/synth.py +708 -0
- cornucopia-0.0.0/cornucopia/tests/__init__.py +0 -0
- cornucopia-0.0.0/cornucopia/tests/test_backward_geometric.py +173 -0
- cornucopia-0.0.0/cornucopia/tests/test_backward_intensity.py +243 -0
- cornucopia-0.0.0/cornucopia/tests/test_backward_kspace.py +115 -0
- cornucopia-0.0.0/cornucopia/tests/test_backward_noise.py +169 -0
- cornucopia-0.0.0/cornucopia/tests/test_backward_psf.py +142 -0
- cornucopia-0.0.0/cornucopia/tests/test_backward_qmri.py +249 -0
- cornucopia-0.0.0/cornucopia/tests/test_backward_random.py +44 -0
- cornucopia-0.0.0/cornucopia/tests/test_backward_synth.py +72 -0
- cornucopia-0.0.0/cornucopia/tests/test_base.py +401 -0
- cornucopia-0.0.0/cornucopia/tests/test_geometric.py +26 -0
- cornucopia-0.0.0/cornucopia/tests/test_intensity.py +9 -0
- cornucopia-0.0.0/cornucopia/tests/test_random.py +722 -0
- cornucopia-0.0.0/cornucopia/tests/test_run_contrast.py +28 -0
- cornucopia-0.0.0/cornucopia/tests/test_run_fov.py +132 -0
- cornucopia-0.0.0/cornucopia/tests/test_run_geometric.py +157 -0
- cornucopia-0.0.0/cornucopia/tests/test_run_intensity.py +192 -0
- cornucopia-0.0.0/cornucopia/tests/test_run_kspace.py +70 -0
- cornucopia-0.0.0/cornucopia/tests/test_run_labels.py +224 -0
- cornucopia-0.0.0/cornucopia/tests/test_run_noise.py +127 -0
- cornucopia-0.0.0/cornucopia/tests/test_run_psf.py +115 -0
- cornucopia-0.0.0/cornucopia/tests/test_run_qmri.py +114 -0
- cornucopia-0.0.0/cornucopia/tests/test_run_synth.py +67 -0
- cornucopia-0.0.0/cornucopia/typing.py +97 -0
- cornucopia-0.0.0/cornucopia/utils/__init__.py +0 -0
- cornucopia-0.0.0/cornucopia/utils/b0.py +745 -0
- cornucopia-0.0.0/cornucopia/utils/bounds.py +412 -0
- cornucopia-0.0.0/cornucopia/utils/compat.py +47 -0
- cornucopia-0.0.0/cornucopia/utils/conv.py +305 -0
- cornucopia-0.0.0/cornucopia/utils/gmm.py +169 -0
- cornucopia-0.0.0/cornucopia/utils/indexing.py +911 -0
- cornucopia-0.0.0/cornucopia/utils/io.py +258 -0
- cornucopia-0.0.0/cornucopia/utils/jit.py +128 -0
- cornucopia-0.0.0/cornucopia/utils/kernels.py +288 -0
- cornucopia-0.0.0/cornucopia/utils/morpho.py +234 -0
- cornucopia-0.0.0/cornucopia/utils/mrf.py +574 -0
- cornucopia-0.0.0/cornucopia/utils/padding.py +173 -0
- cornucopia-0.0.0/cornucopia/utils/patch.py +302 -0
- cornucopia-0.0.0/cornucopia/utils/pool.py +282 -0
- cornucopia-0.0.0/cornucopia/utils/py.py +348 -0
- cornucopia-0.0.0/cornucopia/utils/smart_inplace.py +163 -0
- cornucopia-0.0.0/cornucopia/utils/version.py +57 -0
- cornucopia-0.0.0/cornucopia/utils/warps.py +606 -0
- cornucopia-0.0.0/cornucopia.egg-info/PKG-INFO +92 -0
- cornucopia-0.0.0/cornucopia.egg-info/SOURCES.txt +69 -0
- cornucopia-0.0.0/cornucopia.egg-info/dependency_links.txt +1 -0
- cornucopia-0.0.0/cornucopia.egg-info/requires.txt +14 -0
- cornucopia-0.0.0/cornucopia.egg-info/top_level.txt +1 -0
- cornucopia-0.0.0/pyproject.toml +65 -0
- cornucopia-0.0.0/setup.cfg +4 -0
- cornucopia-0.0.0/setup.py +4 -0
cornucopia-0.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Yaël Balbastre
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cornucopia
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: An abundance of augmentation layers
|
|
5
|
+
Author-email: Yael Balbastre <yael.balbastre@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/balbasty/cornucopia
|
|
8
|
+
Project-URL: Issues, https://github.com/balbasty/cornucopia/issues
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: torch>=1.8
|
|
18
|
+
Requires-Dist: torch-interpol>=0.3
|
|
19
|
+
Requires-Dist: torch-distmap>=0.3
|
|
20
|
+
Requires-Dist: typing_extensions>=4.7
|
|
21
|
+
Requires-Dist: nibabel
|
|
22
|
+
Provides-Extra: io
|
|
23
|
+
Requires-Dist: nibabel; extra == "io"
|
|
24
|
+
Requires-Dist: pillow; extra == "io"
|
|
25
|
+
Requires-Dist: tifffile; extra == "io"
|
|
26
|
+
Requires-Dist: numpy; extra == "io"
|
|
27
|
+
Provides-Extra: typing
|
|
28
|
+
Requires-Dist: numpy>=1.20; extra == "typing"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
<picture align="center">
|
|
32
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/icons/cornucopia_lightorange.svg">
|
|
33
|
+
<source media="(prefers-color-scheme: light)" srcset="docs/icons/cornucopia_orange.svg">
|
|
34
|
+
<img alt="Cornucopia logo" src="https://github.com/balbasty/cornucopia/raw/main/docs/icons/cornucopia_orange.svg">
|
|
35
|
+
</picture>
|
|
36
|
+
|
|
37
|
+
The `cornucopia` package provides a generic framework for preprocessing,
|
|
38
|
+
augmentation, and domain randomization; along with an abundance of specific layers,
|
|
39
|
+
mostly targeted at (medical) imaging. `cornucopia` is written using a PyTorch
|
|
40
|
+
backend, and therefore runs **on the CPU or GPU**.
|
|
41
|
+
|
|
42
|
+
Cornucopia is *intended* to be used on the GPU for on-line augmentation.
|
|
43
|
+
A quick [benchmark](docs/examples/benchmark.ipynb) of affine and elastic augmentation
|
|
44
|
+
shows that while cornucopia is slower than [TorchIO](https://github.com/fepegar/torchio)
|
|
45
|
+
on the CPU (~ 3s vs 1s), it is greatly accelerated on the GPU (~ 50ms).
|
|
46
|
+
|
|
47
|
+
Since gradients are not expected to backpropagate through its layers, it can
|
|
48
|
+
theoretically be used within any dataloader pipeline,
|
|
49
|
+
independent of the downstream learning framework (pytorch, tensorflow, jax, ...).
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
### Dependencies
|
|
54
|
+
|
|
55
|
+
- `pytorch >= 1.8`
|
|
56
|
+
- `numpy`
|
|
57
|
+
- `nibabel`
|
|
58
|
+
- `torch-interpol`
|
|
59
|
+
- `torch-distmap`
|
|
60
|
+
|
|
61
|
+
### Pip (release)
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
pip install cornucopia
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Pip (dev)
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
pip install cornucopia@git+https://github.com/balbasty/cornucopia
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Documentation
|
|
74
|
+
|
|
75
|
+
Read the [documentation](https://balbasty.github.io/cornucopia) and in particular:
|
|
76
|
+
- [installation](https://balbasty.github.io/cornucopia/install/)
|
|
77
|
+
- [get started](https://balbasty.github.io/cornucopia/start/)
|
|
78
|
+
- [examples](https://balbasty.github.io/cornucopia/examples/)
|
|
79
|
+
- [API](https://balbasty.github.io/cornucopia/api/)
|
|
80
|
+
|
|
81
|
+
## Other augmentation packages
|
|
82
|
+
|
|
83
|
+
There are other great, and much more mature, augmentation packages
|
|
84
|
+
out-there (although few run on the GPU). Here's a non-exhaustive list:
|
|
85
|
+
- [MONAI](https://github.com/Project-MONAI/MONAI)
|
|
86
|
+
- [TorchIO](https://github.com/fepegar/torchio)
|
|
87
|
+
- [Albumentations](https://github.com/albumentations-team/albumentations) (2D only)
|
|
88
|
+
- [Volumentations](https://github.com/ZFTurbo/volumentations) (3D extension of Albumentations)
|
|
89
|
+
|
|
90
|
+
## Contributions
|
|
91
|
+
|
|
92
|
+
If you find this project useful and wish to contribute, please reach out!
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<picture align="center">
|
|
2
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/icons/cornucopia_lightorange.svg">
|
|
3
|
+
<source media="(prefers-color-scheme: light)" srcset="docs/icons/cornucopia_orange.svg">
|
|
4
|
+
<img alt="Cornucopia logo" src="https://github.com/balbasty/cornucopia/raw/main/docs/icons/cornucopia_orange.svg">
|
|
5
|
+
</picture>
|
|
6
|
+
|
|
7
|
+
The `cornucopia` package provides a generic framework for preprocessing,
|
|
8
|
+
augmentation, and domain randomization; along with an abundance of specific layers,
|
|
9
|
+
mostly targeted at (medical) imaging. `cornucopia` is written using a PyTorch
|
|
10
|
+
backend, and therefore runs **on the CPU or GPU**.
|
|
11
|
+
|
|
12
|
+
Cornucopia is *intended* to be used on the GPU for on-line augmentation.
|
|
13
|
+
A quick [benchmark](docs/examples/benchmark.ipynb) of affine and elastic augmentation
|
|
14
|
+
shows that while cornucopia is slower than [TorchIO](https://github.com/fepegar/torchio)
|
|
15
|
+
on the CPU (~ 3s vs 1s), it is greatly accelerated on the GPU (~ 50ms).
|
|
16
|
+
|
|
17
|
+
Since gradients are not expected to backpropagate through its layers, it can
|
|
18
|
+
theoretically be used within any dataloader pipeline,
|
|
19
|
+
independent of the downstream learning framework (pytorch, tensorflow, jax, ...).
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
### Dependencies
|
|
24
|
+
|
|
25
|
+
- `pytorch >= 1.8`
|
|
26
|
+
- `numpy`
|
|
27
|
+
- `nibabel`
|
|
28
|
+
- `torch-interpol`
|
|
29
|
+
- `torch-distmap`
|
|
30
|
+
|
|
31
|
+
### Pip (release)
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
pip install cornucopia
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Pip (dev)
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
pip install cornucopia@git+https://github.com/balbasty/cornucopia
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Documentation
|
|
44
|
+
|
|
45
|
+
Read the [documentation](https://balbasty.github.io/cornucopia) and in particular:
|
|
46
|
+
- [installation](https://balbasty.github.io/cornucopia/install/)
|
|
47
|
+
- [get started](https://balbasty.github.io/cornucopia/start/)
|
|
48
|
+
- [examples](https://balbasty.github.io/cornucopia/examples/)
|
|
49
|
+
- [API](https://balbasty.github.io/cornucopia/api/)
|
|
50
|
+
|
|
51
|
+
## Other augmentation packages
|
|
52
|
+
|
|
53
|
+
There are other great, and much more mature, augmentation packages
|
|
54
|
+
out-there (although few run on the GPU). Here's a non-exhaustive list:
|
|
55
|
+
- [MONAI](https://github.com/Project-MONAI/MONAI)
|
|
56
|
+
- [TorchIO](https://github.com/fepegar/torchio)
|
|
57
|
+
- [Albumentations](https://github.com/albumentations-team/albumentations) (2D only)
|
|
58
|
+
- [Volumentations](https://github.com/ZFTurbo/volumentations) (3D extension of Albumentations)
|
|
59
|
+
|
|
60
|
+
## Contributions
|
|
61
|
+
|
|
62
|
+
If you find this project useful and wish to contribute, please reach out!
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Flexible transforms for pre-processing and augmentation
|
|
3
|
+
|
|
4
|
+
Example on how to use this machinery to generate within-subject
|
|
5
|
+
image pairs with a random affine deformation between them::
|
|
6
|
+
|
|
7
|
+
# It's easy to randomize deterministic parameters of a transform
|
|
8
|
+
rand_chi = trf.RandomizedTransform(
|
|
9
|
+
trf.ChiNoiseTransform, dict(sigma=trf.Uniform(0.01, 0.3)))
|
|
10
|
+
|
|
11
|
+
# SequentialTransform is equivalent to monai's Compose
|
|
12
|
+
# MappedTransform make sit possible to process only some inputs (the
|
|
13
|
+
# others are kept untouched)
|
|
14
|
+
demo_transformer = trf.SequentialTransform([
|
|
15
|
+
trf.MappedTransform(img=trf.ToTensorTransform(3, dtype=torch.float32),
|
|
16
|
+
seg=trf.ToTensorTransform(3, dtype=torch.int64)),
|
|
17
|
+
trf.MappedTransform(seg=trf.OneHotTransform([1])),
|
|
18
|
+
trf.MappedTransform(img=trf.QuantileTransform()),
|
|
19
|
+
trf.MakeAffinePair(trf.RandomAffineTransform()),
|
|
20
|
+
trf.MappedTransform(img=trf.MultFieldTransform()),
|
|
21
|
+
trf.MappedTransform(img=rand_chi),
|
|
22
|
+
])
|
|
23
|
+
|
|
24
|
+
# Apply the workflow
|
|
25
|
+
img_and_seg, flow_and_mat = demo_transformer(dict(img=dat, seg=lab))
|
|
26
|
+
|
|
27
|
+
# Unpile everything
|
|
28
|
+
img1, img2 = img_and_seg['img']
|
|
29
|
+
seg1, seg2 = img_and_seg['seg']
|
|
30
|
+
flow = flow_and_mat['flow']
|
|
31
|
+
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
from . import random # noqa: F401
|
|
35
|
+
from . import ctx # noqa: F401
|
|
36
|
+
from . import base # noqa: F401
|
|
37
|
+
from . import baseutils # noqa: F401
|
|
38
|
+
from . import special # noqa: F401
|
|
39
|
+
from . import contrast # noqa: F401
|
|
40
|
+
from . import geometric # noqa: F401
|
|
41
|
+
from . import intensity # noqa: F401
|
|
42
|
+
from . import io # noqa: F401
|
|
43
|
+
from . import fov # noqa: F401
|
|
44
|
+
from . import kspace # noqa: F401
|
|
45
|
+
from . import labels # noqa: F401
|
|
46
|
+
from . import noise # noqa: F401
|
|
47
|
+
from . import psf # noqa: F401
|
|
48
|
+
from . import qmri # noqa: F401
|
|
49
|
+
from . import synth # noqa: F401
|
|
50
|
+
from . import typing # noqa: F401
|
|
51
|
+
from . import utils # noqa: F401
|
|
52
|
+
|
|
53
|
+
from .random import * # noqa: F401,F403
|
|
54
|
+
from .ctx import * # noqa: F401,F403
|
|
55
|
+
from .base import * # noqa: F401,F403
|
|
56
|
+
from .special import * # noqa: F401,F403
|
|
57
|
+
from .contrast import * # noqa: F401,F403
|
|
58
|
+
from .geometric import * # noqa: F401,F403
|
|
59
|
+
from .intensity import * # noqa: F401,F403
|
|
60
|
+
from .io import * # noqa: F401,F403
|
|
61
|
+
from .fov import * # noqa: F401,F403
|
|
62
|
+
from .kspace import * # noqa: F401,F403
|
|
63
|
+
from .labels import * # noqa: F401,F403
|
|
64
|
+
from .noise import * # noqa: F401,F403
|
|
65
|
+
from .psf import * # noqa: F401,F403
|
|
66
|
+
from .qmri import * # noqa: F401,F403
|
|
67
|
+
from .synth import * # noqa: F401,F403
|
|
68
|
+
from .utils.patch import patch_apply # noqa: F401,F403
|
|
69
|
+
|
|
70
|
+
try:
|
|
71
|
+
from ._version import __version__
|
|
72
|
+
except ImportError:
|
|
73
|
+
__version__ = None
|