|
19 | 19 | from monai.apps.pathology.metrics import LesionFROC |
20 | 20 | from monai.utils import optional_import |
21 | 21 |
|
22 | | -_, has_cucim = optional_import("cucim") |
| 22 | +_cucim, has_cucim = optional_import("cucim") |
| 23 | +has_cucim = has_cucim and hasattr(_cucim, "CuImage") |
23 | 24 | _, has_skimage = optional_import("skimage.measure") |
24 | 25 | _, has_sp = optional_import("scipy.ndimage") |
25 | | -PILImage, has_pil = optional_import("PIL.Image") |
| 26 | +imwrite, has_tif = optional_import("tifffile", name="imwrite") |
26 | 27 |
|
27 | 28 |
|
28 | 29 | def save_as_tif(filename, array): |
29 | 30 | array = array[::-1, ...] # Upside-down |
30 | | - img = PILImage.fromarray(array) |
31 | 31 | if not filename.endswith(".tif"): |
32 | 32 | filename += ".tif" |
33 | | - img.save(os.path.join("tests", "testing_data", filename)) |
| 33 | + file_path = os.path.join("tests", "testing_data", filename) |
| 34 | + imwrite(file_path, array, compress="jpeg", tile=(16, 16)) |
34 | 35 |
|
35 | 36 |
|
36 | 37 | def around(val, interval=3): |
@@ -301,7 +302,7 @@ class TestEvaluateTumorFROC(unittest.TestCase): |
301 | 302 | @skipUnless(has_cucim, "Requires cucim") |
302 | 303 | @skipUnless(has_skimage, "Requires skimage") |
303 | 304 | @skipUnless(has_sp, "Requires scipy") |
304 | | - @skipUnless(has_pil, "Requires PIL") |
| 305 | + @skipUnless(has_tif, "Requires tifffile") |
305 | 306 | def setUp(self): |
306 | 307 | prepare_test_data() |
307 | 308 |
|
|
0 commit comments