{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \nimport openslide # for image import rasterio\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport rasterio\nfrom keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nROOT = \"/kaggle/input/prostate-cancer-grade-assessment/\"\n!ls {ROOT}\n\n","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"train = pd.read_csv(ROOT+\"train.csv\")\ntest = pd.read_csv(ROOT+\"test.csv\")\nsub = pd.read_csv(ROOT+\"sample_submission.csv\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Print top 3 results \ntrain.head(5)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.info()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import matplotlib.pyplot as plt \nimport seaborn as sns \nsns.set()\nax = sns.countplot(y = train['isup_grade'])\nplt.title(\"Image distribution\")\nplt.xlabel('Severity of the cancer (isup_grade)')\nplt.ylabel('Image Count')\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.countplot(y = train[\"gleason_score\"])\nplt.tight_layout()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Some Examples of images "},{"metadata":{"trusted":true},"cell_type":"code","source":"path = '/kaggle/input/prostate-cancer-grade-assessment/train_images/'\nfg = [0, 6, 46, 15, 2 ,32]\nfor i in range(len(fg)):\n    a = path +train['image_id'][fg[i]]+'.tiff'\n    src = rasterio.open(a)\n    array = src.read(1)\n    from matplotlib import pyplot\n    plt.figure(figsize= [10,10])\n    #plt.subplot(221)\n    plt.title('Severity of the cancer: '+str(train['isup_grade'][fg[i]]) )\n    pyplot.imshow(array)\n    pyplot.show() \n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Masks of one of the above image"},{"metadata":{"trusted":true},"cell_type":"code","source":"mask_path = '/kaggle/input/prostate-cancer-grade-assessment/train_label_masks/'\nfg = [0, 6, 46, 15, 2 ,32]\ni = 0\na = mask_path +train['image_id'][fg[i]]+'_mask.tiff'\nsrc = rasterio.open(a)\narray = src.read(1)\nfrom matplotlib import pyplot\nplt.figure(figsize= [10,10])\n#plt.subplot(221)\nplt.title('Mask of Severity level cancer: '+str(train['isup_grade'][fg[i]]) )\npyplot.imshow(array, cmap=plt.cm.viridis, interpolation='none', alpha = 0.7)\npyplot.show() ","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Mask over images"},{"metadata":{"trusted":true},"cell_type":"code","source":"from matplotlib import pyplot\nmask_path = '/kaggle/input/prostate-cancer-grade-assessment/train_label_masks/'\npath = '/kaggle/input/prostate-cancer-grade-assessment/train_images/'\nfg = [0, 6, 46, 15, 2 ,32]\nfor i in range(len(fg)):\n    am = mask_path +train['image_id'][fg[i]]+'_mask.tiff'\n    srcm = rasterio.open(am)\n    arraym = srcm.read(1)\n    plt.figure(figsize= [10,10])\n    \n    \n    \n    \n    \n    a = path +train['image_id'][fg[i]]+'.tiff'\n    src = rasterio.open(a)\n    array = src.read(1)\n    plt.title('Mask of Severity level cancer: '+str(train['isup_grade'][fg[i]]) )\n    pyplot.imshow(array)\n    pyplot.imshow(arraym, cmap=plt.cm.viridis, interpolation='none', alpha = 0.6)\n    \n    pyplot.show() ","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}