-
Notifications
You must be signed in to change notification settings - Fork 56
/
conftest.py
60 lines (38 loc) · 1.3 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import os
from typing import List
import pydicom
import pytest
from rt_utils import RTStructBuilder, image_helper
from rt_utils.rtstruct import RTStruct
@pytest.fixture()
def series_path() -> str:
return get_and_test_series_path("mock_data")
@pytest.fixture()
def series_datasets(series_path) -> List[pydicom.Dataset]:
return image_helper.load_dcm_images_from_path(series_path)
@pytest.fixture()
def rtstruct_path(series_path) -> str:
return os.path.join(series_path, "rt.dcm")
@pytest.fixture()
def new_rtstruct() -> RTStruct:
return get_rtstruct("mock_data")
@pytest.fixture()
def oriented_series_path() -> str:
return get_and_test_series_path("oriented_data")
@pytest.fixture()
def oriented_rtstruct() -> RTStruct:
return get_rtstruct("oriented_data")
@pytest.fixture()
def one_slice_series_path() -> str:
return get_and_test_series_path("one_slice_data")
@pytest.fixture()
def one_slice_rtstruct() -> RTStruct:
return get_rtstruct("one_slice_data")
def get_rtstruct(dirname) -> RTStruct:
path = get_and_test_series_path(dirname)
rtstruct = RTStructBuilder.create_new(path)
return rtstruct
def get_and_test_series_path(dirname) -> str:
series_path = os.path.join(os.path.dirname(__file__), dirname)
assert os.path.exists(series_path)
return series_path