41
41
[{"image" : np .array ([[[239 ]], [[239 ]], [[239 ]]], dtype = np .uint8 ), "label" : np .array ([[[1 ]]])}],
42
42
]
43
43
44
+ TEST_CASE_0_L1 = [
45
+ {
46
+ "data" : [{"image" : FILE_PATH , "location" : [0 , 0 ], "label" : [1 ]}],
47
+ "region_size" : (1 , 1 ),
48
+ "grid_shape" : (1 , 1 ),
49
+ "patch_size" : 1 ,
50
+ "level" : 1 ,
51
+ "image_reader_name" : "cuCIM" ,
52
+ },
53
+ [{"image" : np .array ([[[239 ]], [[239 ]], [[239 ]]], dtype = np .uint8 ), "label" : np .array ([[[1 ]]])}],
54
+ ]
55
+
56
+ TEST_CASE_0_L2 = [
57
+ {
58
+ "data" : [{"image" : FILE_PATH , "location" : [0 , 0 ], "label" : [1 ]}],
59
+ "region_size" : (1 , 1 ),
60
+ "grid_shape" : (1 , 1 ),
61
+ "patch_size" : 1 ,
62
+ "level" : 1 ,
63
+ "image_reader_name" : "cuCIM" ,
64
+ },
65
+ [{"image" : np .array ([[[239 ]], [[239 ]], [[239 ]]], dtype = np .uint8 ), "label" : np .array ([[[1 ]]])}],
66
+ ]
67
+
68
+
44
69
TEST_CASE_1 = [
45
70
{
46
71
"data" : [{"image" : FILE_PATH , "location" : [10004 , 20004 ], "label" : [0 , 0 , 0 , 1 ]}],
57
82
],
58
83
]
59
84
85
+
86
+ TEST_CASE_1_L0 = [
87
+ {
88
+ "data" : [{"image" : FILE_PATH , "location" : [10004 , 20004 ], "label" : [0 , 0 , 0 , 1 ]}],
89
+ "region_size" : (8 , 8 ),
90
+ "grid_shape" : (2 , 2 ),
91
+ "patch_size" : 1 ,
92
+ "level" : 0 ,
93
+ "image_reader_name" : "cuCIM" ,
94
+ },
95
+ [
96
+ {"image" : np .array ([[[247 ]], [[245 ]], [[248 ]]], dtype = np .uint8 ), "label" : np .array ([[[0 ]]])},
97
+ {"image" : np .array ([[[245 ]], [[247 ]], [[244 ]]], dtype = np .uint8 ), "label" : np .array ([[[0 ]]])},
98
+ {"image" : np .array ([[[246 ]], [[246 ]], [[246 ]]], dtype = np .uint8 ), "label" : np .array ([[[0 ]]])},
99
+ {"image" : np .array ([[[246 ]], [[246 ]], [[246 ]]], dtype = np .uint8 ), "label" : np .array ([[[1 ]]])},
100
+ ],
101
+ ]
102
+
103
+
104
+ TEST_CASE_1_L1 = [
105
+ {
106
+ "data" : [{"image" : FILE_PATH , "location" : [10004 , 20004 ], "label" : [0 , 0 , 0 , 1 ]}],
107
+ "region_size" : (8 , 8 ),
108
+ "grid_shape" : (2 , 2 ),
109
+ "patch_size" : 1 ,
110
+ "level" : 1 ,
111
+ "image_reader_name" : "cuCIM" ,
112
+ },
113
+ [
114
+ {"image" : np .array ([[[248 ]], [[246 ]], [[249 ]]], dtype = np .uint8 ), "label" : np .array ([[[0 ]]])},
115
+ {"image" : np .array ([[[196 ]], [[187 ]], [[192 ]]], dtype = np .uint8 ), "label" : np .array ([[[0 ]]])},
116
+ {"image" : np .array ([[[245 ]], [[243 ]], [[244 ]]], dtype = np .uint8 ), "label" : np .array ([[[0 ]]])},
117
+ {"image" : np .array ([[[246 ]], [[242 ]], [[243 ]]], dtype = np .uint8 ), "label" : np .array ([[[1 ]]])},
118
+ ],
119
+ ]
60
120
TEST_CASE_2 = [
61
121
{
62
122
"data" : [{"image" : FILE_PATH , "location" : [0 , 0 ], "label" : [1 ]}],
90
150
[{"image" : np .array ([[[239 ]], [[239 ]], [[239 ]]], dtype = np .uint8 ), "label" : np .array ([[[1 ]]])}],
91
151
]
92
152
153
+ TEST_CASE_OPENSLIDE_0_L0 = [
154
+ {
155
+ "data" : [{"image" : FILE_PATH , "location" : [0 , 0 ], "label" : [1 ]}],
156
+ "region_size" : (1 , 1 ),
157
+ "grid_shape" : (1 , 1 ),
158
+ "patch_size" : 1 ,
159
+ "level" : 0 ,
160
+ "image_reader_name" : "OpenSlide" ,
161
+ },
162
+ [{"image" : np .array ([[[239 ]], [[239 ]], [[239 ]]], dtype = np .uint8 ), "label" : np .array ([[[1 ]]])}],
163
+ ]
164
+
165
+ TEST_CASE_OPENSLIDE_0_L1 = [
166
+ {
167
+ "data" : [{"image" : FILE_PATH , "location" : [0 , 0 ], "label" : [1 ]}],
168
+ "region_size" : (1 , 1 ),
169
+ "grid_shape" : (1 , 1 ),
170
+ "patch_size" : 1 ,
171
+ "level" : 1 ,
172
+ "image_reader_name" : "OpenSlide" ,
173
+ },
174
+ [{"image" : np .array ([[[239 ]], [[239 ]], [[239 ]]], dtype = np .uint8 ), "label" : np .array ([[[1 ]]])}],
175
+ ]
176
+
177
+
178
+ TEST_CASE_OPENSLIDE_0_L2 = [
179
+ {
180
+ "data" : [{"image" : FILE_PATH , "location" : [0 , 0 ], "label" : [1 ]}],
181
+ "region_size" : (1 , 1 ),
182
+ "grid_shape" : (1 , 1 ),
183
+ "patch_size" : 1 ,
184
+ "level" : 2 ,
185
+ "image_reader_name" : "OpenSlide" ,
186
+ },
187
+ [{"image" : np .array ([[[239 ]], [[239 ]], [[239 ]]], dtype = np .uint8 ), "label" : np .array ([[[1 ]]])}],
188
+ ]
189
+
93
190
TEST_CASE_OPENSLIDE_1 = [
94
191
{
95
192
"data" : [{"image" : FILE_PATH , "location" : [10004 , 20004 ], "label" : [0 , 0 , 0 , 1 ]}],
@@ -113,7 +210,18 @@ def setUp(self):
113
210
hash_val = testing_data_config ("images" , FILE_KEY , "hash_val" )
114
211
download_url_or_skip_test (FILE_URL , FILE_PATH , hash_type = hash_type , hash_val = hash_val )
115
212
116
- @parameterized .expand ([TEST_CASE_0 , TEST_CASE_1 , TEST_CASE_2 , TEST_CASE_3 ])
213
+ @parameterized .expand (
214
+ [
215
+ TEST_CASE_0 ,
216
+ TEST_CASE_0_L1 ,
217
+ TEST_CASE_0_L2 ,
218
+ TEST_CASE_1 ,
219
+ TEST_CASE_1_L0 ,
220
+ TEST_CASE_1_L1 ,
221
+ TEST_CASE_2 ,
222
+ TEST_CASE_3 ,
223
+ ]
224
+ )
117
225
@skipUnless (has_cim , "Requires CuCIM" )
118
226
def test_read_patches_cucim (self , input_parameters , expected ):
119
227
dataset = PatchWSIDataset (** input_parameters )
@@ -124,7 +232,15 @@ def test_read_patches_cucim(self, input_parameters, expected):
124
232
self .assertIsNone (assert_array_equal (samples [i ]["label" ], expected [i ]["label" ]))
125
233
self .assertIsNone (assert_array_equal (samples [i ]["image" ], expected [i ]["image" ]))
126
234
127
- @parameterized .expand ([TEST_CASE_OPENSLIDE_0 , TEST_CASE_OPENSLIDE_1 ])
235
+ @parameterized .expand (
236
+ [
237
+ TEST_CASE_OPENSLIDE_0 ,
238
+ TEST_CASE_OPENSLIDE_0_L0 ,
239
+ TEST_CASE_OPENSLIDE_0_L1 ,
240
+ TEST_CASE_OPENSLIDE_0_L2 ,
241
+ TEST_CASE_OPENSLIDE_1 ,
242
+ ]
243
+ )
128
244
@skipUnless (has_osl , "Requires OpenSlide" )
129
245
def test_read_patches_openslide (self , input_parameters , expected ):
130
246
dataset = PatchWSIDataset (** input_parameters )
0 commit comments