Update prostate158.py
Browse files- prostate158.py +42 -42
prostate158.py
CHANGED
|
@@ -17,16 +17,16 @@ class Prostate158Dataset(datasets.GeneratorBasedBuilder):
|
|
| 17 |
version=VERSION,
|
| 18 |
description="Return all the dataset in a 2d image format",
|
| 19 |
),
|
| 20 |
-
datasets.BuilderConfig(
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
),
|
| 25 |
-
datasets.BuilderConfig(
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
),
|
| 30 |
datasets.BuilderConfig(
|
| 31 |
name="3d_path",
|
| 32 |
version=VERSION,
|
|
@@ -48,16 +48,16 @@ class Prostate158Dataset(datasets.GeneratorBasedBuilder):
|
|
| 48 |
"adc_tumor_reader1": datasets.Image(),
|
| 49 |
}
|
| 50 |
)
|
| 51 |
-
elif self.config.name == "2d_array":
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
|
| 62 |
elif self.config.name == "3d_path":
|
| 63 |
features = datasets.Features(
|
|
@@ -70,16 +70,16 @@ class Prostate158Dataset(datasets.GeneratorBasedBuilder):
|
|
| 70 |
}
|
| 71 |
)
|
| 72 |
|
| 73 |
-
elif self.config.name == "3d_array":
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
|
| 84 |
return datasets.DatasetInfo(
|
| 85 |
description=_DESCRIPTION,
|
|
@@ -130,22 +130,22 @@ class Prostate158Dataset(datasets.GeneratorBasedBuilder):
|
|
| 130 |
yield_index += 1
|
| 131 |
yield yield_index, {image_name: Image.fromarray(image[:, :, i]) for image_name, image in images_data.items()}
|
| 132 |
|
| 133 |
-
elif self.config.name == "2d_array":
|
| 134 |
-
|
| 135 |
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
|
| 143 |
elif self.config.name == "3d_path":
|
| 144 |
for idx, row in enumerate(df.to_dict(orient="records")):
|
| 145 |
yield idx, {image_name+"_path": downloaded_files / row[image_name] for image_name in images_list}
|
| 146 |
|
| 147 |
-
elif self.config.name == "3d_array":
|
| 148 |
-
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
|
|
|
| 17 |
version=VERSION,
|
| 18 |
description="Return all the dataset in a 2d image format",
|
| 19 |
),
|
| 20 |
+
# datasets.BuilderConfig(
|
| 21 |
+
# name="2d_array",
|
| 22 |
+
# version=VERSION,
|
| 23 |
+
# description="Return all the dataset in a 2d array format",
|
| 24 |
+
# ),
|
| 25 |
+
# datasets.BuilderConfig(
|
| 26 |
+
# name="3d_array",
|
| 27 |
+
# version=VERSION,
|
| 28 |
+
# description="Return all the dataset in a 2d array format",
|
| 29 |
+
# ),
|
| 30 |
datasets.BuilderConfig(
|
| 31 |
name="3d_path",
|
| 32 |
version=VERSION,
|
|
|
|
| 48 |
"adc_tumor_reader1": datasets.Image(),
|
| 49 |
}
|
| 50 |
)
|
| 51 |
+
# elif self.config.name == "2d_array":
|
| 52 |
+
# features = datasets.Features(
|
| 53 |
+
# {
|
| 54 |
+
# "t2": datasets.Array2D(shape=(200,200), dtype="int"),
|
| 55 |
+
# "adc": datasets.Array2D(shape=(200,200), dtype="int"),
|
| 56 |
+
# "dwi": datasets.Array2D(shape=(200,200), dtype="int"),
|
| 57 |
+
# "t2_anatomy_reader1": datasets.Array2D(shape=(200,200), dtype="int"),
|
| 58 |
+
# "adc_tumor_reader1": datasets.Array2D(shape=(200,200), dtype="int"),
|
| 59 |
+
# }
|
| 60 |
+
# )
|
| 61 |
|
| 62 |
elif self.config.name == "3d_path":
|
| 63 |
features = datasets.Features(
|
|
|
|
| 70 |
}
|
| 71 |
)
|
| 72 |
|
| 73 |
+
# elif self.config.name == "3d_array":
|
| 74 |
+
# features = datasets.Features(
|
| 75 |
+
# {
|
| 76 |
+
# "t2": datasets.Array3D(shape=(200,200,20), dtype="int"),
|
| 77 |
+
# "adc": datasets.Array3D(shape=(200,200,20), dtype="int"),
|
| 78 |
+
# "dwi": datasets.Array3D(shape=(200,200,20), dtype="int"),
|
| 79 |
+
# "t2_anatomy_reader1": datasets.Array3D(shape=(200,200,20), dtype="int"),
|
| 80 |
+
# "adc_tumor_reader1": datasets.Array3D(shape=(200,200,20), dtype="int"),
|
| 81 |
+
# }
|
| 82 |
+
# )
|
| 83 |
|
| 84 |
return datasets.DatasetInfo(
|
| 85 |
description=_DESCRIPTION,
|
|
|
|
| 130 |
yield_index += 1
|
| 131 |
yield yield_index, {image_name: Image.fromarray(image[:, :, i]) for image_name, image in images_data.items()}
|
| 132 |
|
| 133 |
+
# elif self.config.name == "2d_array":
|
| 134 |
+
# import nibabel as nib
|
| 135 |
|
| 136 |
+
# yield_index = -1
|
| 137 |
+
# for row in df.to_dict(orient="records"):
|
| 138 |
+
# images_data = {image_name: nib.load(downloaded_files / row[image_name]).get_fdata() for image_name in images_list}
|
| 139 |
+
# for i in range(images_data["t2"].shape[2]):
|
| 140 |
+
# yield_index += 1
|
| 141 |
+
# yield yield_index, {image_name: image[:, :, i] for image_name, image in images_data.items()}
|
| 142 |
|
| 143 |
elif self.config.name == "3d_path":
|
| 144 |
for idx, row in enumerate(df.to_dict(orient="records")):
|
| 145 |
yield idx, {image_name+"_path": downloaded_files / row[image_name] for image_name in images_list}
|
| 146 |
|
| 147 |
+
# elif self.config.name == "3d_array":
|
| 148 |
+
# import nibabel as nib
|
| 149 |
|
| 150 |
+
# for idx, row in enumerate(df.to_dict(orient="records")):
|
| 151 |
+
# yield idx, {image_name: nib.load(downloaded_files / row[image_name]).get_fdata() for image_name in images_list}
|