rt-utils 1.4.0__tar.gz → 1.4.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rt-utils
3
- Version: 1.4.0
3
+ Version: 1.4.1
4
4
  Summary: A small library for handling masks and RT-Structs
5
5
  Author-email: Asim Shrestha <asim.shrestha@hotmail.com>
6
6
  License-Expression: MIT
@@ -33,7 +33,7 @@ Description-Content-Type: text/markdown
33
33
  License-File: LICENSE
34
34
  Requires-Dist: pydicom
35
35
  Requires-Dist: numpy
36
- Requires-Dist: opencv-python>=4.0.0
36
+ Requires-Dist: opencv-python-headless>=4.0.0
37
37
  Provides-Extra: nifti
38
38
  Requires-Dist: SimpleITK; extra == "nifti"
39
39
  Provides-Extra: dev
@@ -71,18 +71,12 @@ RT-Utils provides a builder class to faciliate the creation and loading of an RT
71
71
  The format for the ROI mask is an nd numpy array of type bool. It is an array of 2d binary masks, one plane for each slice location within the DICOM series. The slices should be sorted in ascending order within the mask. Through these masks, we extract the contours of the regions of interest and place them within the RT Struct file. Note that there is currently only support for the use of one frame of reference UID and structered set ROI sequence. Also note that holes within the ROI may be handled poorly.
72
72
 
73
73
  ## Installation
74
- ```
74
+ ```bash
75
75
  pip install rt_utils
76
76
  ```
77
- ##
78
- **libGL**
79
- libGL is a required system dependency. Install it on Linux using:
80
- ```
81
- ```bash
82
- sudo apt install libgl1
83
- ```
77
+
84
78
  ## Installation in editable mode
85
- ```
79
+ ```bash
86
80
  git clone https://github.com/qurit/rt-utils.git
87
81
  cd rt-utils
88
82
  pip install -e .
@@ -26,18 +26,12 @@ RT-Utils provides a builder class to faciliate the creation and loading of an RT
26
26
  The format for the ROI mask is an nd numpy array of type bool. It is an array of 2d binary masks, one plane for each slice location within the DICOM series. The slices should be sorted in ascending order within the mask. Through these masks, we extract the contours of the regions of interest and place them within the RT Struct file. Note that there is currently only support for the use of one frame of reference UID and structered set ROI sequence. Also note that holes within the ROI may be handled poorly.
27
27
 
28
28
  ## Installation
29
- ```
29
+ ```bash
30
30
  pip install rt_utils
31
31
  ```
32
- ##
33
- **libGL**
34
- libGL is a required system dependency. Install it on Linux using:
35
- ```
36
- ```bash
37
- sudo apt install libgl1
38
- ```
32
+
39
33
  ## Installation in editable mode
40
- ```
34
+ ```bash
41
35
  git clone https://github.com/qurit/rt-utils.git
42
36
  cd rt-utils
43
37
  pip install -e .
@@ -38,7 +38,7 @@ classifiers = [
38
38
  dependencies = [
39
39
  "pydicom",
40
40
  "numpy",
41
- "opencv-python>=4.0.0",
41
+ "opencv-python-headless>=4.0.0",
42
42
  ]
43
43
  dynamic = ["version"]
44
44
 
@@ -1,3 +1,3 @@
1
1
  """RT-Utils package version."""
2
2
 
3
- __version__ = "1.4.0"
3
+ __version__ = "1.4.1"
@@ -23,6 +23,26 @@ class RTStruct:
23
23
  """
24
24
  self.ds.SeriesDescription = description
25
25
 
26
+ def _next_roi_number(self) -> int:
27
+ """Return an ROINumber not already used in this structure set.
28
+
29
+ Counting the sequence is not enough. An ROI deleted in another
30
+ application leaves a gap, so len(StructureSetROISequence) + 1 can
31
+ collide with an ROINumber that is still in use. ROINumber is the key
32
+ that ties StructureSetROISequence to ROIContourSequence, so a
33
+ duplicate silently associates two ROIs with the same contours.
34
+
35
+ DICOM numbers ROIs from 1, so an empty structure set yields 1.
36
+ """
37
+ used = []
38
+ for structure_roi in self.ds.StructureSetROISequence:
39
+ try:
40
+ used.append(int(structure_roi.ROINumber))
41
+ except (AttributeError, TypeError, ValueError):
42
+ continue
43
+
44
+ return max(used, default=0) + 1
45
+
26
46
  def add_roi(
27
47
  self,
28
48
  mask: np.ndarray,
@@ -83,7 +103,7 @@ class RTStruct:
83
103
  """
84
104
  # TODO: test if name already exists
85
105
  self.validate_mask(mask)
86
- roi_number = len(self.ds.StructureSetROISequence) + 1
106
+ roi_number = self._next_roi_number()
87
107
  roi_data = ROIData(
88
108
  mask,
89
109
  color,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rt-utils
3
- Version: 1.4.0
3
+ Version: 1.4.1
4
4
  Summary: A small library for handling masks and RT-Structs
5
5
  Author-email: Asim Shrestha <asim.shrestha@hotmail.com>
6
6
  License-Expression: MIT
@@ -33,7 +33,7 @@ Description-Content-Type: text/markdown
33
33
  License-File: LICENSE
34
34
  Requires-Dist: pydicom
35
35
  Requires-Dist: numpy
36
- Requires-Dist: opencv-python>=4.0.0
36
+ Requires-Dist: opencv-python-headless>=4.0.0
37
37
  Provides-Extra: nifti
38
38
  Requires-Dist: SimpleITK; extra == "nifti"
39
39
  Provides-Extra: dev
@@ -71,18 +71,12 @@ RT-Utils provides a builder class to faciliate the creation and loading of an RT
71
71
  The format for the ROI mask is an nd numpy array of type bool. It is an array of 2d binary masks, one plane for each slice location within the DICOM series. The slices should be sorted in ascending order within the mask. Through these masks, we extract the contours of the regions of interest and place them within the RT Struct file. Note that there is currently only support for the use of one frame of reference UID and structered set ROI sequence. Also note that holes within the ROI may be handled poorly.
72
72
 
73
73
  ## Installation
74
- ```
74
+ ```bash
75
75
  pip install rt_utils
76
76
  ```
77
- ##
78
- **libGL**
79
- libGL is a required system dependency. Install it on Linux using:
80
- ```
81
- ```bash
82
- sudo apt install libgl1
83
- ```
77
+
84
78
  ## Installation in editable mode
85
- ```
79
+ ```bash
86
80
  git clone https://github.com/qurit/rt-utils.git
87
81
  cd rt-utils
88
82
  pip install -e .
@@ -1,6 +1,6 @@
1
1
  pydicom
2
2
  numpy
3
- opencv-python>=4.0.0
3
+ opencv-python-headless>=4.0.0
4
4
 
5
5
  [dev]
6
6
  pytest
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes