Commit e581275e authored by Gabriel Couture's avatar Gabriel Couture

Fix get_rtstruct

parent 7a4985a8
......@@ -9,7 +9,12 @@ from dicomgenerator.exceptions import WrongGeometryError
def _format_spacing(spacing: float) -> str:
return str(spacing).replace('.', '')
spacing_str = str(spacing).replace('.', '')
if '0' not in spacing_str:
spacing_str += '0'
return spacing_str
def get_rtstruct(geometry: str, spacing: float) -> List[pydicom.FileDataset]:
......@@ -39,3 +44,32 @@ def get_rtstruct(geometry: str, spacing: float) -> List[pydicom.FileDataset]:
dicom_paths = [os.path.join(geometry_path, i) for i in dicom_files]
return [pydicom.dcmread(i) for i in dicom_paths]
def get_rtdose(geometry: str, spacing: float) -> List[pydicom.FileDataset]:
"""Get RTSTRUCT DICOM files.
Parameters
----------
geometry
Geometry : {'cones', 'spheres', 'cylinders'}.
spacing
Spacing : {0.2, 1.0, 2.0, 3.0}
Returns
-------
List of DICOM file data set.
"""
directory, _ = os.path.split(__file__)
geometry_path = os.path.join(directory, 'data', 'RTSTRUCT', geometry)
if not os.path.exists(geometry_path):
raise WrongGeometryError("Geometry should be in {'cones', 'spheres', 'cylinders'}")
dicom_files = filter(
lambda p: f'{_format_spacing(spacing)}_' in p and 'X' not in p,
os.listdir(geometry_path)
)
dicom_paths = [os.path.join(geometry_path, i) for i in dicom_files]
return [pydicom.dcmread(i) for i in dicom_paths]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment