@@ -55,6 +55,9 @@ class CtRate(SubjectsDataset):
5555 added in `this pull request
5656 <https://huggingface.co/datasets/ibrahimhamamci/CT-RATE/discussions/85>`_.
5757 Otherwise, load the original files with incorrect spatial metadata.
58+ verify_paths: If ``True``, verify that the paths to the images exist
59+ during instantiation of the dataset. This might be slow for large that are
60+ not stored locally.
5861 **kwargs: Additional arguments for SubjectsDataset.
5962
6063 Examples:
@@ -101,6 +104,7 @@ def __init__(
101104 report_key : str = 'report' ,
102105 sizes : list [int ] | None = None ,
103106 load_fixed : bool = True ,
107+ verify_paths : bool = False ,
104108 ** kwargs ,
105109 ):
106110 self ._root_dir = Path (root )
@@ -111,6 +115,7 @@ def __init__(
111115 self ._split = self ._parse_split (split )
112116 self .metadata = self ._get_metadata ()
113117 self ._load_fixed = load_fixed
118+ self ._verify_paths = verify_paths
114119 subjects_list = self ._get_subjects_list (self .metadata )
115120 super ().__init__ (subjects_list , ** kwargs )
116121
@@ -323,7 +328,7 @@ def _instantiate_image(self, image_row: pd.Series) -> ScalarImage:
323328 image_path = self ._root_dir / relative_image_path
324329 report_dict = self ._extract_report_dict (image_dict )
325330 image_dict [self ._report_key ] = report_dict
326- image = ScalarImage (image_path , ** image_dict )
331+ image = ScalarImage (image_path , verify_path = self . _verify_paths , ** image_dict )
327332 return image
328333
329334 def _extract_report_dict (self , subject_dict : dict [str , str ]) -> dict [str , str ]:
0 commit comments