pyconvert 0.0.1__py3-none-any.whl

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 pyconvert might be problematic. Click here for more details.

pyconvert/__init__.py ADDED
@@ -0,0 +1,77 @@
1
+ """PyConveRT -- radiotherapy data conversion (early release).
2
+
3
+ PyConveRT converts radiotherapy treatment data between clinical conventions
4
+ (DICOM / NIfTI) and machine-learning-ready formats. This early release ships a
5
+ small, working subset of the coordinate- and dose-unit conversions; the full
6
+ DICOM/NIfTI pipeline is under active development.
7
+
8
+ Developed alongside the companion project PyDoseRT.
9
+ See https://github.com/muw-airo/rt_ai_preprocessing.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ from collections.abc import Sequence
15
+
16
+ __version__ = "0.0.1"
17
+
18
+ __all__ = ["lps_to_ras", "ras_to_lps", "gy_to_cgy", "cgy_to_gy", "__version__"]
19
+
20
+ Point = tuple[float, float, float]
21
+
22
+
23
+ def lps_to_ras(point: Sequence[float]) -> Point:
24
+ """Convert a 3D point from DICOM LPS to NIfTI RAS coordinates.
25
+
26
+ DICOM uses LPS (+x Left, +y Posterior, +z Superior); NIfTI uses RAS
27
+ (+x Right, +y Anterior, +z Superior). The two differ by the sign of the
28
+ first two axes -- the handedness flip at the core of DICOM <-> NIfTI
29
+ geometry. The conversion is its own inverse.
30
+
31
+ Args:
32
+ point: A 3-element (x, y, z) sequence in LPS millimetres.
33
+
34
+ Returns:
35
+ The point in RAS millimetres as an (x, y, z) tuple.
36
+
37
+ Raises:
38
+ ValueError: If ``point`` does not have exactly three elements.
39
+ """
40
+ x, y, z = _as_triplet(point)
41
+ return (-x, -y, z)
42
+
43
+
44
+ def ras_to_lps(point: Sequence[float]) -> Point:
45
+ """Convert a 3D point from NIfTI RAS to DICOM LPS coordinates.
46
+
47
+ Inverse of :func:`lps_to_ras` (the same x/y sign flip).
48
+
49
+ Args:
50
+ point: A 3-element (x, y, z) sequence in RAS millimetres.
51
+
52
+ Returns:
53
+ The point in LPS millimetres as an (x, y, z) tuple.
54
+
55
+ Raises:
56
+ ValueError: If ``point`` does not have exactly three elements.
57
+ """
58
+ x, y, z = _as_triplet(point)
59
+ return (-x, -y, z)
60
+
61
+
62
+ def gy_to_cgy(dose_gy: float) -> float:
63
+ """Convert an absorbed dose from gray (Gy) to centigray (cGy). 1 Gy = 100 cGy."""
64
+ return float(dose_gy) * 100.0
65
+
66
+
67
+ def cgy_to_gy(dose_cgy: float) -> float:
68
+ """Convert an absorbed dose from centigray (cGy) to gray (Gy). 100 cGy = 1 Gy."""
69
+ return float(dose_cgy) / 100.0
70
+
71
+
72
+ def _as_triplet(point: Sequence[float]) -> Point:
73
+ """Validate and coerce a 3-element sequence to a float (x, y, z) tuple."""
74
+ values = tuple(float(v) for v in point)
75
+ if len(values) != 3:
76
+ raise ValueError(f"expected a 3-element (x, y, z) point, got {len(values)} elements")
77
+ return values # type: ignore[return-value]
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyconvert
3
+ Version: 0.0.1
4
+ Summary: PyConveRT: convert radiotherapy treatment data between clinical (DICOM/NIfTI) conventions and ML-ready formats. Early release with a small working subset of coordinate and dose-unit conversions; the full pipeline is under active development.
5
+ Author-email: Matthias Kronsteiner <matthias.kronsteiner@meduniwien.ac.at>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/muw-airo/rt_ai_preprocessing
8
+ Keywords: radiotherapy,dicom,nifti,conversion,medical-imaging
9
+ Classifier: Development Status :: 2 - Pre-Alpha
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
15
+ Requires-Python: >=3.11
16
+ Description-Content-Type: text/markdown
17
+
18
+ # PyConveRT
19
+
20
+ Convert radiotherapy treatment data between clinical conventions (DICOM / NIfTI)
21
+ and machine-learning-ready formats.
22
+
23
+ **Early release (0.0.1, pre-alpha).** This version ships a small, working subset of
24
+ the conversion helpers; the full DICOM/NIfTI preprocessing pipeline is under active
25
+ development. Developed alongside the companion project PyDoseRT.
26
+
27
+ ## Installed and working now
28
+
29
+ ```python
30
+ import pyconvert
31
+
32
+ pyconvert.lps_to_ras((10.0, 20.0, 30.0)) # -> (-10.0, -20.0, 30.0) DICOM LPS -> NIfTI RAS
33
+ pyconvert.ras_to_lps((-10.0, -20.0, 30.0)) # -> (10.0, 20.0, 30.0) NIfTI RAS -> DICOM LPS
34
+ pyconvert.gy_to_cgy(2.0) # -> 200.0 gray -> centigray
35
+ pyconvert.cgy_to_gy(200.0) # -> 2.0 centigray -> gray
36
+ ```
37
+
38
+ Homepage: https://github.com/muw-airo/rt_ai_preprocessing
@@ -0,0 +1,5 @@
1
+ pyconvert/__init__.py,sha256=YuVDiqLhixS7xMlTJv_O7xrZP4SutWyD5CMl_cdUcTk,2503
2
+ pyconvert-0.0.1.dist-info/METADATA,sha256=NicRUcUP9eFY0QDTeQ4XUb2siWvpZD6wdZ-SGX5VB1Y,1761
3
+ pyconvert-0.0.1.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
4
+ pyconvert-0.0.1.dist-info/top_level.txt,sha256=O2YfFu7RSiJOG9jpbfkwcnQECHDEHHg7iy-r4JI5jMQ,10
5
+ pyconvert-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ pyconvert