IXI2D / ixi2d.py
Sergey Kuznetsov
First version of the IXI2D dataset
4db5532
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()},
}