Download data from Hub
#5
by
albertvillanova
HF staff
- opened
This view is limited to 50 files because it contains too many changes.
See the raw diff here.
- AeroPath.py +29 -123
- {1 → data/1}/1_CT_HR.nii.gz +0 -0
- {1 → data/1}/1_CT_HR_label_airways.nii.gz +0 -0
- {1 → data/1}/1_CT_HR_label_lungs.nii.gz +0 -0
- {10 → data/10}/10_CT_HR.nii.gz +0 -0
- {10 → data/10}/10_CT_HR_label_airways.nii.gz +0 -0
- {10 → data/10}/10_CT_HR_label_lungs.nii.gz +0 -0
- {11 → data/11}/11_CT_HR.nii.gz +0 -0
- {11 → data/11}/11_CT_HR_label_airways.nii.gz +0 -0
- {11 → data/11}/11_CT_HR_label_lungs.nii.gz +0 -0
- {12 → data/12}/12_CT_HR.nii.gz +0 -0
- {12 → data/12}/12_CT_HR_label_airways.nii.gz +0 -0
- {12 → data/12}/12_CT_HR_label_lungs.nii.gz +0 -0
- {13 → data/13}/13_CT_HR.nii.gz +0 -0
- {13 → data/13}/13_CT_HR_label_airways.nii.gz +0 -0
- {13 → data/13}/13_CT_HR_label_lungs.nii.gz +0 -0
- {14 → data/14}/14_CT_HR.nii.gz +0 -0
- {14 → data/14}/14_CT_HR_label_airways.nii.gz +0 -0
- {14 → data/14}/14_CT_HR_label_lungs.nii.gz +0 -0
- {15 → data/15}/15_CT_HR.nii.gz +0 -0
- {15 → data/15}/15_CT_HR_label_airways.nii.gz +0 -0
- {15 → data/15}/15_CT_HR_label_lungs.nii.gz +0 -0
- {16 → data/16}/16_CT_HR.nii.gz +0 -0
- {16 → data/16}/16_CT_HR_label_airways.nii.gz +0 -0
- {16 → data/16}/16_CT_HR_label_lungs.nii.gz +0 -0
- {17 → data/17}/17_CT_HR.nii.gz +0 -0
- {17 → data/17}/17_CT_HR_label_airways.nii.gz +0 -0
- {17 → data/17}/17_CT_HR_label_lungs.nii.gz +0 -0
- {18 → data/18}/18_CT_HR.nii.gz +0 -0
- {18 → data/18}/18_CT_HR_label_airways.nii.gz +0 -0
- {18 → data/18}/18_CT_HR_label_lungs.nii.gz +0 -0
- {19 → data/19}/19_CT_HR.nii.gz +0 -0
- {19 → data/19}/19_CT_HR_label_airways.nii.gz +0 -0
- {19 → data/19}/19_CT_HR_label_lungs.nii.gz +0 -0
- {2 → data/2}/2_CT_HR.nii.gz +0 -0
- {2 → data/2}/2_CT_HR_label_airways.nii.gz +0 -0
- {2 → data/2}/2_CT_HR_label_lungs.nii.gz +0 -0
- {20 → data/20}/20_CT_HR.nii.gz +0 -0
- {20 → data/20}/20_CT_HR_label_airways.nii.gz +0 -0
- {20 → data/20}/20_CT_HR_label_lungs.nii.gz +0 -0
- {21 → data/21}/21_CT_HR.nii.gz +0 -0
- {21 → data/21}/21_CT_HR_label_airways.nii.gz +0 -0
- {21 → data/21}/21_CT_HR_label_lungs.nii.gz +0 -0
- {22 → data/22}/22_CT_HR.nii.gz +0 -0
- {22 → data/22}/22_CT_HR_label_airways.nii.gz +0 -0
- {22 → data/22}/22_CT_HR_label_lungs.nii.gz +0 -0
- {23 → data/23}/23_CT_HR.nii.gz +0 -0
- {23 → data/23}/23_CT_HR_label_airways.nii.gz +0 -0
- {23 → data/23}/23_CT_HR_label_lungs.nii.gz +0 -0
- {24 → data/24}/24_CT_HR.nii.gz +0 -0
AeroPath.py
CHANGED
@@ -1,29 +1,16 @@
|
|
1 |
-
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
# TODO: Address all TODOs and remove all explanatory comments
|
15 |
-
"""TODO: Add a description here."""
|
16 |
|
17 |
|
18 |
-
import csv
|
19 |
-
import json
|
20 |
-
import os
|
21 |
-
|
22 |
import datasets
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
# TODO: Add BibTeX citation
|
26 |
-
# Find for instance the citation on arxiv or on the dataset repo/website
|
27 |
_CITATION = """\
|
28 |
@misc{støverud2023aeropath,
|
29 |
title={AeroPath: An airway segmentation benchmark dataset with challenging pathology},
|
@@ -35,130 +22,49 @@ primaryClass={cs.CV}
|
|
35 |
}
|
36 |
"""
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
"""
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
# TODO: Add the licence for the dataset here if you can find it
|
48 |
-
_LICENSE = "MIT"
|
49 |
-
|
50 |
-
# TODO: Add link to the official dataset URLs here
|
51 |
-
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
52 |
-
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
53 |
-
_URLS = {
|
54 |
-
#"first_domain": "https://huggingface.co/great-new-dataset-first_domain.zip",
|
55 |
-
#"second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip",
|
56 |
-
"zenodo": "https://zenodo.org/records/10069289/files/AeroPath.zip?download=1"
|
57 |
-
}
|
58 |
|
59 |
|
60 |
-
# TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
|
61 |
class AeroPath(datasets.GeneratorBasedBuilder):
|
62 |
"""An airway segmentation benchmark dataset with challenging pathology."""
|
63 |
|
64 |
VERSION = datasets.Version("1.0.0")
|
65 |
|
66 |
-
# This is an example of a dataset with multiple configurations.
|
67 |
-
# If you don't want/need to define several sub-sets in your dataset,
|
68 |
-
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
69 |
-
|
70 |
-
# If you need to make complex sub-parts in the datasets with configurable options
|
71 |
-
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
72 |
-
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
73 |
-
|
74 |
-
# You will be able to load one or the other configurations in the following list with
|
75 |
-
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
76 |
-
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
77 |
-
BUILDER_CONFIGS = [
|
78 |
-
#datasets.BuilderConfig(name="first_domain", version=VERSION, description="This part of my dataset covers a first domain"),
|
79 |
-
#datasets.BuilderConfig(name="second_domain", version=VERSION, description="This part of my dataset covers a second domain"),
|
80 |
-
datasets.BuilderConfig(name="zenodo", version=VERSION, description="This includes all 27 CTs stored as a single zip on Zenodo"),
|
81 |
-
]
|
82 |
-
|
83 |
-
DEFAULT_CONFIG_NAME = "zenodo" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
84 |
-
|
85 |
-
def __init__(self, **kwargs):
|
86 |
-
super().__init__(**kwargs)
|
87 |
-
self.DATA_DIR = None
|
88 |
-
|
89 |
-
def get_patient(self, patient_id):
|
90 |
-
if (patient_id < 1) or (patiend_id > 27):
|
91 |
-
raise ValueError("patient_id should be an integer in range [1, 27].")
|
92 |
-
|
93 |
def _info(self):
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
# These are the features of your dataset like images, labels ...
|
102 |
-
}
|
103 |
-
)
|
104 |
-
else:
|
105 |
-
raise ValueError("Only 'zenodo' is supported.")# This is an example to show how to have different features for "first_domain" and "second_domain"
|
106 |
-
|
107 |
return datasets.DatasetInfo(
|
108 |
-
# This is the description that will appear on the datasets page.
|
109 |
description=_DESCRIPTION,
|
110 |
-
|
111 |
-
features=features, # Here we define them above because they are different between the two configurations
|
112 |
-
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
113 |
-
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
114 |
-
# supervised_keys=("sentence", "label"),
|
115 |
-
# Homepage of the dataset for documentation
|
116 |
homepage=_HOMEPAGE,
|
117 |
-
# License for the dataset if available
|
118 |
license=_LICENSE,
|
119 |
-
# Citation for the dataset
|
120 |
citation=_CITATION,
|
121 |
)
|
122 |
|
123 |
-
def get_data_dir(self):
|
124 |
-
return self.DATA_DIR
|
125 |
-
|
126 |
def _split_generators(self, dl_manager):
|
127 |
-
|
128 |
-
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
129 |
-
|
130 |
-
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
131 |
-
# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
|
132 |
-
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
133 |
-
urls = _URLS[self.config.name]
|
134 |
-
self.DATA_DIR = dl_manager.download_and_extract(urls)
|
135 |
-
|
136 |
-
# append AeroPath
|
137 |
-
self.DATA_DIR = os.path.join(self.DATA_DIR, "AeroPath")
|
138 |
-
|
139 |
-
print("data is downloaded to:", self.DATA_DIR)
|
140 |
-
|
141 |
return [
|
142 |
datasets.SplitGenerator(
|
143 |
name=datasets.Split.TEST,
|
144 |
# These kwargs will be passed to _generate_examples
|
145 |
gen_kwargs={
|
146 |
-
"
|
147 |
},
|
148 |
),
|
149 |
]
|
150 |
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
155 |
-
for patient_id in os.listdir(self.DATA_DIR):
|
156 |
-
curr_path = os.path.join(self.DATA_DIR, patient_id)
|
157 |
-
if patient_id in ["README.md", "license.md"]:
|
158 |
-
continue
|
159 |
-
yield patient_id, {
|
160 |
-
"ct": os.path.join(curr_path, patient_id + "_CT_HR.nii.gz"),
|
161 |
-
"airways": os.path.join(curr_path, patient_id + "_CT_HR_label_airways.nii.gz"),
|
162 |
-
"lungs": os.path.join(curr_path, patient_id + "_CT_HR_label_lungs.nii.gz"),
|
163 |
-
}
|
164 |
-
|
|
|
1 |
+
"""AeroPath: An airway segmentation benchmark dataset with challenging pathology."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
|
|
|
|
|
|
|
|
|
4 |
import datasets
|
5 |
|
6 |
+
_DESCRIPTION = """\
|
7 |
+
AeroPath: An airway segmentation benchmark dataset with challenging pathology.
|
8 |
+
"""
|
9 |
+
|
10 |
+
_HOMEPAGE = "https://github.com/raidionics/AeroPath"
|
11 |
+
|
12 |
+
_LICENSE = "MIT"
|
13 |
|
|
|
|
|
14 |
_CITATION = """\
|
15 |
@misc{støverud2023aeropath,
|
16 |
title={AeroPath: An airway segmentation benchmark dataset with challenging pathology},
|
|
|
22 |
}
|
23 |
"""
|
24 |
|
25 |
+
_URLS = [
|
26 |
+
{
|
27 |
+
"ct": f"data/{i}/{i}_CT_HR.nii.gz",
|
28 |
+
"airways": f"data/{i}/{i}_CT_HR_label_airways.nii.gz",
|
29 |
+
"lungs": f"data/{i}/{i}_CT_HR_label_lungs.nii.gz",
|
30 |
+
}
|
31 |
+
for i in range(1, 28)
|
32 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
|
|
|
35 |
class AeroPath(datasets.GeneratorBasedBuilder):
|
36 |
"""An airway segmentation benchmark dataset with challenging pathology."""
|
37 |
|
38 |
VERSION = datasets.Version("1.0.0")
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
def _info(self):
|
41 |
+
features = datasets.Features(
|
42 |
+
{
|
43 |
+
"ct": datasets.Value("string"),
|
44 |
+
"airways": datasets.Value("string"),
|
45 |
+
"lungs": datasets.Value("string"),
|
46 |
+
}
|
47 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
return datasets.DatasetInfo(
|
|
|
49 |
description=_DESCRIPTION,
|
50 |
+
features=features,
|
|
|
|
|
|
|
|
|
|
|
51 |
homepage=_HOMEPAGE,
|
|
|
52 |
license=_LICENSE,
|
|
|
53 |
citation=_CITATION,
|
54 |
)
|
55 |
|
|
|
|
|
|
|
56 |
def _split_generators(self, dl_manager):
|
57 |
+
data_dirs = dl_manager.download(_URLS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
return [
|
59 |
datasets.SplitGenerator(
|
60 |
name=datasets.Split.TEST,
|
61 |
# These kwargs will be passed to _generate_examples
|
62 |
gen_kwargs={
|
63 |
+
"data_dirs": data_dirs,
|
64 |
},
|
65 |
),
|
66 |
]
|
67 |
|
68 |
+
def _generate_examples(self, data_dirs):
|
69 |
+
for key, patient in enumerate(data_dirs):
|
70 |
+
yield key, patient
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{1 → data/1}/1_CT_HR.nii.gz
RENAMED
File without changes
|
{1 → data/1}/1_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{1 → data/1}/1_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{10 → data/10}/10_CT_HR.nii.gz
RENAMED
File without changes
|
{10 → data/10}/10_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{10 → data/10}/10_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{11 → data/11}/11_CT_HR.nii.gz
RENAMED
File without changes
|
{11 → data/11}/11_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{11 → data/11}/11_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{12 → data/12}/12_CT_HR.nii.gz
RENAMED
File without changes
|
{12 → data/12}/12_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{12 → data/12}/12_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{13 → data/13}/13_CT_HR.nii.gz
RENAMED
File without changes
|
{13 → data/13}/13_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{13 → data/13}/13_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{14 → data/14}/14_CT_HR.nii.gz
RENAMED
File without changes
|
{14 → data/14}/14_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{14 → data/14}/14_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{15 → data/15}/15_CT_HR.nii.gz
RENAMED
File without changes
|
{15 → data/15}/15_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{15 → data/15}/15_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{16 → data/16}/16_CT_HR.nii.gz
RENAMED
File without changes
|
{16 → data/16}/16_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{16 → data/16}/16_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{17 → data/17}/17_CT_HR.nii.gz
RENAMED
File without changes
|
{17 → data/17}/17_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{17 → data/17}/17_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{18 → data/18}/18_CT_HR.nii.gz
RENAMED
File without changes
|
{18 → data/18}/18_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{18 → data/18}/18_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{19 → data/19}/19_CT_HR.nii.gz
RENAMED
File without changes
|
{19 → data/19}/19_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{19 → data/19}/19_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{2 → data/2}/2_CT_HR.nii.gz
RENAMED
File without changes
|
{2 → data/2}/2_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{2 → data/2}/2_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{20 → data/20}/20_CT_HR.nii.gz
RENAMED
File without changes
|
{20 → data/20}/20_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{20 → data/20}/20_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{21 → data/21}/21_CT_HR.nii.gz
RENAMED
File without changes
|
{21 → data/21}/21_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{21 → data/21}/21_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{22 → data/22}/22_CT_HR.nii.gz
RENAMED
File without changes
|
{22 → data/22}/22_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{22 → data/22}/22_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{23 → data/23}/23_CT_HR.nii.gz
RENAMED
File without changes
|
{23 → data/23}/23_CT_HR_label_airways.nii.gz
RENAMED
File without changes
|
{23 → data/23}/23_CT_HR_label_lungs.nii.gz
RENAMED
File without changes
|
{24 → data/24}/24_CT_HR.nii.gz
RENAMED
File without changes
|