-
Notifications
You must be signed in to change notification settings - Fork 8
3. Visualizing the Results
At this point, we want to see if our model is on the right track by visualizing either the predicted segmentation mask or the patch level classification predictions.
Plotting classification predictions is as simple as:
nohup pathflowai-visualize plot_predictions -i inputs/ -b A01 -p predictions.db -ps 512 -o predictions/A01_512_class_pred.png -al 0.3 -ac "y_pred" -cf 5. -sf 2 &
I have a predictions.db that stores the patch level classification predictions. I access the "y_pred" column of the "512" (-ps) table of this predictions db (-p) (yes, you can store the predictions from multiple patch sizes into the same db) for sample "A01". The ZARR image is extracted from the -i inputs/ directory, and overlaid with the classification predictions. I can mix, or decide how much to show of the classification score versus the original slide image through by setting an alpha (-al), where low alpha focus on the prediction while high alpha focuses on the original image. The image is compressed using -cf (this case compressing each dimension 5x), and more contrast can be enforced using the -sf option. The image is output to predictions/A01_512_class_pred.png. If you have the original SQL db, you can just replace predictions.db with the original annotations to plot and compare.
The task is similar for segmentation tasks (now using patch size 256, accessing original SQL db since prediction db is not stored for segmentation tasks):
nohup pathflowai-visualize plot_predictions -i inputs/ -b A01 -p patch_information.db -ps 256 -c predictions/A01_predict.npy -s -al 0.1 -cf 5. -o predictions/A01_predicted.png &
Just adding the -s flag and specifying a custom (-c) prediction segmentation mask. If -c is not specified, then you can obtain the original segmentations.
A "for" loop of sorts is helpful in quickly accomplishing this for all WSI, better yet if there is some form of job deployment.
There are other types of visualizations, but we will stop here for now and leave it as a task for the user to hunt for more information in the documentation if desired.