44from pydicom .data import get_testdata_files
55from pydicom .dataset import Dataset , FileMetaDataset
66from pydicom .filereader import dcmread
7+ from pydicom import uid
78
89
910from highdicom ._module_utils import (
@@ -30,10 +31,15 @@ def write_and_read_dataset(dataset: Dataset):
3031 return dcmread (fp , force = True )
3132
3233
33- def find_readable_images () -> list [str ]:
34+ def find_readable_images () -> list [tuple [ str , str | None ] ]:
3435 """Get a list of all images in highdicom and pydicom test data that should
3536 be expected to work with image reading routines.
3637
38+ Returns a list of tuples (path, dependency), where path is the filepath,
39+ and dependency is either None if the file can be read using only required
40+ dependencies, or a str that can be used with pytest.importorskip if an
41+ optional dependency is required to decode pixel data.
42+
3743 """
3844 # All pydicom test files
3945 all_files = get_testdata_files ()
@@ -97,6 +103,19 @@ def find_readable_images() -> list[str]:
97103 if excluded :
98104 continue
99105
100- files_to_use .append (f )
106+ dependency = None
107+ if dcm .file_meta .TransferSyntaxUID in (
108+ uid .JPEGExtended12Bit ,
109+ uid .JPEGLosslessSV1 ,
110+ ):
111+ dependency = "libjpeg"
112+
113+ if dcm .file_meta .TransferSyntaxUID in (
114+ uid .JPEG2000 ,
115+ uid .JPEG2000Lossless ,
116+ ):
117+ dependency = "openjpeg"
118+
119+ files_to_use .append ((f , dependency ))
101120
102121 return files_to_use
0 commit comments