|
19 | 19 |
|
20 | 20 | label = lb_types.Label(data=lb_types.DicomData(uid="test-uid"),
|
21 | 21 | annotations=dicom_polyline_annotations)
|
| 22 | +label_with_global_key = lb_types.Label( |
| 23 | + data=lb_types.DicomData(global_key="test-global-key"), |
| 24 | + annotations=dicom_polyline_annotations) |
22 | 25 |
|
23 | 26 | label_ndjson = {
|
24 | 27 | 'classifications': [],
|
|
51 | 54 | }],
|
52 | 55 | }
|
53 | 56 |
|
| 57 | +label_ndjson_with_global_key = { |
| 58 | + 'classifications': [], |
| 59 | + 'dataRow': { |
| 60 | + 'globalKey': 'test-global-key' |
| 61 | + }, |
| 62 | + 'name': |
| 63 | + 'dicom_polyline', |
| 64 | + 'groupKey': |
| 65 | + 'axial', |
| 66 | + 'segments': [{ |
| 67 | + 'keyframes': [{ |
| 68 | + 'frame': |
| 69 | + 2, |
| 70 | + 'line': [ |
| 71 | + { |
| 72 | + 'x': 680.0, |
| 73 | + 'y': 100.0 |
| 74 | + }, |
| 75 | + { |
| 76 | + 'x': 100.0, |
| 77 | + 'y': 190.0 |
| 78 | + }, |
| 79 | + { |
| 80 | + 'x': 190.0, |
| 81 | + 'y': 220.0 |
| 82 | + }, |
| 83 | + ] |
| 84 | + }] |
| 85 | + }], |
| 86 | +} |
| 87 | + |
54 | 88 |
|
55 | 89 | def test_serialize_dicom_polyline_annotation():
|
56 | 90 | serialized_label = next(NDJsonConverter().serialize([label]))
|
57 | 91 | serialized_label.pop('uuid')
|
58 | 92 | assert serialized_label == label_ndjson
|
59 | 93 |
|
60 | 94 |
|
| 95 | +def test_serialize_dicom_polyline_annotation_with_global_key(): |
| 96 | + serialized_label = next(NDJsonConverter().serialize([label_with_global_key |
| 97 | + ])) |
| 98 | + serialized_label.pop('uuid') |
| 99 | + assert serialized_label == label_ndjson_with_global_key |
| 100 | + |
| 101 | + |
61 | 102 | def test_deserialize_dicom_polyline_annotation():
|
62 | 103 | deserialized_label = next(NDJsonConverter().deserialize([label_ndjson]))
|
63 | 104 | deserialized_label.annotations[0].extra.pop('uuid')
|
64 | 105 | assert deserialized_label == label
|
65 | 106 |
|
66 | 107 |
|
| 108 | +def test_deserialize_dicom_polyline_annotation_with_global_key(): |
| 109 | + deserialized_label = next(NDJsonConverter().deserialize( |
| 110 | + [label_ndjson_with_global_key])) |
| 111 | + deserialized_label.annotations[0].extra.pop('uuid') |
| 112 | + assert deserialized_label == label_with_global_key |
| 113 | + |
| 114 | + |
67 | 115 | def test_serialize_deserialize_dicom_polyline_annotation():
|
68 | 116 | labels = list(NDJsonConverter.deserialize([label_ndjson]))
|
69 | 117 | res = list(NDJsonConverter.serialize(labels))
|
70 | 118 | res[0].pop('uuid')
|
71 | 119 | assert res == [label_ndjson]
|
72 | 120 |
|
73 | 121 |
|
| 122 | +def test_serialize_deserialize_dicom_polyline_annotation_with_global_key(): |
| 123 | + labels = list(NDJsonConverter.deserialize([label_ndjson_with_global_key])) |
| 124 | + res = list(NDJsonConverter.serialize(labels)) |
| 125 | + res[0].pop('uuid') |
| 126 | + assert res == [label_ndjson_with_global_key] |
| 127 | + |
| 128 | + |
74 | 129 | def test_deserialize_nd_dicom_segments():
|
75 | 130 | nd_dicom_segments = NDDicomSegments(**label_ndjson)
|
76 | 131 | assert isinstance(nd_dicom_segments, NDDicomSegments)
|
|
0 commit comments