Coverage for src/deepdraw/data/drhagis/__init__.py: 93%

14 statements  

« prev     ^ index     » next       coverage.py v7.3.1, created at 2023-11-30 15:00 +0100

1# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch> 

2# 

3# SPDX-License-Identifier: GPL-3.0-or-later 

4 

5"""DRHAGIS dataset for Vessel Segmentation. 

6 

7The DR HAGIS database has been created to aid the development of vessel extraction algorithms 

8suitable for retinal screening programmes. Researchers are encouraged to test their 

9segmentation algorithms using this database. 

10 

11It should be noted that image 24 and 32 are identical, as this fundus image was obtained 

12from a patient exhibiting both diabetic retinopathy and age-related macular degeneration. 

13 

14 

15The images resolutions (height x width) are: 

16 - 4752x3168 or 

17 - 3456x2304 or 

18 - 3126x2136 or 

19 - 2896x1944 or 

20 - 2816x1880 or 

21 

22* Protocol ``default``: 

23 

24 * Training samples: 19 (including labels and masks) 

25 * Test samples: 20 (including labels and masks) 

26""" 

27 

28import os 

29 

30import pkg_resources 

31 

32from ...data.dataset import JSONDataset 

33from ...utils.rc import load_rc 

34from ..loader import load_pil_1, load_pil_rgb, make_delayed 

35 

36_protocols = [ 

37 pkg_resources.resource_filename(__name__, "default.json"), 

38] 

39 

40_root_path = load_rc().get("datadir.drhagis", os.path.realpath(os.curdir)) 

41 

42 

43def _raw_data_loader(sample): 

44 return dict( 

45 data=load_pil_rgb(os.path.join(_root_path, sample["data"])), 

46 label=load_pil_1(os.path.join(_root_path, sample["label"])), 

47 mask=load_pil_1(os.path.join(_root_path, sample["mask"])), 

48 ) 

49 

50 

51def _loader(context, sample): 

52 # "context" is ignored in this case - database is homogeneous 

53 # we returned delayed samples to avoid loading all images at once 

54 return make_delayed(sample, _raw_data_loader) 

55 

56 

57dataset = JSONDataset( 

58 protocols=_protocols, 

59 fieldnames=("data", "label", "mask"), 

60 loader=_loader, 

61) 

62"""DRHAGIS dataset object."""