| """LyNoS: Mediastinal lymph nodes segmentation using 3D convolutional neural network ensembles and anatomical priors guiding.""" |
|
|
|
|
| import os |
| import csv |
| import json |
|
|
| _DESCRIPTION = """\ |
| LyNoS: Mediastinal lymph nodes segmentation using 3D convolutional neural network ensembles and anatomical priors guiding. |
| """ |
|
|
| _HOMEPAGE = "https://github.com/raidionics/LyNoS" |
|
|
| _LICENSE = "MIT" |
|
|
| _CITATION = """\ |
| @article{bouget2023mediastinal, |
| title={Mediastinal lymph nodes segmentation using 3D convolutional neural network ensembles and anatomical priors guiding}, |
| author={Bouget, David and Pedersen, Andr{\'e} and Vanel, Johanna and Leira, Haakon O and Lang{\o}, Thomas}, |
| journal={Computer Methods in Biomechanics and Biomedical Engineering: Imaging \& Visualization}, |
| volume={11}, |
| number={1}, |
| pages={44--58}, |
| year={2023}, |
| publisher={Taylor \& Francis} |
| } |
| |
| """ |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| _URLS = {"zenodo": "https://zenodo.org/records/10102261/files/LyNoS.zip?download=1"} |
|
|
| class LyNoS(datasets.GeneratorBasedBuilder): |
| """A segmentation benchmark dataset for enlarged lymph nodes in patients with primary lung cancer.""" |
|
|
| VERSION = datasets.Version("1.0.0") |
| DEFAULT_CONFIG_NAME = "zenodo" |
| BUILDER_CONFIGS = [ |
| |
| |
| datasets.BuilderConfig(name="zenodo", version=VERSION, description="This includes all 15 CTs stored as a single zip on Zenodo"), |
| ] |
|
|
| DEFAULT_CONFIG_NAME = "zenodo" |
|
|
| def __init__(self, **kwargs): |
| super().__init__(**kwargs) |
| self.DATA_DIR = None |
|
|
| def get_patient(self, patient_id): |
| if (patient_id < 1) or (patiend_id > 15): |
| raise ValueError("patient_id should be an integer in range [1, 15].") |
|
|
| def _info(self): |
| |
| if self.config.name == "zenodo": |
| features = datasets.Features( |
| { |
| "ct": datasets.Value("string"), |
| "lymphnodes": datasets.Value("string"), |
| "azygos": datasets.Value("string"), |
| "brachiocephalicveins": datasets.Value("string"), |
| "esophagus": datasets.Value("string"), |
| "subclaviancarotidarteries": datasets.Value("string") |
| } |
| ) |
| else: |
| raise ValueError("Only 'zenodo' is supported.") |
|
|
| return datasets.DatasetInfo( |
| |
| description=_DESCRIPTION, |
| |
| features=features, |
| |
| |
| |
| |
| homepage=_HOMEPAGE, |
| |
| license=_LICENSE, |
| |
| citation=_CITATION, |
| ) |
|
|
| def get_data_dir(self): |
| return self.DATA_DIR |
| |
| def _split_generators(self, dl_manager): |
| |
| |
|
|
| |
| |
| |
| urls = _URLS[self.config.name] |
| self.DATA_DIR = dl_manager.download_and_extract(urls) |
|
|
| |
| self.DATA_DIR = os.path.join(self.DATA_DIR, "LyNoS") |
|
|
| print("data is downloaded to:", self.DATA_DIR) |
|
|
| return [ |
| datasets.SplitGenerator( |
| name=datasets.Split.TEST, |
| |
| gen_kwargs={ |
| "split": "test", |
| }, |
| ), |
| ] |
|
|
| |
| def _generate_examples(self, split): |
| |
| |
| for patient_id in os.listdir(self.DATA_DIR): |
| curr_path = os.path.join(self.DATA_DIR, patient_id) |
| if patient_id in ["README.md", "license.md", "stations_sto.csv"]: |
| continue |
| yield patient_id, { |
| "ct": os.path.join(curr_path, patient_id.lower() + "_data.nii.gz"), |
| "lymphnodes": os.path.join(curr_path, patient_id.lower() + "_labels_LymphNodes.nii.gz"), |
| "azygos": os.path.join(curr_path, patient_id.lower() + "_labels_Azygos.nii.gz"), |
| "brachiocephalicveins": os.path.join(curr_path, patient_id.lower() + "_labels_BrachiocephalicVeins.nii.gz"), |
| "esophagus": os.path.join(curr_path, patient_id.lower() + "_labels_Esophagus.nii.gz"), |
| "subclaviancarotidarteries": os.path.join(curr_path, patient_id.lower() + "_labels_SubCarArt.nii.gz") |
| } |
|
|