Commit 7a4985a8 authored by Gabriel Couture's avatar Gabriel Couture

Adding base project and a dao

parent cc1fe9cb
*
!.gitignore
!README.md
!setup.py
!dicomgenerator/
!dicomgenerator/**
!tests/
!tests/**
__pycache__
*.pyc
# DICOMGenerator
DICOM file generator
\ No newline at end of file
DICOM-RT file generator
\ No newline at end of file
# coding: utf-8
# author: Gabriel Couture
# coding: utf-8
# author: Gabriel Couture
import os
from typing import List
import pydicom
from dicomgenerator.exceptions import WrongGeometryError
def _format_spacing(spacing: float) -> str:
return str(spacing).replace('.', '')
def get_rtstruct(geometry: str, spacing: float) -> List[pydicom.FileDataset]:
"""Get RTSTRUCT DICOM files.
Parameters
----------
geometry
Geometry : {'cones', 'spheres', 'cylinders'}.
spacing
Spacing.
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]
,gacou54,obiwan,21.10.2019 12:41,file:///home/gacou54/.config/libreoffice/4;
\ No newline at end of file
,gacou54,obiwan,21.10.2019 12:44,file:///home/gacou54/.config/libreoffice/4;
\ No newline at end of file