nezaret 0.1.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.
Files changed (39) hide show
  1. nezaret-0.1.0/CHANGELOG.md +42 -0
  2. nezaret-0.1.0/INSTALL.md +91 -0
  3. nezaret-0.1.0/LICENSE +202 -0
  4. nezaret-0.1.0/MANIFEST.in +12 -0
  5. nezaret-0.1.0/PKG-INFO +237 -0
  6. nezaret-0.1.0/PUBLISHING.md +148 -0
  7. nezaret-0.1.0/README.md +205 -0
  8. nezaret-0.1.0/ROADMAP.md +126 -0
  9. nezaret-0.1.0/TESTING.md +114 -0
  10. nezaret-0.1.0/TROUBLESHOOTING.md +95 -0
  11. nezaret-0.1.0/examples/faulty_bundle/configs/inference.json +62 -0
  12. nezaret-0.1.0/examples/faulty_bundle/configs/train.json +154 -0
  13. nezaret-0.1.0/examples/lint_compose_example.py +41 -0
  14. nezaret-0.1.0/pyproject.toml +50 -0
  15. nezaret-0.1.0/setup.cfg +4 -0
  16. nezaret-0.1.0/src/nezaret/__init__.py +17 -0
  17. nezaret-0.1.0/src/nezaret/__main__.py +5 -0
  18. nezaret-0.1.0/src/nezaret/__version__.py +1 -0
  19. nezaret-0.1.0/src/nezaret/cli.py +114 -0
  20. nezaret-0.1.0/src/nezaret/config.py +211 -0
  21. nezaret-0.1.0/src/nezaret/data/monai_components.json +2452 -0
  22. nezaret-0.1.0/src/nezaret/knowledge.py +159 -0
  23. nezaret-0.1.0/src/nezaret/lint.py +204 -0
  24. nezaret-0.1.0/src/nezaret/pipeline.py +295 -0
  25. nezaret-0.1.0/src/nezaret/report.py +69 -0
  26. nezaret-0.1.0/src/nezaret/rules.py +615 -0
  27. nezaret-0.1.0/src/nezaret.egg-info/PKG-INFO +237 -0
  28. nezaret-0.1.0/src/nezaret.egg-info/SOURCES.txt +37 -0
  29. nezaret-0.1.0/src/nezaret.egg-info/dependency_links.txt +1 -0
  30. nezaret-0.1.0/src/nezaret.egg-info/entry_points.txt +2 -0
  31. nezaret-0.1.0/src/nezaret.egg-info/requires.txt +14 -0
  32. nezaret-0.1.0/src/nezaret.egg-info/top_level.txt +1 -0
  33. nezaret-0.1.0/tests/conftest.py +64 -0
  34. nezaret-0.1.0/tests/test_cli.py +90 -0
  35. nezaret-0.1.0/tests/test_examples.py +35 -0
  36. nezaret-0.1.0/tests/test_live_monai.py +147 -0
  37. nezaret-0.1.0/tests/test_model_zoo.py +56 -0
  38. nezaret-0.1.0/tests/test_rules.py +415 -0
  39. nezaret-0.1.0/tools/refresh_monai_components.py +41 -0
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0: first release
4
+
5
+ **`nezaret lint`, for MONAI Bundle configs.** Reads `train.json`,
6
+ `inference.json` and their YAML equivalents as data, resolves `@` references,
7
+ `%` macros (including `%other.json#…`) and `$@a + @b` concatenation without
8
+ evaluating anything, and checks every transform pipeline it finds against
9
+ eleven rules. Each rule names a way a pipeline produces a wrong result
10
+ **without raising an error**.
11
+
12
+ | Rule | Severity |
13
+ |---|---|
14
+ | `NZ101` label-interpolation | error |
15
+ | `NZ102` label-intensity | error (warning for min-max scaling) |
16
+ | `NZ103` geometry-split | error (warning when a key is never moved at all) |
17
+ | `NZ104` unknown-target | error |
18
+ | `NZ105` discrete-interpolation | error |
19
+ | `NZ106` saved-not-inverted | warning |
20
+ | `NZ107` label-guided-eval | error |
21
+ | `NZ108` random-in-eval | warning |
22
+ | `NZ109` train-eval-mismatch | warning |
23
+ | `NZ110` missing-channel-first | info |
24
+ | `NZ111` no-determinism | info |
25
+
26
+ **`lint_compose()`, for pipelines built in Python.** Reads the attributes of a
27
+ live `monai.transforms.Compose` (including `OneOf`, `SomeOf`, `RandomOrder` and
28
+ nested `Compose`) into the same model, so the same rules apply.
29
+
30
+ **What it knows about MONAI was read from MONAI 1.6.1**: the default `mode` of
31
+ every resampling transform, `Invertd`'s `nearest_interp=True`, the intensity
32
+ defaults compared between training and evaluation, and the 2446 names MONAI's
33
+ `ComponentLocator` resolves. The live test suite re-checks all of it against
34
+ the installed MONAI.
35
+
36
+ **Tested against MONAI's model zoo.** All 37 bundles, 157 config files and 174
37
+ pipelines: 6 errors and 7 warnings, every error read against the bundle source.
38
+ Seven false positives found during development became clean tests (listed in
39
+ TESTING.md). The six true errors, in four bundles, are in the README.
40
+
41
+ Zero runtime dependencies. PyYAML for YAML bundles and MONAI for
42
+ `lint_compose()` are optional extras.
@@ -0,0 +1,91 @@
1
+ # Installing nezaret
2
+
3
+ ## Just the tool
4
+
5
+ ```bash
6
+ pip install nezaret
7
+ ```
8
+
9
+ That is everything for JSON bundle configs. nezaret has **zero runtime
10
+ dependencies** and works on Python 3.10 or newer. It needs no account, no
11
+ server, no GPU, and makes no network call.
12
+
13
+ Verify:
14
+
15
+ ```bash
16
+ python -c "import nezaret; print(nezaret.__version__)"
17
+ nezaret doctor
18
+ ```
19
+
20
+ ---
21
+
22
+ ## The optional extras
23
+
24
+ | Extra | Pulls | Needed for |
25
+ |---|---|---|
26
+ | `nezaret[yaml]` | PyYAML | bundles written in YAML (`train.yaml`). Without it those files are skipped with a note, never silently |
27
+ | `nezaret[monai]` | MONAI ≥ 1.4, and through it **PyTorch** | `nezaret.lint_compose()` on live pipeline objects, and the live test suite |
28
+ | `nezaret[all]` | both | |
29
+ | `nezaret[dev]` | pytest, PyYAML | running the tests |
30
+
31
+ ```bash
32
+ pip install "nezaret[yaml]" # most people want this one
33
+ ```
34
+
35
+ **Linting a bundle never needs MONAI.** Bundle configs are read as data, so a
36
+ laptop with no CUDA and no torch checks them as well as a GPU server does. Only
37
+ `lint_compose()` needs MONAI, because it reads attributes off transform objects
38
+ that must already exist in your process.
39
+
40
+ PyTorch is a large download (several hundred MB, more with CUDA). If you only
41
+ want MONAI for `lint_compose()` on a CPU machine, the CPU wheel is much smaller:
42
+
43
+ ```bash
44
+ pip install torch --index-url https://download.pytorch.org/whl/cpu
45
+ pip install "nezaret[monai]"
46
+ ```
47
+
48
+ ### Which MONAI
49
+
50
+ nezaret's rules were written against **MONAI 1.6.1**, and the list of names
51
+ MONAI can resolve (for `NZ104`) was read from that release. Other MONAI
52
+ versions should work with `lint_compose()` as long as the transform classes
53
+ keep their attribute names, but only 1.6.1 has been tested. `nezaret doctor`
54
+ says when your MONAI differs from 1.6.1; the live tests then say whether
55
+ anything nezaret assumes has changed:
56
+
57
+ ```bash
58
+ pytest tests/test_live_monai.py -v
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Offline or behind a slow connection
64
+
65
+ Because the core has no dependencies, the wheel is the whole install (about
66
+ 40 KB). On any machine with access to PyPI:
67
+
68
+ ```bash
69
+ pip download nezaret --no-deps -d wheels/
70
+ pip download pyyaml --no-deps -d wheels/ # optional, for YAML bundles
71
+ ```
72
+
73
+ Copy `wheels/` across and:
74
+
75
+ ```bash
76
+ pip install --no-index --find-links wheels/ nezaret pyyaml
77
+ ```
78
+
79
+ ---
80
+
81
+ ## From source
82
+
83
+ ```bash
84
+ git clone https://github.com/aslansd/nezaret
85
+ cd nezaret
86
+ pip install -e ".[dev]"
87
+ pytest -q
88
+ ```
89
+
90
+ See [TESTING.md](TESTING.md) for what a green run looks like in each
91
+ environment.
nezaret-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,12 @@
1
+ include LICENSE
2
+ include README.md
3
+ include INSTALL.md
4
+ include TESTING.md
5
+ include PUBLISHING.md
6
+ include TROUBLESHOOTING.md
7
+ include ROADMAP.md
8
+ include CHANGELOG.md
9
+ include src/nezaret/data/*.json
10
+ recursive-include examples *.py *.json
11
+ recursive-include tests *.py
12
+ recursive-include tools *.py
nezaret-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,237 @@
1
+ Metadata-Version: 2.4
2
+ Name: nezaret
3
+ Version: 0.1.0
4
+ Summary: Find MONAI pipeline faults that do not raise errors: misaligned labels, interpolated class maps, evaluation that peeks at the ground truth.
5
+ Author: Aslan Satary Dizaji
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/aslansd/nezaret
8
+ Project-URL: Repository, https://github.com/aslansd/nezaret
9
+ Project-URL: Issues, https://github.com/aslansd/nezaret/issues
10
+ Keywords: MONAI,medical-imaging,segmentation,linter,validation,reproducibility
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Intended Audience :: Healthcare Industry
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
16
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
17
+ Classifier: Topic :: Software Development :: Quality Assurance
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Provides-Extra: yaml
22
+ Requires-Dist: pyyaml>=6; extra == "yaml"
23
+ Provides-Extra: monai
24
+ Requires-Dist: monai>=1.4; extra == "monai"
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=8; extra == "dev"
27
+ Requires-Dist: pyyaml>=6; extra == "dev"
28
+ Provides-Extra: all
29
+ Requires-Dist: pyyaml>=6; extra == "all"
30
+ Requires-Dist: monai>=1.4; extra == "all"
31
+ Dynamic: license-file
32
+
33
+ # nezaret
34
+
35
+ **نظارت**: *oversight, supervision, inspection.* The same word in Persian
36
+ (*nezārat*), Turkish (*nezaret*) and Azerbaijani (*nəzarət*).
37
+
38
+ Find faults in [MONAI](https://monai.io) pipelines that **do not raise
39
+ errors**: a label map resampled with bilinear interpolation, a rotation applied
40
+ to the image but not its label, a validation crop chosen from the ground truth,
41
+ an inference pipeline that preprocesses differently from training.
42
+
43
+ Each of these trains, evaluates and reports a number. The number is wrong, and
44
+ nothing in the run says so.
45
+
46
+ **No dependencies. Runs offline. Reads configs as data; never imports torch, never
47
+ runs a transform.**
48
+
49
+ ```bash
50
+ pip install nezaret
51
+ nezaret lint path/to/bundle
52
+ ```
53
+
54
+ Python 3.10+. Apache 2.0. Rules are checked against MONAI 1.6.1.
55
+
56
+ [PyPI](https://pypi.org/project/nezaret/) · [INSTALL](INSTALL.md) ·
57
+ [TESTING](TESTING.md) · [PUBLISHING](PUBLISHING.md) ·
58
+ [TROUBLESHOOTING](TROUBLESHOOTING.md) · [ROADMAP](ROADMAP.md) ·
59
+ [CHANGELOG](CHANGELOG.md)
60
+
61
+ ---
62
+
63
+ ## The thirty-second version
64
+
65
+ ```text
66
+ $ nezaret lint examples/faulty_bundle
67
+ configs/inference.json
68
+ E NZ104 unknown-target preprocessing#transforms#1
69
+ 'AddChanneld' is not a MONAI 1.6.1 component. It was removed or renamed in MONAI; use EnsureChannelFirstd with channel_dim="no_channel".
70
+ W NZ106 saved-not-inverted postprocessing#transforms#2
71
+ SaveImaged writes 'pred' without Invertd, but the preprocessing at inference.json:preprocessing changes the grid (Orientationd, Spacingd).
72
+ W NZ109 train-eval-mismatch preprocessing
73
+ compared with train.json:train#preprocessing: NormalizeIntensityd only in training; Orientationd.axcodes: train 'RAS' vs eval 'LPS'
74
+
75
+ configs/train.json
76
+ E NZ101 label-interpolation train#deterministic_transforms#3
77
+ Spacingd resamples label key 'label' with mode 'bilinear' (MONAI's default); label maps need 'nearest'.
78
+ E NZ102 label-intensity train#random_transforms#2
79
+ RandGaussianNoised changes voxel values of label key(s) 'label'.
80
+ E NZ103 geometry-split train#random_transforms#1
81
+ RandRotated transforms 'image' but not 'label', which were loaded together and stop being aligned here.
82
+ E NZ107 label-guided-eval validate#preprocessing#transforms#4
83
+ CropForegroundd in an evaluation pipeline takes its region from ground-truth key 'label' (source_key).
84
+ W NZ109 train-eval-mismatch validate#preprocessing
85
+ compared with train.json:train#preprocessing: NormalizeIntensityd only in training
86
+ I NZ111 no-determinism train#preprocessing
87
+ random transforms in training and no set_determinism or seed in this file or the config it overrides.
88
+
89
+ 2 file(s), 4 pipeline(s): 5 error(s), 3 warning(s), 1 info
90
+ ```
91
+
92
+ Every location is a MONAI Bundle `#`-path, so `train#deterministic_transforms#3`
93
+ is the fourth entry of that list. A finding on a transform reached through
94
+ `$@train#deterministic_transforms + @train#random_transforms` points at the list
95
+ the transform is written in, not at the expression.
96
+
97
+ ---
98
+
99
+ ## What it checks
100
+
101
+ | Rule | Severity | Catches |
102
+ |---|---|---|
103
+ | `NZ101` label-interpolation | error | a label key resampled with a non-nearest mode, **including MONAI's defaults** (`Spacingd`, `RandAffined`: bilinear; `Resized`, `Zoomd`, `RandZoomd`: area) |
104
+ | `NZ102` label-intensity | error | intensity transforms (noise, scaling, normalisation, contrast) on a label key; min-max scaling is a warning, since 0/255 → 0/1 masks are a real idiom |
105
+ | `NZ103` geometry-split | error | a spatial transform (orientation, spacing, crop, pad, flip, rotate, zoom) applied to some of the arrays loaded together but not the others |
106
+ | `NZ104` unknown-target | error | a `_target_` MONAI cannot resolve, with the replacement for removed ones (`AddChanneld`, `AsChannelFirstd`, `IgniteMetric`…) |
107
+ | `NZ105` discrete-interpolation | error | `Invertd(nearest_interp=false)` after `AsDiscreted`, which interpolates class indices |
108
+ | `NZ106` saved-not-inverted | warning | predictions saved on the resampled grid, without `Invertd` or `resample=true` |
109
+ | `NZ107` label-guided-eval | error | validation or inference that crops by the ground truth (`CropForegroundd(source_key=label)`, label-guided random crops) |
110
+ | `NZ108` random-in-eval | warning | a random transform in validation or inference |
111
+ | `NZ109` train-eval-mismatch | warning | orientation, spacing, size or intensity scaling that differs between training and evaluation, **across files of the same bundle** |
112
+ | `NZ110` missing-channel-first | info | a spatial transform before any channel-first step |
113
+ | `NZ111` no-determinism | info | random training transforms and no seed anywhere |
114
+
115
+ `nezaret rules` lists them; `nezaret explain NZ107` says why one matters and
116
+ how to fix it.
117
+
118
+ The defaults nezaret relies on were read from `inspect.signature` of MONAI
119
+ 1.6.1, not from documentation, and `tests/test_live_monai.py` re-checks them
120
+ against whatever MONAI is installed.
121
+
122
+ ---
123
+
124
+ ## What it found in MONAI's own model zoo
125
+
126
+ Linting all 37 bundles of [Project-MONAI/model-zoo](https://github.com/Project-MONAI/model-zoo)
127
+ (commit `feb2e8c`, 20 October 2026; 157 config files, 174 pipelines) gives
128
+ **6 errors, 7 warnings and 5 info**. Every error, and every warning below, was read
129
+ against the bundle source by hand:
130
+
131
+ | Bundle | Rule | What the config does |
132
+ |---|---|---|
133
+ | `prostate_mri_anatomy` train | NZ101 ×3 | `RandAffined`, `Rand3DElasticd` and `RandZoomd` on `["image", "label"]` with no `mode`, so the label is resampled bilinearly (twice) and by area averaging |
134
+ | `prostate_mri_anatomy` inference | NZ105 | `AsDiscreted(argmax)`, then `Invertd(nearest_interp=false)` on the class map |
135
+ | `renalStructures_CECT_segmentation` train | NZ101 | `RandZoomd` on the label with the default `area` mode |
136
+ | `renalStructures_CECT_segmentation` inference | NZ109 | training loads with `as_closest_canonical=true` (RAS); inference reorients to `LPS` |
137
+ | `wholeBrainSeg_Large_UNEST_segmentation` train | NZ109 | `NormalizeIntensityd` sits in `random_transforms`; validation copies only the deterministic list, so the checkpoint is selected on unnormalised inputs while training and inference normalise |
138
+ | `mednist_reg` train | NZ104 | `IgniteMetric`, renamed `IgniteMetricHandler` |
139
+
140
+ The reference bundles (`spleen_ct_segmentation`, `swin_unetr_btcv_segmentation`)
141
+ come back clean. `tests/test_model_zoo.py` turns this table into a regression
142
+ test.
143
+
144
+ The remaining warnings are judgement calls nezaret cannot settle from the
145
+ config alone: e.g. `lung_nodule_ct_detection` resamples only at inference
146
+ because its README resamples the training data offline, which the message
147
+ says.
148
+
149
+ ---
150
+
151
+ ## Commands
152
+
153
+ ```bash
154
+ nezaret lint PATH... # a config file, a bundle, or a folder of bundles
155
+ nezaret lint PATH --format markdown # or json; -o report.md to write a file
156
+ nezaret lint PATH --fail-on warning # exit 1 on warnings too (default: errors only)
157
+ nezaret lint PATH --ignore NZ108,no-determinism
158
+ nezaret lint PATH --label-keys seg,organs
159
+ nezaret rules
160
+ nezaret explain NZ103
161
+ nezaret doctor
162
+ ```
163
+
164
+ Exit codes: `0` clean, `1` a finding at or above `--fail-on`, `2` nothing
165
+ could be checked. That makes it a CI step as it stands:
166
+
167
+ ```yaml
168
+ - run: pip install "nezaret[yaml]"
169
+ - run: nezaret lint configs/ --fail-on error
170
+ ```
171
+
172
+ A directory with a `configs/` folder is one bundle; a directory holding
173
+ configs is one bundle; anything else is searched for `configs/` folders.
174
+ Cross-file rules only compare files within one bundle.
175
+
176
+ ---
177
+
178
+ ## From Python
179
+
180
+ ```python
181
+ import nezaret
182
+
183
+ report = nezaret.lint("my_bundle/") # Report
184
+ report.ok # no errors
185
+ report.findings # [Finding(rule, severity, file, location, message, ...)]
186
+ report.to_json(); report.to_markdown()
187
+
188
+ nezaret.lint_config(config_dict, name="train.json")
189
+ ```
190
+
191
+ For pipelines built in Python rather than in a config (needs MONAI installed):
192
+
193
+ ```python
194
+ report = nezaret.lint_compose(train_transforms, role="train")
195
+ report = nezaret.lint_compose(val_transforms, role="eval")
196
+ report = nezaret.lint_compose(post_transforms, role="post", preprocessing=val_transforms)
197
+ ```
198
+
199
+ nezaret reads the transform objects' attributes; it does not call them, load
200
+ data or need a GPU. `role` has to be given because an object does not say what
201
+ it is used for. See `examples/lint_compose_example.py`.
202
+
203
+ ---
204
+
205
+ ## How it decides what is a label
206
+
207
+ In this order:
208
+
209
+ 1. `--label-keys` / `label_keys=`, if given, and nothing else.
210
+ 2. Key names such as `label`, `seg`, `mask`, `gt`, `annotation`, `target`
211
+ (also `label_inst`, `seg_1`, `lbl`…).
212
+ 3. A per-key `mode` list that mixes `nearest` with something else: the author
213
+ saying which keys are label maps.
214
+ 4. The `label_key` of a label-guided crop.
215
+
216
+ A single `mode: "nearest"` for every key is *not* evidence: some bundles
217
+ resample their images that way.
218
+
219
+ ## What it does not do
220
+
221
+ - **It does not evaluate `$` expressions.** `@` references, `%` macros
222
+ (including `%other.json#…`) and `$@a + @b` concatenation are resolved
223
+ statically; any other expression is treated as unknown and the rules that
224
+ would need it are skipped, never guessed. A pipeline built entirely by an
225
+ expression is not checked.
226
+ - **It does not read your data list or your images.** It cannot know that
227
+ your data list supplies four files per key (which is why `NZ110` is info) or
228
+ that two cases come from the same patient. That is `nezaret data`, planned
229
+ for 0.2.0 (see the [ROADMAP](ROADMAP.md)).
230
+ - **It does not judge custom transforms.** After a `scripts.*` step that may
231
+ add, merge or drop keys, the key-tracking rules stop rather than guess.
232
+
233
+ ---
234
+
235
+ ## Licence
236
+
237
+ Apache 2.0. See [LICENSE](LICENSE).