|
37 | 37 | "* Data pre-processing functions, as typically pathology data is given as a whole slide, which cannot be directly used for training as it's too large in size, in particular check `consep_nuclei_dataset`\n",
|
38 | 38 | "* Uses the dataset: \n",
|
39 | 39 | "\n",
|
40 |
| - "This model is trained using [DenseNet121](https://docs.monai.io/en/latest/networks.html#densenet121) over [ConSeP](https://warwick.ac.uk/fac/cross_fac/tia/data/hovernet) dataset. \n", |
| 40 | + "This model is trained using [DenseNet121](https://docs.monai.io/en/latest/networks.html#densenet121) over [CoNSeP](https://warwick.ac.uk/fac/cross_fac/tia/data/hovernet) dataset. \n", |
41 | 41 | "\n",
|
42 | 42 | "> Please note that this model uses existing label mask as additional signal input while training.\n",
|
43 | 43 | "\n",
|
|
92 | 92 | "import torch.distributed\n",
|
93 | 93 | "from IPython.display import Image as IImage\n",
|
94 | 94 | "from monai.apps.nuclick.transforms import AddLabelAsGuidanced, SetLabelClassd, SplitLabeld\n",
|
95 |
| - "from monai.apps.utils import download_and_extract\n", |
96 | 95 | "from monai.config import IgniteInfo, print_config\n",
|
97 | 96 | "from monai.data import CacheDataset, DataLoader\n",
|
98 | 97 | "from monai.engines import SupervisedEvaluator, SupervisedTrainer\n",
|
|
146 | 145 | "cell_type": "markdown",
|
147 | 146 | "metadata": {},
|
148 | 147 | "source": [
|
149 |
| - "## Configure Workspace Path" |
150 |
| - ] |
151 |
| - }, |
152 |
| - { |
153 |
| - "cell_type": "code", |
154 |
| - "execution_count": 4, |
155 |
| - "metadata": {}, |
156 |
| - "outputs": [ |
157 |
| - { |
158 |
| - "name": "stderr", |
159 |
| - "output_type": "stream", |
160 |
| - "text": [ |
161 |
| - "consep_dataset.zip: 146MB [00:23, 6.41MB/s] " |
162 |
| - ] |
163 |
| - }, |
164 |
| - { |
165 |
| - "name": "stdout", |
166 |
| - "output_type": "stream", |
167 |
| - "text": [ |
168 |
| - "2022-12-06 10:46:41,905 - INFO - Downloaded: /tmp/tmp834vb_2l/consep_dataset.zip\n", |
169 |
| - "2022-12-06 10:46:41,907 - INFO - Expected md5 is None, skip md5 check for file /tmp/tmp834vb_2l/consep_dataset.zip.\n", |
170 |
| - "2022-12-06 10:46:41,910 - INFO - Writing into directory: workspace.\n" |
171 |
| - ] |
172 |
| - }, |
173 |
| - { |
174 |
| - "name": "stderr", |
175 |
| - "output_type": "stream", |
176 |
| - "text": [ |
177 |
| - "\n" |
178 |
| - ] |
179 |
| - } |
180 |
| - ], |
181 |
| - "source": [ |
182 |
| - "consep_zip = \"https://warwick.ac.uk/fac/cross_fac/tia/data/hovernet/consep_dataset.zip\"\n", |
183 |
| - "consep_dir = os.path.join(workspace_path, \"CoNSeP\")\n", |
184 |
| - "\n", |
185 |
| - "if not os.path.exists(consep_dir):\n", |
186 |
| - " download_and_extract(consep_zip, output_dir=workspace_path)" |
| 148 | + "## Configure Workspace Path\n", |
| 149 | + "The datasets used in the examples are from [CoNSeP](https://warwick.ac.uk/fac/cross_fac/tia/data/HoVerNet/). Each user is responsible for checking the content of datasets and the applicable licenses and determining if suitable for the intended use." |
187 | 150 | ]
|
188 | 151 | },
|
189 | 152 | {
|
|
204 | 167 | }
|
205 | 168 | ],
|
206 | 169 | "source": [
|
| 170 | + "# consep_dir points to the root directory of the consep dataset\n", |
| 171 | + "consep_dir = os.path.join(workspace_path, \"CoNSeP\")\n", |
| 172 | + "\n", |
207 | 173 | "IImage(filename=os.path.join(consep_dir, \"Train\", \"Overlay\", \"train_8.png\"))"
|
208 | 174 | ]
|
209 | 175 | },
|
|
213 | 179 | "source": [
|
214 | 180 | "## Pre-processing utility functions\n",
|
215 | 181 | "\n",
|
216 |
| - "`consep_nuclei_dataset` reads the raw Image and Matlab files provided in ConSeP dataset. For each Nuclei it tries to create a patch of 128x128 with single nuclei labeled with correspnding class index and rest of the nuclei falling in this patch are labeled as others (mask_value: 255)\n", |
| 182 | + "The `consep_nuclei_dataset` function processes the raw image and Matlab files from the CoNSeP dataset. For each nucleus, it generates a 128x128 patch wherein the target nucleus is labeled with its corresponding class index, and all other nuclei within the patch are labeled as 'others' (using a mask value of 255).\n", |
217 | 183 | "\n"
|
218 | 184 | ]
|
219 | 185 | },
|
|
225 | 191 | "source": [
|
226 | 192 | "def consep_nuclei_dataset(datalist, output_dir, crop_size, min_area=80, min_distance=20, limit=0) -> List[Dict]:\n",
|
227 | 193 | " \"\"\"\n",
|
228 |
| - " Utility to pre-process and create dataset list for Patches per Nuclei for training over ConSeP dataset.\n", |
| 194 | + " Utility to pre-process and create a dataset list for Patches per Nuclei for training over CoNSeP dataset.\n", |
229 | 195 | "\n",
|
230 | 196 | " Args:\n",
|
231 | 197 | " datalist: A list of data dictionary. Each entry should at least contain 'image_key': <image filename>.\n",
|
|
0 commit comments