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_RS/__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"""Extended Montgomery dataset for computer-aided diagnosis  

5(extended with DensenetRS predictions) 

6 

7The Montgomery database has been established to foster research 

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

9focus on pulmonary tuberculosis (TB). 

10 

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

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

13* Split reference: none 

14* Protocol ``default``: 

15 

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

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

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

19 

20""" 

21 

22import os 

23import pkg_resources 

24 

25import bob.extension 

26 

27from ..dataset import JSONDataset 

28from ..loader import make_delayed 

29 

30_protocols = [ 

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

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

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

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

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

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

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

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

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

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

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

42] 

43 

44def _raw_data_loader(sample): 

45 return dict( 

46 data=sample["data"], 

47 label=sample["label"] 

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, key=sample["filename"]) 

55 

56 

57dataset = JSONDataset( 

58 protocols=_protocols, 

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

60 loader=_loader, 

61) 

62"""Extended Montgomery dataset object"""