Skip to content

Commit 669cc5d

Browse files
committed
Merge branch 'typehinting' into main
2 parents 69cd70f + b9b0f27 commit 669cc5d

2 files changed

Lines changed: 36 additions & 13 deletions

File tree

README.md

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img src="https://raw.githubusercontent.com/qurit/rt-utils/main/src/rt-utils-logo.png" height="300"/>
33
</p>
44
<p align="center">
5-
<em>A minimal Python library for RTStruct manipulation</em>
5+
<em>A minimal Python library for RT Struct manipulation</em>
66
</p>
77
<p align="center">
88
<img src="https://github.com/qurit/rt-utils/workflows/Python%20application/badge.svg" height="18">
@@ -13,45 +13,62 @@
1313

1414
---
1515

16-
RT-Utils is motivated to allow physicians and other users to view the results of segmentation performed on a series of DICOM images. RT-Utils allows you to create new RTStructs, easily add one or more regions of interest, and save the resulting RTStruct in just a few lines! Through RT-Utils, you will also be able to load 3D masks from existing RTStruct files.
16+
RT-Utils is motivated to allow physicians and other users to view the results of segmentation performed on a series of DICOM images. RT-Utils allows you to create or load RT Structs, extract 3d masks from RT Struct ROIs, easily add one or more regions of interest, and save the resulting RT Struct in just a few lines!
1717

1818
## How it works
19-
RT-Utils provides a builder class to faciliate the creation and loading of an RTStruct. From there, you can add ROIs through binary masks and optionally input the colour of the region along with the region name.
19+
RT-Utils provides a builder class to faciliate the creation and loading of an RT Struct. From there, you can add ROIs through binary masks and optionally input the colour of the region along with the region name.
2020

21-
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 RTStruct 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.
21+
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.
2222

2323
## Installation
2424
```
2525
pip install rt_utils
2626
```
2727

28-
## Creating new RTStructs
28+
## Creating new RT Structs
2929
```Python
3030
from rt_utils import RTStructBuilder
3131

32+
# Create new RT Struct. Requires the DICOM series path for the RT Struct.
3233
rtstruct = RTStructBuilder.create_new(dicom_series_path="./testlocation")
34+
35+
# ...
36+
# Create mask through means such as ML
37+
# ...
38+
39+
# Add the 3D mask as an ROI.
40+
# The colour, description, and name will be auto generated
41+
rtstruct.add_roi(mask=MASK_FROM_ML_MODEL)
42+
43+
# Add another ROI, this time setting the color, description, and name
3344
rtstruct.add_roi(
3445
mask=MASK_FROM_ML_MODEL,
3546
color=[255, 0, 255],
3647
name="RT-Utils ROI!"
3748
)
38-
rtstruct.save("test-rt-struct.dcm")
49+
50+
rtstruct.save('new-rt-struct')
3951
```
4052

41-
## Loading existing RTStructs
53+
## Loading existing RT Structs
4254
```Python
4355
from rt_utils import RTStructBuilder
56+
import matplotlib.pyplot as plt
4457

58+
# Load existing RT Struct. Requires the series path and existing RT Struct path
4559
rtstruct = RTStructBuilder.create_from(
4660
dicom_series_path="./testlocation",
4761
rt_struct_path="./testlocation/rt-struct.dcm"
4862
)
63+
64+
# Add ROI. This is the same as the above example.
4965
rtstruct.add_roi(
5066
mask=MASK_FROM_ML_MODEL,
5167
color=[255, 0, 255],
5268
name="RT-Utils ROI!"
5369
)
54-
rtstruct.save("updated-rt-struct.dcm")
70+
71+
rtstruct.save('new-rt-struct')
5572
```
5673

5774
## Creation Results
@@ -62,21 +79,27 @@ rtstruct.save("updated-rt-struct.dcm")
6279
The results of a generated ROI with a dummy mask, as viewed in Slicer.
6380
</p>
6481

65-
## Loading an existing RTStruct contour as a mask
82+
## Loading an existing RT Struct contour as a mask
6683
```Python
67-
import matplotlib.pyplot as plt
6884
from rt_utils import RTStructBuilder
85+
import matplotlib.pyplot as plt
6986

87+
# Load existing RT Struct. Requires the series path and existing RT Struct path
7088
rtstruct = RTStructBuilder.create_from(
7189
dicom_series_path="./testlocation",
7290
rt_struct_path="./testlocation/rt-struct.dcm"
7391
)
7492

93+
# View all of the ROI names from within the image
94+
print(rtstruct.get_roi_names())
95+
96+
# Loading the 3D Mask from within the RT Struct
7597
mask_3d = rtstruct.get_roi_mask_by_name("ROI NAME")
98+
99+
# Display one slice of the region
76100
first_mask_slice = mask_3d[:, :, 0]
77-
plt.imshow(first_mask_slice) # View one slice within the mask
101+
plt.imshow(first_mask_slice)
78102
plt.show()
79-
rtstruct.save("updated-rt-struct.dcm")
80103
```
81104

82105
## Loading Results

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import setuptools
22

3-
VERSION = '0.0.7'
3+
VERSION = '1.0.0'
44
with open("README.md", "r", encoding="utf-8") as fh:
55
long_description = fh.read()
66
with open('requirements.txt') as f:

0 commit comments

Comments
 (0)