{"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_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom skimage import io\nfrom skimage.transform import rescale, resize, downscale_local_mean\nfrom PIL import Image\nImage.MAX_IMAGE_PIXELS = None\n%matplotlib inline","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-07-16T08:14:57.495285Z","iopub.execute_input":"2022-07-16T08:14:57.495846Z","iopub.status.idle":"2022-07-16T08:14:59.53172Z","shell.execute_reply.started":"2022-07-16T08:14:57.495745Z","shell.execute_reply":"2022-07-16T08:14:59.529977Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"TRAIN_DIR = '../input/mayo-clinic-strip-ai/train'\ntrain_df = pd.read_csv('../input/mayo-clinic-strip-ai/train.csv')\nother_df = pd.read_csv('../input/mayo-clinic-strip-ai/other.csv')","metadata":{"execution":{"iopub.status.busy":"2022-07-16T08:14:59.534181Z","iopub.execute_input":"2022-07-16T08:14:59.53462Z","iopub.status.idle":"2022-07-16T08:14:59.561465Z","shell.execute_reply.started":"2022-07-16T08:14:59.534569Z","shell.execute_reply":"2022-07-16T08:14:59.560473Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## **Count of each label**","metadata":{}},{"cell_type":"code","source":"print(f\"Cardioembolic(CE) etiology slides: {len(train_df[train_df['label']=='CE'])}\")","metadata":{"execution":{"iopub.status.busy":"2022-07-16T08:14:59.562763Z","iopub.execute_input":"2022-07-16T08:14:59.563123Z","iopub.status.idle":"2022-07-16T08:14:59.581201Z","shell.execute_reply.started":"2022-07-16T08:14:59.563093Z","shell.execute_reply":"2022-07-16T08:14:59.579695Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"Large Artery Atherosclerosis(LAA) etiology slides: {len(train_df[train_df['label']=='LAA'])}\")","metadata":{"execution":{"iopub.status.busy":"2022-07-16T08:20:40.641935Z","iopub.execute_input":"2022-07-16T08:20:40.642299Z","iopub.status.idle":"2022-07-16T08:20:40.65138Z","shell.execute_reply.started":"2022-07-16T08:20:40.642273Z","shell.execute_reply":"2022-07-16T08:20:40.649544Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"Unknown etiology slides: {len(other_df[other_df['label']=='Unknown'])}\")","metadata":{"execution":{"iopub.status.busy":"2022-07-16T08:14:59.599136Z","iopub.execute_input":"2022-07-16T08:14:59.599668Z","iopub.status.idle":"2022-07-16T08:14:59.614177Z","shell.execute_reply.started":"2022-07-16T08:14:59.599625Z","shell.execute_reply":"2022-07-16T08:14:59.613344Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"Other etiology slides: {len(other_df[other_df['label']=='Other'])}\")","metadata":{"execution":{"iopub.status.busy":"2022-07-16T08:14:59.615312Z","iopub.execute_input":"2022-07-16T08:14:59.615737Z","iopub.status.idle":"2022-07-16T08:14:59.626824Z","shell.execute_reply.started":"2022-07-16T08:14:59.61571Z","shell.execute_reply":"2022-07-16T08:14:59.625375Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## **Image Viz**","metadata":{}},{"cell_type":"code","source":"ce_df = train_df[train_df['label']=='CE']\nce_im = Image.open(f'{TRAIN_DIR}/{ce_df.image_id[0]}.tif')\nce_im_resized = ce_im.resize((ce_im.size[0]//10,ce_im.size[1]//10))","metadata":{"execution":{"iopub.status.busy":"2022-07-16T08:14:59.628685Z","iopub.execute_input":"2022-07-16T08:14:59.629214Z","iopub.status.idle":"2022-07-16T08:15:53.073005Z","shell.execute_reply.started":"2022-07-16T08:14:59.629182Z","shell.execute_reply":"2022-07-16T08:15:53.071515Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"laa_df = train_df[train_df['label']=='LAA']\nlaa_im = Image.open(f'{TRAIN_DIR}/{laa_df.image_id.values[0]}.tif')\nlaa_im_resized = laa_im.resize((laa_im.size[0]//10,laa_im.size[1]//10))\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T08:15:53.074517Z","iopub.execute_input":"2022-07-16T08:15:53.074964Z","iopub.status.idle":"2022-07-16T08:16:10.9936Z","shell.execute_reply.started":"2022-07-16T08:15:53.074919Z","shell.execute_reply":"2022-07-16T08:16:10.992586Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots(1,2,figsize=(20,15))\n\nax[0].imshow(np.rot90(np.array(ce_im_resized)))\nax[0].set_title('Cardioembolic')\nax[0].axis('off')\n\nax[1].imshow(np.rot90(np.array(laa_im_resized)))\nax[1].set_title('Large Artery Atherosclerosis')\nax[1].axis('off')","metadata":{"execution":{"iopub.status.busy":"2022-07-16T08:22:16.415719Z","iopub.execute_input":"2022-07-16T08:22:16.41687Z","iopub.status.idle":"2022-07-16T08:22:23.348971Z","shell.execute_reply.started":"2022-07-16T08:22:16.41683Z","shell.execute_reply":"2022-07-16T08:22:23.34765Z"},"trusted":true},"execution_count":null,"outputs":[]}]}