diff --git a/examples/05-patch-prediction.ipynb b/examples/05-patch-prediction.ipynb index 978f1399f..bf7486ba5 100644 --- a/examples/05-patch-prediction.ipynb +++ b/examples/05-patch-prediction.ipynb @@ -180,7 +180,7 @@ "source": [ "from tiatoolbox.models.engine.patch_predictor import PatchPredictor, IOPatchPredictorConfig\n", "from tiatoolbox.utils.misc import imread, grab_files_from_dir\n", - "from tiatoolbox.utils.visualization import overlay_patch_prediction\n", + "from tiatoolbox.utils.visualization import overlay_prediction_mask\n", "from tiatoolbox.wsicore.wsireader import WSIReader\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", @@ -721,7 +721,7 @@ "source": [ "Here, we show a prediction map where each colour denotes a different predicted category. We overlay the prediction map on the original image. To generate this prediction map, we utilize the `merge_predictions` method from the `PatchPredictor` class which accepts as arguments the path of the original image, `predictor` outputs, `mode` (set to `tile` or `wsi`), `tile_resolution` (at which tiles were originally extracted) and `resolution` (at which the prediction map is generated), and outputs the \"Prediction map\", in which regions have indexed values based on their classes.\n", "\n", - "To visualize the prediction map as an overlay on the input image, we use the`overlay_patch_prediction`function from the `tiatoolbox.utils.visualization` module. It accepts as arguments the original image, the prediction map, the `alpha` parameter which specifies the blending ratio of overlay and original image, and the `label_info` dictionary which contains names and desired colours for different classes. Below we generate an example of an acceptable `label_info` dictionary and show how it can be used with `overlay_patch_prediction`." + "To visualize the prediction map as an overlay on the input image, we use the `overlay_prediction_mask`function from the `tiatoolbox.utils.visualization` module. It accepts as arguments the original image, the prediction map, the `alpha` parameter which specifies the blending ratio of overlay and original image, and the `label_info` dictionary which contains names and desired colours for different classes. Below we generate an example of an acceptable `label_info` dictionary and show how it can be used with `overlay_patch_prediction`." ] }, { @@ -777,7 +777,7 @@ "for class_name, label in label_dict.items():\n", " label_color_dict[label+1] = (class_name, 255*np.array(colors[label]))\n", "pred_map = predictor.merge_predictions(img_file_name, tile_output[0], resolution=1, units='baseline')\n", - "overlay = overlay_patch_prediction(input_tile, pred_map, alpha=0.5, label_info=label_color_dict)\n", + "overlay = overlay_prediction_mask(input_tile, pred_map, alpha=0.5, label_info=label_color_dict)\n", "plt.show()\n" ] }, @@ -787,7 +787,7 @@ "id": "qv4SBdcM6GiT" }, "source": [ - "Note that `overlay_patch_prediction` returns a figure handler, so that `plt.show()` or `plt.savefig()` shows or, respectively, saves the overlay figure generated. Now go back and predict with a different `stride_size` or `pretrained_model` to see what effect this has on the output." + "Note that `overlay_prediction_mask` returns a figure handler, so that `plt.show()` or `plt.savefig()` shows or, respectively, saves the overlay figure generated. Now go back and predict with a different `stride_size` or `pretrained_model` to see what effect this has on the output." ] }, { @@ -939,7 +939,7 @@ "plt.figure(), plt.imshow(wsi_overview); plt.axis('off')\n", "\n", "pred_map = predictor.merge_predictions(wsi_file_name, wsi_output[0], resolution=overview_resolution, units=overview_unit)\n", - "overlay = overlay_patch_prediction(wsi_overview, pred_map, alpha=0.5, label_info=label_color_dict)\n", + "overlay = overlay_prediction_mask(wsi_overview, pred_map, alpha=0.5, label_info=label_color_dict)\n", "plt.show()" ] }, @@ -949,7 +949,7 @@ "id": "J_1pb6BGGbVu" }, "source": [ - "In this notebook, we show how we can use the `PatchPredictor` class and its `predict` method to predict the label for patches of big tiles and WSIs. We introduce `merge_predictions` and `overlay_patch_prediction` helper functions that merge the patch prediction outputs and visualize the resulting prediction map as an overlay on the input image/WSI.\n", + "In this notebook, we show how we can use the `PatchPredictor` class and its `predict` method to predict the label for patches of big tiles and WSIs. We introduce `merge_predictions` and `overlay_prediction_mask` helper functions that merge the patch prediction outputs and visualize the resulting prediction map as an overlay on the input image/WSI.\n", "\n", "All the processes take place within the TIAToolbox and you can easily put the pieces together, following our example code. Just make sure to set inputs and options correctly. We encourage you to further investigate the effect on the prediction output of changing `predict` function parameters. Furthermore, if you want to use your own pretrained model for patch classification in the TIAToolbox framework (even if the model structure is not defined in the TIAToolbox model class), you can follow the instructions in our example notebook on [advanced model techniques](https://github.com/TissueImageAnalytics/tiatoolbox/blob/master/examples/07-advanced-modeling.ipynb) to gain some insights and guidance.\n" ]