mlx-segment-ct 0.3.4__tar.gz → 0.3.5__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 (28) hide show
  1. mlx_segment_ct-0.3.5/.gitignore +38 -0
  2. mlx_segment_ct-0.3.5/PKG-INFO +231 -0
  3. mlx_segment_ct-0.3.5/README.md +189 -0
  4. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/pyproject.toml +38 -8
  5. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/__init__.py +1 -1
  6. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/medmlx.py +57 -26
  7. mlx_segment_ct-0.3.4/.gitignore +0 -26
  8. mlx_segment_ct-0.3.4/PKG-INFO +0 -89
  9. mlx_segment_ct-0.3.4/README.md +0 -61
  10. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/LICENSE +0 -0
  11. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/THIRD_PARTY_NOTICES.md +0 -0
  12. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/_types.py +0 -0
  13. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/activations.py +0 -0
  14. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/bundle_transforms.py +0 -0
  15. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/correction.py +0 -0
  16. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/correction_inferer.py +0 -0
  17. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/instance_norm.py +0 -0
  18. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/interactive.py +0 -0
  19. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/labels.py +0 -0
  20. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/mlx_network.py +0 -0
  21. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/mlx_point.py +0 -0
  22. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/mlx_point_window.py +0 -0
  23. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/mlx_upsample.py +0 -0
  24. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/mlx_worker.py +0 -0
  25. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/projections.py +0 -0
  26. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/py.typed +0 -0
  27. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/restoration.py +0 -0
  28. {mlx_segment_ct-0.3.4 → mlx_segment_ct-0.3.5}/src/mlx_segment_ct/streaming.py +0 -0
@@ -0,0 +1,38 @@
1
+ # MedMLX standard
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .venv
6
+ build/
7
+ dist/
8
+ .pytest_cache/
9
+ .ruff_cache/
10
+ .mypy_cache/
11
+ .hypothesis/
12
+ .coverage
13
+ htmlcov/
14
+ .DS_Store
15
+ # Never commit secrets (Hugging Face tokens)
16
+ .env
17
+ # Never commit data or weights
18
+ /data/
19
+ /work/
20
+ /weights/
21
+ /models/
22
+ /checkpoints/
23
+ /outputs/
24
+ *.nii
25
+ *.nii.gz
26
+ *.dcm
27
+ *.nrrd
28
+ *.mha
29
+ *.mhd
30
+ *.safetensors
31
+ *.pt
32
+ *.pth
33
+ *.ckpt
34
+ *.bin
35
+ *.h5
36
+ *.npy
37
+ *.npz
38
+ !tests/fixtures/**/*.npz
@@ -0,0 +1,231 @@
1
+ Metadata-Version: 2.5
2
+ Name: mlx-segment-ct
3
+ Version: 0.3.5
4
+ Summary: Segment CT anatomy automatically or with anatomy names and clicks, using NVIDIA VISTA-3D in native MLX
5
+ Project-URL: Homepage, https://medmlx.org
6
+ Project-URL: Documentation, https://github.com/MedMLX/mlx-segment-ct/blob/v0.3.5/README.md
7
+ Project-URL: Repository, https://github.com/MedMLX/mlx-segment-ct
8
+ Project-URL: Issues, https://github.com/MedMLX/mlx-segment-ct/issues
9
+ Project-URL: Weights, https://huggingface.co/models?author=MedMLX&search=vista3d
10
+ Project-URL: MedMLX, https://github.com/MedMLX/medmlx
11
+ Author: Joseph Sandoval, Alfredo Sandoval Jr.
12
+ License-Expression: Apache-2.0 AND BSD-3-Clause
13
+ License-File: LICENSE
14
+ License-File: THIRD_PARTY_NOTICES.md
15
+ Keywords: apple-silicon,ct,medical-imaging,metal,mlx,mri,segmentation,vista3d
16
+ Classifier: Development Status :: 4 - Beta
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Intended Audience :: Science/Research
19
+ Classifier: Operating System :: MacOS :: MacOS X
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3 :: Only
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
25
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
26
+ Requires-Python: <3.14,>=3.13
27
+ Requires-Dist: medmlx-core==0.2.6
28
+ Requires-Dist: mlx==0.32.4; platform_system == 'Darwin' and platform_machine == 'arm64'
29
+ Requires-Dist: nibabel<6,>=5.3
30
+ Requires-Dist: numpy<3,>=2.0
31
+ Requires-Dist: scipy<2,>=1.14
32
+ Provides-Extra: dev
33
+ Requires-Dist: einops<1,>=0.8; extra == 'dev'
34
+ Requires-Dist: monai==1.6.1; extra == 'dev'
35
+ Requires-Dist: pyright==1.1.414; extra == 'dev'
36
+ Requires-Dist: pytest<10,>=8.4; extra == 'dev'
37
+ Requires-Dist: ruff<1,>=0.13; extra == 'dev'
38
+ Requires-Dist: scikit-image<1,>=0.25; extra == 'dev'
39
+ Requires-Dist: scipy-stubs==1.18.1.1; extra == 'dev'
40
+ Requires-Dist: torch<3,>=2.13; extra == 'dev'
41
+ Description-Content-Type: text/markdown
42
+
43
+ <div align="center">
44
+
45
+ # mlx-segment-ct
46
+
47
+ Segment CT anatomy automatically or with anatomy names and clicks, using NVIDIA VISTA-3D in native MLX.
48
+
49
+ [![PyPI](https://img.shields.io/pypi/v/mlx-segment-ct)](https://pypi.org/project/mlx-segment-ct/)
50
+ [![Python](https://img.shields.io/pypi/pyversions/mlx-segment-ct)](https://pypi.org/project/mlx-segment-ct/)
51
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue)](https://github.com/MedMLX/mlx-segment-ct/blob/v0.3.5/LICENSE)
52
+ [![Apple Silicon](https://img.shields.io/badge/Apple_Silicon-MLX-black?logo=apple)](https://github.com/ml-explore/mlx)
53
+ [![Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97_Hugging_Face-weights-yellow)](https://huggingface.co/MedMLX/vista3d-ct-mlx)
54
+ [![MedMLX](https://img.shields.io/badge/MedMLX-runtime-A51C30)](https://github.com/MedMLX/medmlx)
55
+
56
+ [CT weights](https://huggingface.co/MedMLX/vista3d-ct-mlx) · [CTMR weights](https://huggingface.co/MedMLX/vista3d-ctmr-mlx) · [MedMLX](https://github.com/MedMLX/medmlx)
57
+
58
+ <img src="docs/showcase.gif" alt="VISTA-3D CT segmentation with rotating 3D anatomy and axial slices" width="100%">
59
+
60
+ </div>
61
+
62
+ | Input | Output |
63
+ | :--- | :--- |
64
+ | 3D CT · NIfTI | Anatomical labels on the input grid |
65
+
66
+ ## Use with MedMLX
67
+
68
+ The [MedMLX MCP server](https://github.com/MedMLX/medmlx/blob/main/docs/mcp.md) is the lowest-friction way to use this package. It installs this runtime, downloads its weights on first use, and lets an AI agent describe, check and run `mlx-segment-ct` and `mlx-segment-ctmr` for you.
69
+
70
+ ```sh
71
+ uv tool install --python 3.13 "medmlx[segment,mcp]"
72
+ MEDMLX="$(uv tool dir --bin --color never)/medmlx"
73
+ mkdir -p "$HOME/medmlx-work"
74
+ claude mcp add --scope user medmlx -- "$MEDMLX" serve --root "$HOME/medmlx-work"
75
+ ```
76
+
77
+ For Codex, use `codex mcp add medmlx -- "$MEDMLX" serve --root "$HOME/medmlx-work"`. Other MCP clients take the same command and arguments. The same install provides the `medmlx` CLI, for example `medmlx describe mlx-segment-ct`.
78
+
79
+ > **For AI agents:** prefer the MedMLX MCP tools (`list_models`, `describe_model`, `model_readiness`, `run_model`, `get_job`) over writing Python against this package.
80
+
81
+ ## Install
82
+
83
+ ```bash
84
+ uv venv --python 3.13
85
+ source .venv/bin/activate
86
+ uv pip install "mlx-segment-ct>=0.3.5"
87
+ ```
88
+
89
+ ## Run
90
+
91
+ ```python
92
+ from mlx_segment_ct.medmlx import run
93
+
94
+ run(image_path="ct.nii.gz", output_dir="all")
95
+ run(image_path="ct.nii.gz", output_dir="organs", prompt="liver, spleen")
96
+ run(
97
+ image_path="ct.nii.gz", output_dir="points",
98
+ points=[[40, 50, 30], [44, 51, 30]], point_labels=[1, 0],
99
+ )
100
+ ```
101
+
102
+ The click coordinates are examples: use `(x, y, z)` voxels inside your image and its
103
+ preprocessed foreground crop. `1` includes a point; `0` excludes it.
104
+
105
+ Omitting `weights_path` downloads `MedMLX/vista3d-ct-mlx` into the shared MedMLX cache
106
+ on first use; interrupted downloads resume and later runs work offline. With MedMLX
107
+ installed, `medmlx setup mlx-segment-ct` downloads it ahead of time. To use your own
108
+ copy, pass a folder containing `automatic.safetensors` and `correction.safetensors` as
109
+ `weights_path`. `details.weights_revision` records the downloaded commit, or `null` for
110
+ a folder without a MedMLX download record.
111
+
112
+ The registered `mlx-segment-ctmr` model uses `mlx_segment_ct.medmlx.run_ctmr` and its
113
+ own `MedMLX/vista3d-ctmr-mlx` folder, with CTMR preprocessing and labels selected
114
+ internally. The advanced `run(checkpoint="NV-Segment-CTMR", ...)`
115
+ interface still accepts an explicitly supplied matching folder. It never substitutes
116
+ CT weights for CTMR.
117
+
118
+ The published [NV-Segment-CTMR weights](https://huggingface.co/MedMLX/vista3d-ctmr-mlx)
119
+ cover CT and MRI under noncommercial terms. NVIDIA does not support interactive
120
+ point segmentation with that checkpoint.
121
+
122
+ ### Inputs and outputs
123
+
124
+ | Argument | Meaning |
125
+ | --- | --- |
126
+ | `image_path` | One CT in NIfTI (`.nii` or `.nii.gz`); CT or MRI with NV-Segment-CTMR |
127
+ | `output_dir` | Directory for `mlx_segment_ct_mask.nii.gz` |
128
+ | `weights_path` | Optional folder with `automatic.safetensors`, plus `correction.safetensors` for points |
129
+ | `prompt`, `label_prompt` | Classes by canonical name (list or comma-separated string, case insensitive) or by numeric ID |
130
+ | `segment_all` | Every class of the checkpoint; also the default without prompts |
131
+ | `points`, `point_labels` | Clicks as `(x, y, z)` source voxels, with one code each |
132
+ | `previous_logits_path`, `point_start` | Correct an earlier point result (see below) |
133
+ | `interactive` | Require point mode; clicks select it anyway |
134
+ | `checkpoint` | `"NV-Segment-CT"` (default) or `"NV-Segment-CTMR"`, matching the weights |
135
+ | `modality` | CTMR all-classes set without prompts: `"MRI_BODY"` (default), `"CT_BODY"` or `"MRI_BRAIN"` |
136
+ | `restoration` | `"scores"` (default) or `"bundle"` (see below) |
137
+ | `overwrite` | `False` by default; an existing mask is never replaced |
138
+
139
+ Image voxels must be finite. Spatial units must be millimetres or unknown (assumed
140
+ millimetres); files marked in metres or microns are rejected.
141
+
142
+ The mask holds float32 global labels with the source shape and affine in a new NIfTI
143
+ header; voxels no window covered are 255. `run` returns
144
+ `{"outputs": {"mask": path}, "details": {...}}`, with prompts, window settings,
145
+ timings, source revision and restoration. Invalid requests, missing weights and
146
+ inference failures raise `medmlx-core` errors.
147
+
148
+ ### Prompts
149
+
150
+ Kidney (2), lung (20) and bone (21) expand to their subclasses for automatic
151
+ segmentation. Point runs take at most one class and reject these coarse prompts.
152
+ NV-Segment-CT IDs 133–254 need points. Names are limited to the bundle vocabulary.
153
+
154
+ NV-Segment-CTMR follows its bundle's inference configuration: CT or MRI input,
155
+ 1st–99th percentile scaling instead of the HU window, 192×192×128 windows and labels
156
+ 0–345. IDs 346–511 are zero-shot and need points; the deprecated IDs 133 and 137–145
157
+ are not automatic. Without prompts, `modality` picks the all-classes set: `MRI_BODY`
158
+ (50 classes), `CT_BODY` (the 117 NV-Segment-CT classes) or `MRI_BRAIN` (IDs 214–345).
159
+ `MRI_BRAIN` expects skull-stripped T1 registered as the model card describes; that
160
+ preprocessing is not included. The uncovered value 255 is also CTMR's ID for
161
+ `Left-AnG---angular-gyrus`.
162
+
163
+ ### Points and corrections
164
+
165
+ Clicks must fall inside the source grid and the foreground crop after preprocessing.
166
+ Codes are 0/1 exclude/include, 2/3 special exclude/include and -1 padding; for
167
+ classes 25–29 and 117, 0/1 become 2/3. With no class the foreground label is 1. Class
168
+ IDs up to 132 combine automatic and point scores; higher IDs use the point branch. A
169
+ class prompt whose clicks are all padding keeps the automatic branch.
170
+
171
+ A correction passes the previous raw logits, before sigmoid or postprocessing:
172
+
173
+ ```python
174
+ run(
175
+ image_path="ct.nii.gz", output_dir="corrected", label_prompt=[26],
176
+ previous_logits_path="previous.npy",
177
+ points=[[40, 50, 30], [44, 51, 30]], point_labels=[1, 0], point_start=1,
178
+ )
179
+ ```
180
+
181
+ `previous.npy` is float32 `(1, 1, X, Y, Z)` on this CT's preprocessed grid, as
182
+ `interactive_logits` returns it; the caller keeps track of its image and class.
183
+ `point_start` marks the first new click; earlier clicks remain context. Voxels no new
184
+ window covers keep the previous logits. The result is a single-object mask; other
185
+ objects' labels are not protected.
186
+
187
+ ### Restoration
188
+
189
+ The bundle decides labels on its 1.5 mm grid and restores them by nearest neighbour,
190
+ so boundaries step on finer CTs. The default `restoration="scores"` instead
191
+ interpolates the scores trilinearly at each source voxel and decides there;
192
+ `restoration="bundle"` reproduces the bundle. Both agree on a 1.5 mm source.
193
+
194
+ ### Python API
195
+
196
+ ```python
197
+ from pathlib import Path
198
+
199
+ from medmlx_core.runtime import import_mlx
200
+ from mlx_segment_ct import (
201
+ InteractivePrompt, PointModel, interactive_labels, interactive_logits, transform_points,
202
+ )
203
+ from mlx_segment_ct.bundle_transforms import load_volume, preprocess
204
+
205
+ mx = import_mlx()
206
+ weights = Path("weights")
207
+ point_weights = {
208
+ **mx.load(str(weights / "automatic.safetensors")),
209
+ **mx.load(str(weights / "correction.safetensors")),
210
+ }
211
+ volume, affine = load_volume(Path("ct.nii.gz"))
212
+ prepared = preprocess(volume, affine)
213
+ request = InteractivePrompt(points=((40.0, 50.0, 30.0),), point_labels=(1,))
214
+ request = transform_points(prepared, request)
215
+ point = PointModel(point_weights, mx=mx)
216
+ logits = interactive_logits(prepared.image[None], request, point, mx=mx, roi_size=(128, 128, 128))
217
+ labels = interactive_labels(logits, request)
218
+ ```
219
+
220
+ Images are FP32 `(1, 1, X, Y, Z)`; dimensions must be divisible by 16, with more than
221
+ one voxel at the deepest level. For a class that enables the automatic branch, pass
222
+ `automatic_model=AutomaticModel(...)`; `interactive_logits` also takes
223
+ `previous_logits` and `point_start`. `automatic_logits` returns full automatic scores
224
+ and `rolling_logits` holds only an axis-0 ring of them. Inference needs Apple Silicon
225
+ with Metal and has no CPU fallback.
226
+
227
+ ## License
228
+
229
+ [Apache-2.0](https://github.com/MedMLX/mlx-segment-ct/blob/v0.3.5/LICENSE). See [third-party notices](https://github.com/MedMLX/mlx-segment-ct/blob/v0.3.5/THIRD_PARTY_NOTICES.md). Model weights retain their publisher terms.
230
+
231
+ For research and education. Outputs require human review.
@@ -0,0 +1,189 @@
1
+ <div align="center">
2
+
3
+ # mlx-segment-ct
4
+
5
+ Segment CT anatomy automatically or with anatomy names and clicks, using NVIDIA VISTA-3D in native MLX.
6
+
7
+ [![PyPI](https://img.shields.io/pypi/v/mlx-segment-ct)](https://pypi.org/project/mlx-segment-ct/)
8
+ [![Python](https://img.shields.io/pypi/pyversions/mlx-segment-ct)](https://pypi.org/project/mlx-segment-ct/)
9
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue)](https://github.com/MedMLX/mlx-segment-ct/blob/v0.3.5/LICENSE)
10
+ [![Apple Silicon](https://img.shields.io/badge/Apple_Silicon-MLX-black?logo=apple)](https://github.com/ml-explore/mlx)
11
+ [![Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97_Hugging_Face-weights-yellow)](https://huggingface.co/MedMLX/vista3d-ct-mlx)
12
+ [![MedMLX](https://img.shields.io/badge/MedMLX-runtime-A51C30)](https://github.com/MedMLX/medmlx)
13
+
14
+ [CT weights](https://huggingface.co/MedMLX/vista3d-ct-mlx) · [CTMR weights](https://huggingface.co/MedMLX/vista3d-ctmr-mlx) · [MedMLX](https://github.com/MedMLX/medmlx)
15
+
16
+ <img src="docs/showcase.gif" alt="VISTA-3D CT segmentation with rotating 3D anatomy and axial slices" width="100%">
17
+
18
+ </div>
19
+
20
+ | Input | Output |
21
+ | :--- | :--- |
22
+ | 3D CT · NIfTI | Anatomical labels on the input grid |
23
+
24
+ ## Use with MedMLX
25
+
26
+ The [MedMLX MCP server](https://github.com/MedMLX/medmlx/blob/main/docs/mcp.md) is the lowest-friction way to use this package. It installs this runtime, downloads its weights on first use, and lets an AI agent describe, check and run `mlx-segment-ct` and `mlx-segment-ctmr` for you.
27
+
28
+ ```sh
29
+ uv tool install --python 3.13 "medmlx[segment,mcp]"
30
+ MEDMLX="$(uv tool dir --bin --color never)/medmlx"
31
+ mkdir -p "$HOME/medmlx-work"
32
+ claude mcp add --scope user medmlx -- "$MEDMLX" serve --root "$HOME/medmlx-work"
33
+ ```
34
+
35
+ For Codex, use `codex mcp add medmlx -- "$MEDMLX" serve --root "$HOME/medmlx-work"`. Other MCP clients take the same command and arguments. The same install provides the `medmlx` CLI, for example `medmlx describe mlx-segment-ct`.
36
+
37
+ > **For AI agents:** prefer the MedMLX MCP tools (`list_models`, `describe_model`, `model_readiness`, `run_model`, `get_job`) over writing Python against this package.
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ uv venv --python 3.13
43
+ source .venv/bin/activate
44
+ uv pip install "mlx-segment-ct>=0.3.5"
45
+ ```
46
+
47
+ ## Run
48
+
49
+ ```python
50
+ from mlx_segment_ct.medmlx import run
51
+
52
+ run(image_path="ct.nii.gz", output_dir="all")
53
+ run(image_path="ct.nii.gz", output_dir="organs", prompt="liver, spleen")
54
+ run(
55
+ image_path="ct.nii.gz", output_dir="points",
56
+ points=[[40, 50, 30], [44, 51, 30]], point_labels=[1, 0],
57
+ )
58
+ ```
59
+
60
+ The click coordinates are examples: use `(x, y, z)` voxels inside your image and its
61
+ preprocessed foreground crop. `1` includes a point; `0` excludes it.
62
+
63
+ Omitting `weights_path` downloads `MedMLX/vista3d-ct-mlx` into the shared MedMLX cache
64
+ on first use; interrupted downloads resume and later runs work offline. With MedMLX
65
+ installed, `medmlx setup mlx-segment-ct` downloads it ahead of time. To use your own
66
+ copy, pass a folder containing `automatic.safetensors` and `correction.safetensors` as
67
+ `weights_path`. `details.weights_revision` records the downloaded commit, or `null` for
68
+ a folder without a MedMLX download record.
69
+
70
+ The registered `mlx-segment-ctmr` model uses `mlx_segment_ct.medmlx.run_ctmr` and its
71
+ own `MedMLX/vista3d-ctmr-mlx` folder, with CTMR preprocessing and labels selected
72
+ internally. The advanced `run(checkpoint="NV-Segment-CTMR", ...)`
73
+ interface still accepts an explicitly supplied matching folder. It never substitutes
74
+ CT weights for CTMR.
75
+
76
+ The published [NV-Segment-CTMR weights](https://huggingface.co/MedMLX/vista3d-ctmr-mlx)
77
+ cover CT and MRI under noncommercial terms. NVIDIA does not support interactive
78
+ point segmentation with that checkpoint.
79
+
80
+ ### Inputs and outputs
81
+
82
+ | Argument | Meaning |
83
+ | --- | --- |
84
+ | `image_path` | One CT in NIfTI (`.nii` or `.nii.gz`); CT or MRI with NV-Segment-CTMR |
85
+ | `output_dir` | Directory for `mlx_segment_ct_mask.nii.gz` |
86
+ | `weights_path` | Optional folder with `automatic.safetensors`, plus `correction.safetensors` for points |
87
+ | `prompt`, `label_prompt` | Classes by canonical name (list or comma-separated string, case insensitive) or by numeric ID |
88
+ | `segment_all` | Every class of the checkpoint; also the default without prompts |
89
+ | `points`, `point_labels` | Clicks as `(x, y, z)` source voxels, with one code each |
90
+ | `previous_logits_path`, `point_start` | Correct an earlier point result (see below) |
91
+ | `interactive` | Require point mode; clicks select it anyway |
92
+ | `checkpoint` | `"NV-Segment-CT"` (default) or `"NV-Segment-CTMR"`, matching the weights |
93
+ | `modality` | CTMR all-classes set without prompts: `"MRI_BODY"` (default), `"CT_BODY"` or `"MRI_BRAIN"` |
94
+ | `restoration` | `"scores"` (default) or `"bundle"` (see below) |
95
+ | `overwrite` | `False` by default; an existing mask is never replaced |
96
+
97
+ Image voxels must be finite. Spatial units must be millimetres or unknown (assumed
98
+ millimetres); files marked in metres or microns are rejected.
99
+
100
+ The mask holds float32 global labels with the source shape and affine in a new NIfTI
101
+ header; voxels no window covered are 255. `run` returns
102
+ `{"outputs": {"mask": path}, "details": {...}}`, with prompts, window settings,
103
+ timings, source revision and restoration. Invalid requests, missing weights and
104
+ inference failures raise `medmlx-core` errors.
105
+
106
+ ### Prompts
107
+
108
+ Kidney (2), lung (20) and bone (21) expand to their subclasses for automatic
109
+ segmentation. Point runs take at most one class and reject these coarse prompts.
110
+ NV-Segment-CT IDs 133–254 need points. Names are limited to the bundle vocabulary.
111
+
112
+ NV-Segment-CTMR follows its bundle's inference configuration: CT or MRI input,
113
+ 1st–99th percentile scaling instead of the HU window, 192×192×128 windows and labels
114
+ 0–345. IDs 346–511 are zero-shot and need points; the deprecated IDs 133 and 137–145
115
+ are not automatic. Without prompts, `modality` picks the all-classes set: `MRI_BODY`
116
+ (50 classes), `CT_BODY` (the 117 NV-Segment-CT classes) or `MRI_BRAIN` (IDs 214–345).
117
+ `MRI_BRAIN` expects skull-stripped T1 registered as the model card describes; that
118
+ preprocessing is not included. The uncovered value 255 is also CTMR's ID for
119
+ `Left-AnG---angular-gyrus`.
120
+
121
+ ### Points and corrections
122
+
123
+ Clicks must fall inside the source grid and the foreground crop after preprocessing.
124
+ Codes are 0/1 exclude/include, 2/3 special exclude/include and -1 padding; for
125
+ classes 25–29 and 117, 0/1 become 2/3. With no class the foreground label is 1. Class
126
+ IDs up to 132 combine automatic and point scores; higher IDs use the point branch. A
127
+ class prompt whose clicks are all padding keeps the automatic branch.
128
+
129
+ A correction passes the previous raw logits, before sigmoid or postprocessing:
130
+
131
+ ```python
132
+ run(
133
+ image_path="ct.nii.gz", output_dir="corrected", label_prompt=[26],
134
+ previous_logits_path="previous.npy",
135
+ points=[[40, 50, 30], [44, 51, 30]], point_labels=[1, 0], point_start=1,
136
+ )
137
+ ```
138
+
139
+ `previous.npy` is float32 `(1, 1, X, Y, Z)` on this CT's preprocessed grid, as
140
+ `interactive_logits` returns it; the caller keeps track of its image and class.
141
+ `point_start` marks the first new click; earlier clicks remain context. Voxels no new
142
+ window covers keep the previous logits. The result is a single-object mask; other
143
+ objects' labels are not protected.
144
+
145
+ ### Restoration
146
+
147
+ The bundle decides labels on its 1.5 mm grid and restores them by nearest neighbour,
148
+ so boundaries step on finer CTs. The default `restoration="scores"` instead
149
+ interpolates the scores trilinearly at each source voxel and decides there;
150
+ `restoration="bundle"` reproduces the bundle. Both agree on a 1.5 mm source.
151
+
152
+ ### Python API
153
+
154
+ ```python
155
+ from pathlib import Path
156
+
157
+ from medmlx_core.runtime import import_mlx
158
+ from mlx_segment_ct import (
159
+ InteractivePrompt, PointModel, interactive_labels, interactive_logits, transform_points,
160
+ )
161
+ from mlx_segment_ct.bundle_transforms import load_volume, preprocess
162
+
163
+ mx = import_mlx()
164
+ weights = Path("weights")
165
+ point_weights = {
166
+ **mx.load(str(weights / "automatic.safetensors")),
167
+ **mx.load(str(weights / "correction.safetensors")),
168
+ }
169
+ volume, affine = load_volume(Path("ct.nii.gz"))
170
+ prepared = preprocess(volume, affine)
171
+ request = InteractivePrompt(points=((40.0, 50.0, 30.0),), point_labels=(1,))
172
+ request = transform_points(prepared, request)
173
+ point = PointModel(point_weights, mx=mx)
174
+ logits = interactive_logits(prepared.image[None], request, point, mx=mx, roi_size=(128, 128, 128))
175
+ labels = interactive_labels(logits, request)
176
+ ```
177
+
178
+ Images are FP32 `(1, 1, X, Y, Z)`; dimensions must be divisible by 16, with more than
179
+ one voxel at the deepest level. For a class that enables the automatic branch, pass
180
+ `automatic_model=AutomaticModel(...)`; `interactive_logits` also takes
181
+ `previous_logits` and `point_start`. `automatic_logits` returns full automatic scores
182
+ and `rolling_logits` holds only an axis-0 ring of them. Inference needs Apple Silicon
183
+ with Metal and has no CPU fallback.
184
+
185
+ ## License
186
+
187
+ [Apache-2.0](https://github.com/MedMLX/mlx-segment-ct/blob/v0.3.5/LICENSE). See [third-party notices](https://github.com/MedMLX/mlx-segment-ct/blob/v0.3.5/THIRD_PARTY_NOTICES.md). Model weights retain their publisher terms.
188
+
189
+ For research and education. Outputs require human review.
@@ -4,24 +4,53 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "mlx-segment-ct"
7
- version = "0.3.4"
8
- description = "Native MLX implementation of NV-Segment-CT (VISTA-3D)"
7
+ version = "0.3.5"
8
+ description = "Segment CT anatomy automatically or with anatomy names and clicks, using NVIDIA VISTA-3D in native MLX"
9
9
  readme = "README.md"
10
- classifiers = ["Operating System :: MacOS :: MacOS X"]
11
- requires-python = ">=3.13,<3.15"
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Intended Audience :: Developers",
13
+ "Intended Audience :: Science/Research",
14
+ "Operating System :: MacOS :: MacOS X",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3 :: Only",
17
+ "Programming Language :: Python :: 3.13",
18
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
19
+ "Topic :: Scientific/Engineering :: Image Processing",
20
+ "Topic :: Scientific/Engineering :: Medical Science Apps.",
21
+ ]
22
+ keywords = [
23
+ "mlx",
24
+ "apple-silicon",
25
+ "metal",
26
+ "medical-imaging",
27
+ "vista3d",
28
+ "ct",
29
+ "mri",
30
+ "segmentation",
31
+ ]
32
+ requires-python = ">=3.13,<3.14"
12
33
  license = "Apache-2.0 AND BSD-3-Clause"
13
34
  license-files = ["LICENSE", "THIRD_PARTY_NOTICES.md"]
14
- authors = [{ name = "Joseph Sandoval" }, { name = "Alfredo Sandoval Jr." }]
35
+ authors = [
36
+ { name = "Joseph Sandoval" },
37
+ { name = "Alfredo Sandoval Jr." },
38
+ ]
15
39
  dependencies = [
16
- "medmlx-core==0.2.5",
40
+ "medmlx-core==0.2.6",
41
+ "mlx==0.32.4; platform_system == 'Darwin' and platform_machine == 'arm64'",
17
42
  "nibabel>=5.3,<6",
18
43
  "numpy>=2.0,<3",
19
44
  "scipy>=1.14,<2",
20
45
  ]
21
46
 
22
47
  [project.urls]
23
- Homepage = "https://huggingface.co/MedMLX/vista3d-ct-mlx"
48
+ Homepage = "https://medmlx.org"
49
+ Documentation = "https://github.com/MedMLX/mlx-segment-ct/blob/v0.3.5/README.md"
24
50
  Repository = "https://github.com/MedMLX/mlx-segment-ct"
51
+ Issues = "https://github.com/MedMLX/mlx-segment-ct/issues"
52
+ Weights = "https://huggingface.co/models?author=MedMLX&search=vista3d"
53
+ MedMLX = "https://github.com/MedMLX/medmlx"
25
54
 
26
55
  [project.entry-points."medmlx.models"]
27
56
  mlx-segment-ct = "mlx_segment_ct.medmlx:MODEL"
@@ -34,7 +63,6 @@ dev = [
34
63
  "torch>=2.13,<3",
35
64
  "scikit-image>=0.25,<1",
36
65
  "pytest>=8.4,<10",
37
- "hypothesis>=6.140,<7",
38
66
  "einops>=0.8,<1",
39
67
  "ruff>=0.13,<1",
40
68
  "scipy-stubs==1.18.1.1",
@@ -74,6 +102,8 @@ ban-relative-imports = "all"
74
102
  "typing_extensions.Any" = {msg = "Use a precise type and parse untyped values at the boundary."}
75
103
 
76
104
  [tool.uv]
105
+ environments = ["sys_platform == 'darwin' and platform_machine == 'arm64'"]
106
+ required-environments = ["sys_platform == 'darwin' and platform_machine == 'arm64'"]
77
107
  constraint-dependencies = ["setuptools>=84.1.0", "filelock>=4.2.1", "Pillow>=13,<14"]
78
108
 
79
109
  [tool.hatch.build.targets.sdist]
@@ -25,7 +25,7 @@ if TYPE_CHECKING:
25
25
  from mlx_segment_ct.mlx_worker import automatic_logits
26
26
  from mlx_segment_ct.streaming import LabelReducer, bounded_labels, rolling_logits
27
27
 
28
- __version__ = "0.3.4"
28
+ __version__ = "0.3.5"
29
29
 
30
30
  _EXPORTS = {
31
31
  "AutomaticModel": "mlx_segment_ct.mlx_network",
@@ -175,6 +175,40 @@ def run(
175
175
  restoration: ``"scores"`` (default) interpolates scores before deciding labels;
176
176
  ``"bundle"`` restores labels with nearest interpolation.
177
177
  """
178
+ return _run(
179
+ image_path=image_path, weights_path=weights_path, output_dir=output_dir,
180
+ segment_all=segment_all, prompt=prompt, label_prompt=label_prompt,
181
+ previous_logits_path=previous_logits_path, points=points, point_labels=point_labels,
182
+ point_start=point_start, interactive=interactive, overwrite=overwrite,
183
+ checkpoint=checkpoint, modality=modality, restoration=restoration,
184
+ automatic="mlx-segment-ct" if checkpoint == "NV-Segment-CT" else None,
185
+ )
186
+
187
+
188
+ def _run(
189
+ *,
190
+ image_path: str | os.PathLike[str],
191
+ weights_path: str | os.PathLike[str] | None,
192
+ output_dir: str | os.PathLike[str],
193
+ segment_all: bool,
194
+ prompt: str | Sequence[str] | None,
195
+ label_prompt: Sequence[int] | None,
196
+ previous_logits_path: str | os.PathLike[str] | None,
197
+ points: Sequence[Sequence[float]] | None,
198
+ point_labels: Sequence[int] | None,
199
+ point_start: int,
200
+ interactive: bool,
201
+ overwrite: bool,
202
+ checkpoint: str,
203
+ modality: str | None,
204
+ restoration: str,
205
+ automatic: str | None,
206
+ ) -> RunResult:
207
+ """Check every argument, then resolve weights and run; see ``run`` for the contract.
208
+
209
+ ``automatic`` names the model whose weights download when ``weights_path`` is omitted;
210
+ without it an explicit folder is required. Nothing downloads before all checks pass.
211
+ """
178
212
  started = time.perf_counter()
179
213
  for name, value in (
180
214
  ("overwrite", overwrite),
@@ -190,18 +224,12 @@ def run(
190
224
  f"NV-Segment-CT restoration must be one of {', '.join(RESTORATIONS)}"
191
225
  )
192
226
  rules = label_rules(checkpoint)
193
- if weights_path is None and checkpoint != "NV-Segment-CT":
194
- raise AssetNotReadyError(
195
- "NV-Segment-CTMR requires an explicit matching weights_path folder.",
196
- hint="Automatic mlx-segment-ct weights belong to NV-Segment-CT; "
197
- "supply your converted CTMR folder for this advanced option.",
198
- )
199
227
  if modality is not None and not isinstance(cast("object", modality), str):
200
228
  raise InvalidInputError("NV-Segment-CT modality must be a string")
201
229
  image_file = _nifti_file(image_path, "image_path")
202
230
  previous_file = None
203
231
  if previous_logits_path is not None:
204
- previous_file = Path(previous_logits_path).resolve()
232
+ previous_file = Path(previous_logits_path).expanduser().absolute()
205
233
  if not previous_file.is_file() or previous_file.suffix != ".npy":
206
234
  raise InvalidInputError("previous_logits_path must be an existing float32 .npy file")
207
235
  point_mode = interactive or points is not None or point_labels is not None
@@ -224,20 +252,27 @@ def run(
224
252
  "with label or point prompts"
225
253
  )
226
254
  rules.everything_labels(modality)
227
- output = Path(output_dir).resolve()
255
+ output = Path(output_dir).expanduser().absolute()
228
256
  if output.exists() and not output.is_dir():
229
257
  raise InvalidInputError(f"NV-Segment-CT output_dir is not a directory: {output}")
230
258
  destination = output / MASK_FILENAME
231
- if destination.resolve() in {image_file, previous_file}:
259
+ inputs = {path.resolve() for path in (image_file, previous_file) if path is not None}
260
+ if destination.resolve() in inputs:
232
261
  raise InvalidInputError("NV-Segment-CT outputs must be separate from the input CT and mask")
233
262
  if destination.exists() and not overwrite:
234
263
  raise InvalidInputError(
235
264
  f"NV-Segment-CT output exists: {destination}; pass overwrite=true to replace it"
236
265
  )
237
- weights_root = (
238
- model_weights_dir("mlx-segment-ct")
239
- if weights_path is None else Path(weights_path).expanduser()
240
- )
266
+ if weights_path is not None:
267
+ weights_root = Path(weights_path).expanduser()
268
+ elif automatic is not None:
269
+ weights_root = model_weights_dir(automatic)
270
+ else:
271
+ raise AssetNotReadyError(
272
+ "NV-Segment-CTMR requires an explicit matching weights_path folder.",
273
+ hint="Automatic mlx-segment-ct weights belong to NV-Segment-CT; "
274
+ "supply your converted CTMR folder for this advanced option.",
275
+ )
241
276
  weights_dir = _weights_dir(weights_root, correction=point_mode)
242
277
  return _infer_and_publish(
243
278
  weights_dir,
@@ -301,17 +336,13 @@ def run_ctmr(
301
336
  restoration: ``scores`` interpolates scores before selecting labels;
302
337
  ``bundle`` restores labels with the bundle's nearest-neighbor rule.
303
338
  """
304
- folder = (
305
- model_weights_dir("mlx-segment-ctmr")
306
- if weights_path is None else Path(weights_path).expanduser()
307
- )
308
- return run(
309
- image_path=image_path, output_dir=output_dir, weights_path=folder,
310
- checkpoint="NV-Segment-CTMR", segment_all=segment_all, prompt=prompt,
311
- label_prompt=label_prompt, previous_logits_path=previous_logits_path,
312
- points=points, point_labels=point_labels, point_start=point_start,
313
- interactive=interactive, overwrite=overwrite, modality=modality,
314
- restoration=restoration,
339
+ return _run(
340
+ image_path=image_path, weights_path=weights_path, output_dir=output_dir,
341
+ segment_all=segment_all, prompt=prompt, label_prompt=label_prompt,
342
+ previous_logits_path=previous_logits_path, points=points, point_labels=point_labels,
343
+ point_start=point_start, interactive=interactive, overwrite=overwrite,
344
+ checkpoint="NV-Segment-CTMR", modality=modality, restoration=restoration,
345
+ automatic="mlx-segment-ctmr",
315
346
  )
316
347
 
317
348
 
@@ -783,8 +814,8 @@ def _parse_label_id(value: object) -> int:
783
814
 
784
815
 
785
816
  def _nifti_file(value: str | os.PathLike[str], name: str) -> Path:
786
- """Resolve and validate a NIfTI input file path."""
787
- path = Path(value).resolve()
817
+ """Make a NIfTI input path absolute, expanding ``~`` but keeping links, and validate it."""
818
+ path = Path(value).expanduser().absolute()
788
819
  if not path.is_file():
789
820
  raise InvalidInputError(f"Missing NV-Segment-CT {name}: {path}")
790
821
  if not path.name.endswith((".nii", ".nii.gz")):
@@ -1,26 +0,0 @@
1
- __pycache__/
2
- *.py[cod]
3
- .venv/
4
- *.egg-info/
5
- dist/
6
- build/
7
- .pytest_cache/
8
- .ruff_cache/
9
-
10
- # Checkpoints and converted weights are never committed.
11
- checkpoints/
12
- weights/
13
- *.safetensors
14
- *.npz
15
- !tests/fixtures/*.npz
16
- !tests/fixtures/*/*.npz
17
- *.pt
18
- *.pth
19
- *.ckpt
20
-
21
- # Imaging data is never committed.
22
- data/
23
- *.nii
24
- *.nii.gz
25
- *.dcm
26
- .DS_Store
@@ -1,89 +0,0 @@
1
- Metadata-Version: 2.5
2
- Name: mlx-segment-ct
3
- Version: 0.3.4
4
- Summary: Native MLX implementation of NV-Segment-CT (VISTA-3D)
5
- Project-URL: Homepage, https://huggingface.co/MedMLX/vista3d-ct-mlx
6
- Project-URL: Repository, https://github.com/MedMLX/mlx-segment-ct
7
- Author: Joseph Sandoval, Alfredo Sandoval Jr.
8
- License-Expression: Apache-2.0 AND BSD-3-Clause
9
- License-File: LICENSE
10
- License-File: THIRD_PARTY_NOTICES.md
11
- Classifier: Operating System :: MacOS :: MacOS X
12
- Requires-Python: <3.15,>=3.13
13
- Requires-Dist: medmlx-core==0.2.5
14
- Requires-Dist: nibabel<6,>=5.3
15
- Requires-Dist: numpy<3,>=2.0
16
- Requires-Dist: scipy<2,>=1.14
17
- Provides-Extra: dev
18
- Requires-Dist: einops<1,>=0.8; extra == 'dev'
19
- Requires-Dist: hypothesis<7,>=6.140; extra == 'dev'
20
- Requires-Dist: monai==1.6.1; extra == 'dev'
21
- Requires-Dist: pyright==1.1.414; extra == 'dev'
22
- Requires-Dist: pytest<10,>=8.4; extra == 'dev'
23
- Requires-Dist: ruff<1,>=0.13; extra == 'dev'
24
- Requires-Dist: scikit-image<1,>=0.25; extra == 'dev'
25
- Requires-Dist: scipy-stubs==1.18.1.1; extra == 'dev'
26
- Requires-Dist: torch<3,>=2.13; extra == 'dev'
27
- Description-Content-Type: text/markdown
28
-
29
- # mlx-segment-ct
30
-
31
- Segment CT anatomy automatically or with anatomy names and clicks, using NVIDIA VISTA-3D in native MLX.
32
-
33
- [Docs](https://github.com/MedMLX/mlx-segment-ct/blob/main/docs/technical.md) · [CT weights](https://huggingface.co/MedMLX/vista3d-ct-mlx) · [CTMR weights](https://huggingface.co/MedMLX/vista3d-ctmr-mlx) · [MedMLX](https://github.com/MedMLX)
34
-
35
- | Input | Output |
36
- | :--- | :--- |
37
- | 3D CT · NIfTI | Anatomical labels on the input grid |
38
-
39
- **Apple Silicon · Metal · Python 3.13 / 3.14** · [uv](https://docs.astral.sh/uv/)
40
-
41
- ## Install
42
-
43
- ```bash
44
- uv venv --python 3.13
45
- source .venv/bin/activate
46
- uv pip install "mlx-segment-ct>=0.3.4"
47
- ```
48
-
49
- NIfTI files explicitly marked in meters or microns are rejected. Inputs with
50
- unknown spatial units are assumed to use millimeters.
51
-
52
- The click coordinates below are examples: replace them with voxels inside your
53
- image and its preprocessed foreground crop. `1` includes a point; `0` excludes it.
54
-
55
- ## Run
56
-
57
- ```python
58
- from mlx_segment_ct.medmlx import run
59
-
60
- run(image_path="ct.nii.gz", output_dir="all")
61
- run(image_path="ct.nii.gz", output_dir="organs", prompt="liver, spleen")
62
- run(
63
- image_path="ct.nii.gz", output_dir="points",
64
- points=[[40, 50, 30], [44, 51, 30]], point_labels=[1, 0],
65
- )
66
- ```
67
-
68
- Omitting `weights_path` downloads `MedMLX/vista3d-ct-mlx` once and reuses its local
69
- cache. An explicit model folder contains `automatic.safetensors` and
70
- `correction.safetensors`. Point coordinates are `(x, y, z)` voxels.
71
-
72
- The registered `mlx-segment-ctmr` model uses `mlx_segment_ct.medmlx.run_ctmr` and its
73
- own `MedMLX/vista3d-ctmr-mlx` folder, with CTMR preprocessing and labels selected
74
- internally. The advanced `run(checkpoint="NV-Segment-CTMR", ...)`
75
- interface still accepts an explicitly supplied matching folder. It never substitutes
76
- CT weights for CTMR.
77
-
78
- The published [NV-Segment-CTMR weights](https://huggingface.co/MedMLX/vista3d-ctmr-mlx)
79
- cover CT and MRI under noncommercial terms. NVIDIA does not support interactive
80
- point segmentation with that checkpoint.
81
-
82
- Downloaded commits are returned in `details.weights_revision`; explicit local
83
- weights report `null` unless the folder carries a MedMLX download revision.
84
-
85
- ## License
86
-
87
- [Apache-2.0](https://github.com/MedMLX/mlx-segment-ct/blob/main/LICENSE). See [third-party notices](https://github.com/MedMLX/mlx-segment-ct/blob/main/THIRD_PARTY_NOTICES.md). Model weights retain their publisher terms.
88
-
89
- For research and education. Outputs require human review.
@@ -1,61 +0,0 @@
1
- # mlx-segment-ct
2
-
3
- Segment CT anatomy automatically or with anatomy names and clicks, using NVIDIA VISTA-3D in native MLX.
4
-
5
- [Docs](https://github.com/MedMLX/mlx-segment-ct/blob/main/docs/technical.md) · [CT weights](https://huggingface.co/MedMLX/vista3d-ct-mlx) · [CTMR weights](https://huggingface.co/MedMLX/vista3d-ctmr-mlx) · [MedMLX](https://github.com/MedMLX)
6
-
7
- | Input | Output |
8
- | :--- | :--- |
9
- | 3D CT · NIfTI | Anatomical labels on the input grid |
10
-
11
- **Apple Silicon · Metal · Python 3.13 / 3.14** · [uv](https://docs.astral.sh/uv/)
12
-
13
- ## Install
14
-
15
- ```bash
16
- uv venv --python 3.13
17
- source .venv/bin/activate
18
- uv pip install "mlx-segment-ct>=0.3.4"
19
- ```
20
-
21
- NIfTI files explicitly marked in meters or microns are rejected. Inputs with
22
- unknown spatial units are assumed to use millimeters.
23
-
24
- The click coordinates below are examples: replace them with voxels inside your
25
- image and its preprocessed foreground crop. `1` includes a point; `0` excludes it.
26
-
27
- ## Run
28
-
29
- ```python
30
- from mlx_segment_ct.medmlx import run
31
-
32
- run(image_path="ct.nii.gz", output_dir="all")
33
- run(image_path="ct.nii.gz", output_dir="organs", prompt="liver, spleen")
34
- run(
35
- image_path="ct.nii.gz", output_dir="points",
36
- points=[[40, 50, 30], [44, 51, 30]], point_labels=[1, 0],
37
- )
38
- ```
39
-
40
- Omitting `weights_path` downloads `MedMLX/vista3d-ct-mlx` once and reuses its local
41
- cache. An explicit model folder contains `automatic.safetensors` and
42
- `correction.safetensors`. Point coordinates are `(x, y, z)` voxels.
43
-
44
- The registered `mlx-segment-ctmr` model uses `mlx_segment_ct.medmlx.run_ctmr` and its
45
- own `MedMLX/vista3d-ctmr-mlx` folder, with CTMR preprocessing and labels selected
46
- internally. The advanced `run(checkpoint="NV-Segment-CTMR", ...)`
47
- interface still accepts an explicitly supplied matching folder. It never substitutes
48
- CT weights for CTMR.
49
-
50
- The published [NV-Segment-CTMR weights](https://huggingface.co/MedMLX/vista3d-ctmr-mlx)
51
- cover CT and MRI under noncommercial terms. NVIDIA does not support interactive
52
- point segmentation with that checkpoint.
53
-
54
- Downloaded commits are returned in `details.weights_revision`; explicit local
55
- weights report `null` unless the folder carries a MedMLX download revision.
56
-
57
- ## License
58
-
59
- [Apache-2.0](https://github.com/MedMLX/mlx-segment-ct/blob/main/LICENSE). See [third-party notices](https://github.com/MedMLX/mlx-segment-ct/blob/main/THIRD_PARTY_NOTICES.md). Model weights retain their publisher terms.
60
-
61
- For research and education. Outputs require human review.
File without changes