File size: 2,074 Bytes
4db5532
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import datasets

logger = datasets.logging.get_logger(__name__)

_HOMEPAGE = 'https://brain-development.org/ixi-dataset/'

_DESCRIPTION = (
    "This dataset contains around 28000 2D slices extracted from 600 MRI images of healthy subjects."
    " Each MRI volume was skull-stripped, white matter normalized and registered to the 'fsaverage' template using affine transformation. "
)

_URLS = {
    'train': 'data/train.zip',
    'valid': 'data/valid.zip'
}

_LICENSE = """\
LICENSE AGREEMENT
=================
 - The IXI-2D dataset consists of images from IXI Dataset [1] which are
   property of the Biomedical Image Analysis Group, Imperial College London. Any use beyond
   scientific fair use must be negotiated with the respective picture owners
   according to the Creative Commons license [2].
[1] https://brain-development.org/ixi-dataset/
[2] https://creativecommons.org/licenses/by-sa/3.0/legalcode
"""


class IXI2D(datasets.GeneratorBasedBuilder):
    """Food-101 Images dataset"""

    def _info(self):
        return datasets.DatasetInfo(
            features=datasets.Features(
                {
                    "image": datasets.Image(),
                }
            ),
            homepage=_HOMEPAGE,
            description=_DESCRIPTION,
            license=_LICENSE
        )

    def _split_generators(self, dl_manager):
        archive_path = dl_manager.download(_URLS)
        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                gen_kwargs={
                    "images": dl_manager.iter_archive(archive_path['train']),
                },
            ),
            datasets.SplitGenerator(
                name=datasets.Split.VALIDATION,
                gen_kwargs={
                    "images": dl_manager.iter_archive(archive_path['valid']),
                },
            ),
        ]

    def _generate_examples(self, images):
        for file_path, file_obj in images:
            yield file_path, {
                "image": {"path": file_path, "bytes": file_obj.read()},
            }