Coverage for /scratch/builds/bob/bob.med.tb/miniconda/conda-bld/bob.med.tb_1637571489937/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/lib/python3.8/site-packages/bob/med/tb/data/montgomery/__init__.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

13 statements  

1#!/usr/bin/env python 

2# coding=utf-8 

3 

4"""Montgomery dataset for computer-aided diagnosis 

5 

6The Montgomery database has been established to foster research 

7in computer-aided diagnosis of pulmonary diseases with a special 

8focus on pulmonary tuberculosis (TB). 

9 

10* Reference: [MONTGOMERY-SHENZHEN-2014]_ 

11* Original resolution (height x width or width x height): 4020 x 4892 

12* Split reference: none 

13* Protocol ``default``: 

14 

15 * Training samples: 64% of TB and healthy CXR (including labels) 

16 * Validation samples: 16% of TB and healthy CXR (including labels) 

17 * Test samples: 20% of TB and healthy CXR (including labels) 

18 

19""" 

20 

21import os 

22import pkg_resources 

23 

24import bob.extension 

25 

26from ..dataset import JSONDataset 

27from ..loader import load_pil_baw, make_delayed 

28 

29_protocols = [ 

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

31 pkg_resources.resource_filename(__name__, "fold_0.json"), 

32 pkg_resources.resource_filename(__name__, "fold_1.json"), 

33 pkg_resources.resource_filename(__name__, "fold_2.json"), 

34 pkg_resources.resource_filename(__name__, "fold_3.json"), 

35 pkg_resources.resource_filename(__name__, "fold_4.json"), 

36 pkg_resources.resource_filename(__name__, "fold_5.json"), 

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

38 pkg_resources.resource_filename(__name__, "fold_7.json"), 

39 pkg_resources.resource_filename(__name__, "fold_8.json"), 

40 pkg_resources.resource_filename(__name__, "fold_9.json"), 

41] 

42 

43def _raw_data_loader(sample): 

44 return dict( 

45 data=load_pil_baw(os.path.join( 

46 bob.extension.rc.get( 

47 "bob.med.tb.montgomery.datadir", os.path.realpath(os.curdir) 

48 ), sample["data"])), 

49 label=sample["label"], 

50 ) 

51 

52 

53def _loader(context, sample): 

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

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

56 return make_delayed(sample, _raw_data_loader) 

57 

58 

59dataset = JSONDataset( 

60 protocols=_protocols, 

61 fieldnames=("data", "label"), 

62 loader=_loader, 

63) 

64"""Montgomery dataset object"""