mlx-segment-ct 0.3.2__tar.gz → 0.3.3__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.
Potentially problematic release.
This version of mlx-segment-ct might be problematic. Click here for more details.
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/PKG-INFO +8 -4
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/README.md +7 -3
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/pyproject.toml +1 -1
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/__init__.py +1 -1
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/bundle_transforms.py +8 -6
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/medmlx.py +34 -9
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/.gitignore +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/LICENSE +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/THIRD_PARTY_NOTICES.md +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/_types.py +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/activations.py +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/correction.py +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/correction_inferer.py +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/instance_norm.py +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/interactive.py +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/labels.py +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/mlx_network.py +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/mlx_point.py +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/mlx_point_window.py +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/mlx_upsample.py +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/mlx_worker.py +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/projections.py +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/py.typed +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/restoration.py +0 -0
- {mlx_segment_ct-0.3.2 → mlx_segment_ct-0.3.3}/src/mlx_segment_ct/streaming.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: mlx-segment-ct
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Native MLX implementation of NV-Segment-CT (VISTA-3D)
|
|
5
5
|
Project-URL: Homepage, https://huggingface.co/MedMLX/vista3d-ct-mlx
|
|
6
6
|
Author: Joseph Sandoval, Alfredo Sandoval Jr.
|
|
@@ -29,7 +29,7 @@ Description-Content-Type: text/markdown
|
|
|
29
29
|
|
|
30
30
|
Segment CT anatomy automatically or with anatomy names and clicks, using NVIDIA VISTA-3D in native MLX.
|
|
31
31
|
|
|
32
|
-
[CT weights](https://huggingface.co/MedMLX/vista3d-ct-mlx) · [CTMR weights](https://huggingface.co/MedMLX/vista3d-ctmr-mlx)
|
|
32
|
+
[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)
|
|
33
33
|
|
|
34
34
|
| Input | Output |
|
|
35
35
|
| :--- | :--- |
|
|
@@ -37,9 +37,11 @@ Segment CT anatomy automatically or with anatomy names and clicks, using NVIDIA
|
|
|
37
37
|
|
|
38
38
|
**Apple Silicon · Metal · Python 3.13 / 3.14** · [uv](https://docs.astral.sh/uv/)
|
|
39
39
|
|
|
40
|
-
##
|
|
40
|
+
## Install
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
+
uv venv --python 3.13
|
|
44
|
+
source .venv/bin/activate
|
|
43
45
|
uv pip install "mlx-segment-ct>=0.3.2"
|
|
44
46
|
```
|
|
45
47
|
|
|
@@ -49,6 +51,8 @@ unknown spatial units are assumed to use millimeters.
|
|
|
49
51
|
The click coordinates below are examples: replace them with voxels inside your
|
|
50
52
|
image and its preprocessed foreground crop. `1` includes a point; `0` excludes it.
|
|
51
53
|
|
|
54
|
+
## Run
|
|
55
|
+
|
|
52
56
|
```python
|
|
53
57
|
from mlx_segment_ct.medmlx import run
|
|
54
58
|
|
|
@@ -79,6 +83,6 @@ weights report `null` unless the folder carries a MedMLX download revision.
|
|
|
79
83
|
|
|
80
84
|
## License
|
|
81
85
|
|
|
82
|
-
Apache-2.0
|
|
86
|
+
[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.
|
|
83
87
|
|
|
84
88
|
For research and education. Outputs require human review.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Segment CT anatomy automatically or with anatomy names and clicks, using NVIDIA VISTA-3D in native MLX.
|
|
4
4
|
|
|
5
|
-
[CT weights](https://huggingface.co/MedMLX/vista3d-ct-mlx) · [CTMR weights](https://huggingface.co/MedMLX/vista3d-ctmr-mlx)
|
|
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
6
|
|
|
7
7
|
| Input | Output |
|
|
8
8
|
| :--- | :--- |
|
|
@@ -10,9 +10,11 @@ Segment CT anatomy automatically or with anatomy names and clicks, using NVIDIA
|
|
|
10
10
|
|
|
11
11
|
**Apple Silicon · Metal · Python 3.13 / 3.14** · [uv](https://docs.astral.sh/uv/)
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Install
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
+
uv venv --python 3.13
|
|
17
|
+
source .venv/bin/activate
|
|
16
18
|
uv pip install "mlx-segment-ct>=0.3.2"
|
|
17
19
|
```
|
|
18
20
|
|
|
@@ -22,6 +24,8 @@ unknown spatial units are assumed to use millimeters.
|
|
|
22
24
|
The click coordinates below are examples: replace them with voxels inside your
|
|
23
25
|
image and its preprocessed foreground crop. `1` includes a point; `0` excludes it.
|
|
24
26
|
|
|
27
|
+
## Run
|
|
28
|
+
|
|
25
29
|
```python
|
|
26
30
|
from mlx_segment_ct.medmlx import run
|
|
27
31
|
|
|
@@ -52,6 +56,6 @@ weights report `null` unless the folder carries a MedMLX download revision.
|
|
|
52
56
|
|
|
53
57
|
## License
|
|
54
58
|
|
|
55
|
-
Apache-2.0
|
|
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.
|
|
56
60
|
|
|
57
61
|
For research and education. Outputs require human review.
|
|
@@ -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.
|
|
28
|
+
__version__ = "0.3.3"
|
|
29
29
|
|
|
30
30
|
_EXPORTS = {
|
|
31
31
|
"AutomaticModel": "mlx_segment_ct.mlx_network",
|
|
@@ -248,16 +248,18 @@ def preprocess(
|
|
|
248
248
|
NV-Segment-CT's fixed range (``"range"``) or NV-Segment-CTMR's percentiles.
|
|
249
249
|
|
|
250
250
|
``image`` is float32 ``(1, X, Y, Z)`` as ``load_volume`` returns it, and ``affine``
|
|
251
|
-
its voxel-to-world matrix (NIfTI RAS, assumed millimeters).
|
|
252
|
-
scaled to [0, 1] in the usual nondegenerate case (see
|
|
253
|
-
``scale_intensity_percentiles`` for the equal-percentile case)
|
|
254
|
-
|
|
251
|
+
its voxel-to-world matrix (NIfTI RAS, assumed millimeters). Voxel values must
|
|
252
|
+
be finite. They are scaled to [0, 1] in the usual nondegenerate case (see
|
|
253
|
+
``scale_intensity_percentiles`` for the equal-percentile case). The result is
|
|
254
|
+
on the RAS-oriented 1.5 mm foreground crop.
|
|
255
255
|
|
|
256
256
|
Raises:
|
|
257
|
-
InvalidInputError: no voxel is above zero after
|
|
258
|
-
volume does not resample onto the image grid.
|
|
257
|
+
InvalidInputError: image voxels are non-finite, no voxel is above zero after
|
|
258
|
+
resampling, or an ``extra`` volume does not resample onto the image grid.
|
|
259
259
|
ValueError: unknown ``intensity``.
|
|
260
260
|
"""
|
|
261
|
+
if not np.isfinite(image).all():
|
|
262
|
+
raise InvalidInputError("NV-Segment-CT image contains non-finite voxel intensities")
|
|
261
263
|
resampled_image, image_affine = _spacing(image, affine, "bilinear")
|
|
262
264
|
resampled = _Resampled(affine, _shape(image))
|
|
263
265
|
start, end = _foreground_box(resampled_image)
|
|
@@ -125,9 +125,10 @@ def run(
|
|
|
125
125
|
interpolates the scores trilinearly at each source voxel and decides its label
|
|
126
126
|
there, so boundaries follow the source resolution. ``"bundle"`` decides on the
|
|
127
127
|
1.5 mm grid and restores labels with nearest interpolation, as the NVIDIA bundle does.
|
|
128
|
-
Input
|
|
129
|
-
other declared units require conversion before
|
|
130
|
-
are newly constructed and do not retain the
|
|
128
|
+
Input voxel intensities must be finite. Spatial units must be millimeters or
|
|
129
|
+
unknown (assumed millimeters); other declared units require conversion before
|
|
130
|
+
inference. Output NIfTI headers are newly constructed and do not retain the
|
|
131
|
+
source unit code.
|
|
131
132
|
|
|
132
133
|
The published ``MedMLX/vista3d-ct-mlx`` bundle supplies ``automatic.safetensors``
|
|
133
134
|
and ``correction.safetensors`` for ``checkpoint="NV-Segment-CT"``. The
|
|
@@ -234,7 +235,7 @@ def run(
|
|
|
234
235
|
f"NV-Segment-CT output exists: {destination}; pass overwrite=true to replace it"
|
|
235
236
|
)
|
|
236
237
|
weights_root = (
|
|
237
|
-
model_weights_dir("
|
|
238
|
+
model_weights_dir("mlx-segment-ct")
|
|
238
239
|
if weights_path is None else Path(weights_path).expanduser()
|
|
239
240
|
)
|
|
240
241
|
weights_dir = _weights_dir(weights_root, correction=point_mode)
|
|
@@ -271,13 +272,37 @@ def run_ctmr(
|
|
|
271
272
|
"""Run the CTMR variant with its own automatic model folder and fixed settings.
|
|
272
273
|
|
|
273
274
|
Omitted weights use ``MedMLX/vista3d-ctmr-mlx``; an explicit folder contains
|
|
274
|
-
``automatic.safetensors
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
275
|
+
``automatic.safetensors``. CTMR preprocessing and label rules are fixed
|
|
276
|
+
internally, so CT weights are never substituted. The shared point/correction
|
|
277
|
+
arguments are forwarded to ``run``, but NVIDIA does not support point
|
|
278
|
+
segmentation with this checkpoint. Their presence is not a qualification
|
|
279
|
+
of CTMR point inference.
|
|
280
|
+
|
|
281
|
+
Args:
|
|
282
|
+
image_path: Single-channel CT or MRI NIfTI volume; declared spatial units
|
|
283
|
+
must be millimeters or unknown (assumed millimeters).
|
|
284
|
+
output_dir: Directory for the restored label map.
|
|
285
|
+
weights_path: Optional model folder containing ``automatic.safetensors``;
|
|
286
|
+
omit to reuse the automatic CTMR download.
|
|
287
|
+
segment_all: Request all classes for the selected modality; no prompts also
|
|
288
|
+
selects this mode.
|
|
289
|
+
prompt: Anatomy names instead of numeric class IDs.
|
|
290
|
+
label_prompt: Numeric foreground IDs instead of anatomy names.
|
|
291
|
+
previous_logits_path: Advanced shared correction input; requires point
|
|
292
|
+
prompts, which NVIDIA does not support for CTMR.
|
|
293
|
+
points: Advanced shared source-grid ``(x, y, z)`` point coordinates;
|
|
294
|
+
CTMR point inference is not supported by NVIDIA.
|
|
295
|
+
point_labels: Include/exclude codes paired with ``points``.
|
|
296
|
+
point_start: Index of the first new click for the shared point interface.
|
|
297
|
+
interactive: Require the shared point-prompt mode; see its support limit above.
|
|
298
|
+
overwrite: Replace an existing output; inputs remain protected from aliasing.
|
|
299
|
+
modality: All-classes set: ``CT_BODY``, ``MRI_BODY`` or ``MRI_BRAIN``.
|
|
300
|
+
None selects ``MRI_BODY``. Inapplicable to class or point prompts.
|
|
301
|
+
restoration: ``scores`` interpolates scores before selecting labels;
|
|
302
|
+
``bundle`` restores labels with the bundle's nearest-neighbor rule.
|
|
278
303
|
"""
|
|
279
304
|
folder = (
|
|
280
|
-
model_weights_dir("
|
|
305
|
+
model_weights_dir("mlx-segment-ctmr")
|
|
281
306
|
if weights_path is None else Path(weights_path).expanduser()
|
|
282
307
|
)
|
|
283
308
|
return run(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|