Chris Oswald
commited on
Commit
·
00ba0c6
1
Parent(s):
02961c5
minor text edits
Browse files
SPIDER.py
CHANGED
|
@@ -34,7 +34,9 @@ def import_csv_data(filepath: str) -> List[Dict[str, str]]:
|
|
| 34 |
for line in reader:
|
| 35 |
results.append(line)
|
| 36 |
return results
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
|
| 39 |
# TODO: Add BibTeX citation
|
| 40 |
# Find for instance the citation on arxiv or on the dataset repo/website
|
|
@@ -159,10 +161,12 @@ class SPIDER(datasets.GeneratorBasedBuilder):
|
|
| 159 |
)
|
| 160 |
|
| 161 |
def _split_generators(self, dl_manager):
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
|
|
|
|
|
|
| 166 |
|
| 167 |
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
| 168 |
# 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.
|
|
@@ -172,7 +176,6 @@ class SPIDER(datasets.GeneratorBasedBuilder):
|
|
| 172 |
return [
|
| 173 |
datasets.SplitGenerator(
|
| 174 |
name=datasets.Split.TRAIN,
|
| 175 |
-
# These kwargs will be passed to _generate_examples
|
| 176 |
gen_kwargs={
|
| 177 |
"paths_dict": paths_dict,
|
| 178 |
"split": "train",
|
|
@@ -181,7 +184,6 @@ class SPIDER(datasets.GeneratorBasedBuilder):
|
|
| 181 |
),
|
| 182 |
datasets.SplitGenerator(
|
| 183 |
name=datasets.Split.VALIDATION,
|
| 184 |
-
# These kwargs will be passed to _generate_examples
|
| 185 |
gen_kwargs={
|
| 186 |
"paths_dict": paths_dict,
|
| 187 |
"split": "validate",
|
|
@@ -190,7 +192,6 @@ class SPIDER(datasets.GeneratorBasedBuilder):
|
|
| 190 |
),
|
| 191 |
datasets.SplitGenerator(
|
| 192 |
name=datasets.Split.TEST,
|
| 193 |
-
# These kwargs will be passed to _generate_examples
|
| 194 |
gen_kwargs={
|
| 195 |
"paths_dict": paths_dict,
|
| 196 |
"split": "test",
|
|
@@ -199,7 +200,6 @@ class SPIDER(datasets.GeneratorBasedBuilder):
|
|
| 199 |
),
|
| 200 |
]
|
| 201 |
|
| 202 |
-
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 203 |
def _generate_examples(
|
| 204 |
self,
|
| 205 |
paths_dict: Dict[str, str],
|
|
@@ -242,7 +242,6 @@ class SPIDER(datasets.GeneratorBasedBuilder):
|
|
| 242 |
Tuple (unique patient-scan ID, dict of
|
| 243 |
"""
|
| 244 |
# Set constants
|
| 245 |
-
N_PATIENTS = 257
|
| 246 |
train_share = (1.0 - validate_share - test_share)
|
| 247 |
np.random.seed(int(random_seed))
|
| 248 |
|
|
|
|
| 34 |
for line in reader:
|
| 35 |
results.append(line)
|
| 36 |
return results
|
| 37 |
+
|
| 38 |
+
# Define constants
|
| 39 |
+
N_PATIENTS = 257
|
| 40 |
|
| 41 |
# TODO: Add BibTeX citation
|
| 42 |
# Find for instance the citation on arxiv or on the dataset repo/website
|
|
|
|
| 161 |
)
|
| 162 |
|
| 163 |
def _split_generators(self, dl_manager):
|
| 164 |
+
"""
|
| 165 |
+
This method is tasked with downloading/extracting the data
|
| 166 |
+
and defining the splits depending on the configuration
|
| 167 |
+
If several configurations are possible (listed in BUILDER_CONFIGS),
|
| 168 |
+
the configuration selected by the user is in self.config.name
|
| 169 |
+
"""
|
| 170 |
|
| 171 |
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
| 172 |
# 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.
|
|
|
|
| 176 |
return [
|
| 177 |
datasets.SplitGenerator(
|
| 178 |
name=datasets.Split.TRAIN,
|
|
|
|
| 179 |
gen_kwargs={
|
| 180 |
"paths_dict": paths_dict,
|
| 181 |
"split": "train",
|
|
|
|
| 184 |
),
|
| 185 |
datasets.SplitGenerator(
|
| 186 |
name=datasets.Split.VALIDATION,
|
|
|
|
| 187 |
gen_kwargs={
|
| 188 |
"paths_dict": paths_dict,
|
| 189 |
"split": "validate",
|
|
|
|
| 192 |
),
|
| 193 |
datasets.SplitGenerator(
|
| 194 |
name=datasets.Split.TEST,
|
|
|
|
| 195 |
gen_kwargs={
|
| 196 |
"paths_dict": paths_dict,
|
| 197 |
"split": "test",
|
|
|
|
| 200 |
),
|
| 201 |
]
|
| 202 |
|
|
|
|
| 203 |
def _generate_examples(
|
| 204 |
self,
|
| 205 |
paths_dict: Dict[str, str],
|
|
|
|
| 242 |
Tuple (unique patient-scan ID, dict of
|
| 243 |
"""
|
| 244 |
# Set constants
|
|
|
|
| 245 |
train_share = (1.0 - validate_share - test_share)
|
| 246 |
np.random.seed(int(random_seed))
|
| 247 |
|