3
3
from .common import test_input_path , test_output_path
4
4
5
5
6
+ orientation_series = [
7
+ test_input_path / "DicomImageOrientationTest" / "ImageOrientation.1.dcm" ,
8
+ test_input_path / "DicomImageOrientationTest" / "ImageOrientation.2.dcm" ,
9
+ test_input_path / "DicomImageOrientationTest" / "ImageOrientation.3.dcm" ,
10
+ ]
11
+
12
+ mr_series = [
13
+ test_input_path / "dicom-images" / "MR" / "1-001.dcm" ,
14
+ test_input_path / "dicom-images" / "MR" / "1-002.dcm" ,
15
+ test_input_path / "dicom-images" / "MR" / "1-003.dcm" ,
16
+ test_input_path / "dicom-images" / "MR" / "1-004.dcm" ,
17
+ test_input_path / "dicom-images" / "MR" / "1-005.dcm" ,
18
+ ]
19
+
20
+
6
21
def test_one_series ():
22
+ assert orientation_series [0 ].exists ()
23
+ out_of_order = [
24
+ orientation_series [1 ],
25
+ orientation_series [2 ],
26
+ orientation_series [0 ],
27
+ ]
28
+ image_sets = image_sets_normalization (out_of_order )
29
+ assert image_sets
30
+ instances = list (image_sets [0 ]["Study" ]["Series" ].values ())[0 ]["Instances" ].values ()
31
+ sorted_files = [instance ["FileName" ] for instance in instances ]
32
+ assert all (
33
+ file == str (path ) for file , path in zip (sorted_files , orientation_series )
34
+ )
35
+
36
+
37
+ def test_two_series ():
7
38
files = [
8
- test_input_path / "DicomImageOrientationTest" / "ImageOrientation.3.dcm" ,
9
- test_input_path / "DicomImageOrientationTest" / "ImageOrientation.1.dcm" ,
10
- test_input_path / "DicomImageOrientationTest" / "ImageOrientation.2.dcm" ,
39
+ orientation_series [1 ],
40
+ orientation_series [2 ],
41
+ orientation_series [0 ],
42
+ mr_series [3 ],
43
+ mr_series [0 ],
44
+ mr_series [4 ],
45
+ mr_series [2 ],
46
+ mr_series [1 ],
11
47
]
12
48
assert files [0 ].exists ()
13
49
image_sets = image_sets_normalization (files )
14
- print (image_sets )
15
- assert image_sets
16
- sorted_files = list (image_sets .values ())[0 ]
17
- assert sorted_files == [
18
- str (files [1 ]),
19
- str (files [2 ]),
20
- str (files [0 ]),
21
- ]
50
+ assert len (image_sets ) == 2
22
51
23
- # def test_two_series():
24
- # files = [
25
- # test_input_path / "DicomImageOrientationTest" / "ImageOrientation.3.dcm",
26
- # test_input_path / "DicomImageOrientationTest" / "ImageOrientation.1.dcm",
27
- # test_input_path / "DicomImageOrientationTest" / "ImageOrientation.2.dcm",
28
- # test_input_path / "dicom-images" / "MR" / "1-001.dcm",
29
- # test_input_path / "dicom-images" / "MR" / "1-002.dcm",
30
- # test_input_path / "dicom-images" / "MR" / "1-003.dcm",
31
- # test_input_path / "dicom-images" / "MR" / "1-004.dcm",
32
- # test_input_path / "dicom-images" / "MR" / "1-005.dcm",
33
- # ]
34
- # assert files[0].exists()
35
- # image_sets = image_sets_normalization(files)
36
- # assert image_sets
37
- # assert len(image_sets.keys()) == 2
38
52
39
53
# def test_strange_ct():
40
54
# files = [
@@ -43,4 +57,4 @@ def test_one_series():
43
57
# ]
44
58
# image_sets = image_sets_normalization(files)
45
59
# assert image_sets
46
- # print(image_sets)
60
+ # print(image_sets)
0 commit comments