{"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":"markdown","source":"<center style = \"font-family: 'Lucida Console', 'Courier New', monospace;\">\n    <img src = \"https://storage.googleapis.com/kaggle-competitions/kaggle/37333/logos/header.png\">\n    <h1 style = \"background: rgb(44,169,201);\nbackground: linear-gradient(180deg, rgba(44,169,201,1) 0%, rgba(1,94,125,1) 100%);border-radius: 20px; font-size:30px\">Mayo Clinic - STRIP AI 🩸🔬🩺</h1>\n    <h3 style = \"background: rgb(44,169,201); text-align:center\">Image Classification of Stroke Blood Clot Origin</h3>\n</center>\n\n<div style = \"background: rgb(224,224,224);border-radius: 42px;\">\n    <h1 style = \"font-family: Consolas; text-align:center; color:#FF69B4\">Introduction</h1>\n    <h2 style = \"font-family: Consolas; text-align:center\">Why this Competition ❓</h2>\n    <p style = \"font-family : Lucida Sans Typewriter\">\n     Stroke remains the second-leading cause of death worldwide. Subsequent strokes may be mitigated if physicians can determine stroke etiology, which influences the therapeutic management following stroke events. Healthcare professionals are currently attempting to apply deep learning-based methods to predict ischemic stroke etiology and clot origin. However, unique data formats, image file sizes, as well as the number of available pathology slides create challenges.\n    </p>\n    <h2 style = \"font-family: Consolas; text-align:center\">Goal of Competition 🥅</h2>\n    <p style = \"font-family : Lucida Sans Typewriter\">\n    The goal of this competition is to classify the blood clot origins in ischemic stroke. Using whole slide digital pathology images. The trained model should be able to differentiate between the two major acute ischemic stroke (AIS) etiology subtypes: <b>Cardiac (CE)</b> and <b>Large Artery Atherosclerosis (LAA) </b>.\n    </p>\n    <h2 style = \"font-family: Consolas; text-align:center\">About Organizers 🗃️</h2>\n    <p style = \"font-family : Lucida Sans Typewriter\">\n    <a href = \"https://www.mayoclinic.org/\">The Mayo Clinic </a> is a nonprofit American academic medical center focused on integrated health care, education, and research. Stroke Thromboembolism Registry of Imaging and Pathology (STRIP) is a uniquely large multicenter project led by <a href = \"https://www.mayo.edu/research/labs/neurovascular-research/overview\">Mayo Clinic Neurovascular Lab </a> with the aim of histopathologic characterization of thromboemboli of various etiologies and examining clot composition and its relation to mechanical thrombectomy revascularization.\n    </p>\n</div>\n\n<h2 style = \"font-family: Consolas\">More Details</h2>\n<p style = \"font-family : Lucida Sans Typewriter\">Check <a href = \"https://www.kaggle.com/competitions/mayo-clinic-strip-ai/overview\">competition page</a> for details</p>\n<h2 style = \"font-family : Comic Sans MS\">Let's dive in ⬇️</h2>\n\n<center><img src = \"https://img.shields.io/badge/Upvote-If%20you%20found%20this%20notebook%20useful-blue\" width=400 height = 400></center>\n","metadata":{}},{"cell_type":"markdown","source":"<h2 style = \"font-family: 'Lucida Console', 'Courier New', monospace; border-radius: 25px; font-size:30px; text-align:center; color:black; background-image: url(https://image.freepik.com/free-vector/gradient-background-green-shades_23-2148363157.jpg);\">Import and Install Libraries</h2>","metadata":{}},{"cell_type":"code","source":"#-----------------------------\n## Install Necessary Libraries\n#-----------------------------\n!pip install -U pandas-profiling==3.2.0\n!pip install markupsafe==2.1.1","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-07-16T16:56:55.622548Z","iopub.execute_input":"2022-07-16T16:56:55.623113Z","iopub.status.idle":"2022-07-16T16:57:22.222081Z","shell.execute_reply.started":"2022-07-16T16:56:55.622992Z","shell.execute_reply":"2022-07-16T16:57:22.220732Z"},"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#----------------------------\n## Import Necessary Libraries\n#----------------------------\n\nimport os\nimport sys\nimport shutil\nimport warnings\nwarnings.filterwarnings('ignore')\nfrom tqdm import tqdm\nfrom IPython.display import IFrame\n\nimport numpy as np\nimport pandas as pd\nfrom pandas_profiling import ProfileReport\n\nimport cv2\nimport wandb\nimport PIL\nfrom PIL import Image\nImage.MAX_IMAGE_PIXELS = None\n\nimport matplotlib.pyplot as plt\n%matplotlib inline\nimport seaborn as sns\nsns.set()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T16:57:22.223878Z","iopub.execute_input":"2022-07-16T16:57:22.224209Z","iopub.status.idle":"2022-07-16T16:57:25.492976Z","shell.execute_reply.started":"2022-07-16T16:57:22.224178Z","shell.execute_reply":"2022-07-16T16:57:25.491632Z"},"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h2 style = \"font-family: 'Lucida Console', 'Courier New', monospace; border-radius: 25px; font-size:30px; text-align:center; color:black; background-image: url(https://image.freepik.com/free-vector/gradient-background-green-shades_23-2148363157.jpg);\">Initialization</h2>","metadata":{}},{"cell_type":"code","source":"height, width = 256, 256\n\ntrain_path = \"../input/mayo-jpg-dataset-4x-downsampled/train/\" #\"../input/mayo-clinic-strip-ai/train/\"\nother_path = \"../input/mayo-jpg-dataset-4x-downsampled/other/\" #\"../input/mayo-clinic-strip-ai/other/\"\n\ntrain_paths = [os.path.join(train_path,i) for i in os.listdir(train_path)]\nother_paths = [os.path.join(other_path,i) for i in os.listdir(other_path)]\n\ntrain_df = pd.read_csv(\"../input/mayo-clinic-strip-ai/train.csv\")\nother_df = pd.read_csv(\"../input/mayo-clinic-strip-ai/other.csv\")\n\ntrain_df[\"image_path\"] = train_df[\"image_id\"].map(lambda x : train_path+x+\".jpg\")\nother_df[\"image_path\"] = other_df[\"image_id\"].map(lambda x : other_path+x+\".jpg\")\n\ntrain_df.head(2)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T16:57:25.494723Z","iopub.execute_input":"2022-07-16T16:57:25.495787Z","iopub.status.idle":"2022-07-16T16:57:25.999033Z","shell.execute_reply.started":"2022-07-16T16:57:25.495748Z","shell.execute_reply":"2022-07-16T16:57:25.997677Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style = \"font-family : Lucida Sans Typewriter;background: rgb(224,224,224);border-radius: 25px;\">\n    <h2 style = \"font-family: 'Lucida Console', 'Courier New', monospace; border-radius: 25px; font-size:30px; text-align:center; color:black; background-image: url(https://image.freepik.com/free-vector/gradient-background-green-shades_23-2148363157.jpg);\">Pandas Profiling</h2>\n    <center><img src = \"https://ydataai.github.io/pandas-profiling/docs/assets/logo_header.png\" width=200 height = 200></center>\n    <p style = \"font-family : Lucida Sans Typewriter\">\n    Pandas profiling is an open source Python module with which we can quickly do an exploratory data analysis with just a few lines of code. Besides, if this is not enough to convince us to use this tool, it also generates interactive reports in web format that can be presented to any person, even if they don’t know programming.\n    </p>  \n    <a href = \"https://pandas-profiling.github.io/pandas-profiling/\">Go to offocial website for documentation</a>\n</div>","metadata":{}},{"cell_type":"code","source":"train_report = ProfileReport(train_df,title=\"Metadata of Training images\")\ntrain_report.to_file(\"./train_metadata.html\")\n\nother_report = ProfileReport(other_df,title=\"Metadata of Other images\")\nother_report.to_file(\"./other_metadata.html\")\n\ntrain_report","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h2 style = \"font-family: 'Lucida Console', 'Courier New', monospace; border-radius: 25px; font-size:30px; text-align:center; color:black; background-image: url(https://image.freepik.com/free-vector/gradient-background-green-shades_23-2148363157.jpg);\">Metadata Analysis</h2>","metadata":{}},{"cell_type":"code","source":"fig, ax = plt.subplots(1, 2, figsize=(13,6))\nfig.suptitle(\"Labels Distribution\", weight=\"bold\", size=20)\n\nax[0] = sns.countplot(x=\"label\", data=train_df, ax=ax[0])\nax[0].bar_label(ax[0].containers[0])\nax[0].set_title(\"Training Data\")\n\nax[1] = sns.countplot(x=\"label\", data=other_df, ax=ax[1])\nax[1].bar_label(ax[1].containers[0])\nax[1].set_title(\"Other Data\")","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots(1, 3, figsize=(21,6))\nfig.suptitle(\"Samples Distribution wrto center_id\", weight=\"bold\", size=20)\n\nax[0] = sns.countplot(x=\"center_id\", data=train_df, ax=ax[0])\nax[0].bar_label(ax[0].containers[0])\nax[0].set_title(\"Training Data\")\n\ntmp_df = train_df[train_df[\"label\"] == \"CE\"]\nax[1] = sns.countplot(x=\"center_id\", data=tmp_df, ax=ax[1])\nax[1].bar_label(ax[1].containers[0])\nax[1].set_title(\"Cardioembolic (CE)\")\n\ntmp_df = train_df[train_df[\"label\"] == \"LAA\"]\nax[2] = sns.countplot(x=\"center_id\", data=tmp_df, ax=ax[2])\nax[2].bar_label(ax[2].containers[0])\nax[2].set_title(\"Large Artery Atherosclerosis (LAA)\")","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots(1, 3, figsize=(21,6))\nfig.suptitle(\"Samples Distribution wrto image_num\", weight=\"bold\", size=20)\n\nax[0] = sns.countplot(x=\"image_num\", data=train_df, ax=ax[0])\nax[0].bar_label(ax[0].containers[0])\nax[0].set_title(\"Training Data\")\n\ntmp_df = train_df[train_df[\"label\"] == \"CE\"]\nax[1] = sns.countplot(x=\"image_num\", data=tmp_df, ax=ax[1])\nax[1].bar_label(ax[1].containers[0])\nax[1].set_title(\"Cardioembolic (CE)\")\n\ntmp_df = train_df[train_df[\"label\"] == \"LAA\"]\nax[2] = sns.countplot(x=\"image_num\", data=tmp_df, ax=ax[2])\nax[2].bar_label(ax[2].containers[0])\nax[2].set_title(\"Large Artery Atherosclerosis (LAA)\")","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style = \"font-family : Lucida Sans Typewriter;background: rgb(224,224,224);border-radius: 25px;\">\n    <h2 style = \"font-family: 'Lucida Console', 'Courier New', monospace; border-radius: 25px; font-size:30px; text-align:center; color:black; background-image: url(https://image.freepik.com/free-vector/gradient-background-green-shades_23-2148363157.jpg);\">Weights and Biases</h2>\n    <center><img src = \"https://i.imgur.com/KISYcqD.png\" width=200 height = 200></center>\n    <a href = \"https://wandb.ai/shanmukh/MayoClinic/runs/1tmdud4q\"; style = \"font-family: 'Lucida Console', 'Courier New', monospace; border-radius: 20px; text-align:center; font-size:25px\">Checkout Dashboard created for this notebook</a>\n    <p style = \"font-family : Lucida Sans Typewriter\">\n    Weights and Biases is a set of Machine Learning tools used for experiment tracking, dataset versioning, and collaborating on ML projects. Weights and Biases is useful in many applications such as\n    </p>  \n    <ul>\n          <li>Experiment Tracking</li>\n          <li>Hyperparameter Tuning</li>\n          <li>Data Visualization</li>\n          <li>Data and model Versioning</li>\n          <li>Collaborative Reports</li>\n    </ul>\n    <a href = \"https://wandb.ai/site\">Go to offocial website for more tutorials and Documentation</a>\n</div>","metadata":{}},{"cell_type":"code","source":"from kaggle_secrets import UserSecretsClient\n\ntry:\n    user_secrets = UserSecretsClient()\n    api_key = user_secrets.get_secret(\"wandb_api\")\n    wandb.login(key=api_key)\n    anony = None\nexcept:\n    anony = \"must\"\n    print('''If you want to use your W&B account, Follow these steps :\n            -> go to Add-ons {Below name of notebook} -> Secrets -> Add a new Secret\n            -> Label = wandb_api\n            -> Value = W&B access token from https://wandb.ai/authorize \n         ''')","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-07-16T16:57:26.002313Z","iopub.execute_input":"2022-07-16T16:57:26.00328Z","iopub.status.idle":"2022-07-16T16:57:27.570011Z","shell.execute_reply.started":"2022-07-16T16:57:26.003214Z","shell.execute_reply":"2022-07-16T16:57:27.568829Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"WANDB_CONFIG = {\n   \"competition\" : \"ImageClassification\",\n}\n\nrun = wandb.init(project=\"MayoClinic\", config=WANDB_CONFIG, anonymous=anony)\n\nwb_table = wandb.Table(columns = [\n    'Id', 'Image', 'Center Id', 'Patient Id', 'Image Number', 'Label' \n])","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-07-16T17:18:16.634915Z","iopub.execute_input":"2022-07-16T17:18:16.63733Z","iopub.status.idle":"2022-07-16T17:18:20.254722Z","shell.execute_reply.started":"2022-07-16T17:18:16.637255Z","shell.execute_reply":"2022-07-16T17:18:20.25314Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in tqdm(range(len(train_df)-700)):\n    row = train_df.loc[i]\n    impath = row[\"image_path\"]\n    \n    wb_table.add_data(\n        row[\"image_id\"],\n        wandb.Image(impath),\n        row[\"center_id\"],\n        row[\"patient_id\"],\n        row[\"image_num\"],\n        row[\"label\"]\n    )\n    \nwandb.log({'Training Data Visualization': wb_table})\nwandb.finish()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-07-16T17:18:44.777855Z","iopub.execute_input":"2022-07-16T17:18:44.778345Z","iopub.status.idle":"2022-07-16T17:19:58.172142Z","shell.execute_reply.started":"2022-07-16T17:18:44.778309Z","shell.execute_reply":"2022-07-16T17:19:58.170818Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"frame = IFrame(run.url, width=1080, height=720)\nframe","metadata":{"_kg_hide-input":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style = \"font-family : Lucida Sans Typewriter;background: rgb(224,224,224);border-radius: 25px;\">\n    <h2 style = \"font-family: 'Lucida Console', 'Courier New', monospace; border-radius: 25px; font-size:30px; text-align:center; color:black; background-image: url(https://image.freepik.com/free-vector/gradient-background-green-shades_23-2148363157.jpg);\">Image Format</h2>\n    <p style = \"font-family : Lucida Sans Typewriter\">\n        TIFF or TIF: <b>Tagged Image File Format</b>, represents raster images that are meant for usage on a variety of devices that comply with this file format standard. It is capable of describing bilevel, grayscale, palette-color and full-color image data in several color spaces. It supports lossy as well as lossless compression schemes to choose between space and time for applications using the format. The format is not machine dependent and is free from bounds like processor, operating system, or file systems.\n    </p>  \n    <a href = \"https://docs.fileformat.com/image/tiff/\">See this documentation for more details</a>\n</div>","metadata":{}},{"cell_type":"code","source":"train_h, train_w = [], []\nother_h, other_w = [], []\n\nfor i in tqdm(range(len(train_df))):\n    row = train_df.loc[i]\n    impath = row[\"image_path\"]\n    im = Image.open(impath)\n    w, h = im.size\n    train_w.append(w)\n    train_h.append(h)\n    \nfor i in tqdm(range(len(other_df))):\n    row = other_df.loc[i]\n    impath = row[\"image_path\"]\n    try:\n        im = Image.open(impath)\n        w, h = im.size\n        other_w.append(w)\n        other_h.append(h)\n    except:\n        other_w.append(w)\n        other_h.append(h)\n    \ntrain_df[\"width\"] = train_w\ntrain_df[\"height\"] = train_h\n\nother_df[\"width\"] = other_w\nother_df[\"height\"] = other_h","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h2 style = \"font-family: 'Lucida Console', 'Courier New', monospace; font-size:25px; text-align:center; ; color:#FF69B4\">Image Size Variation</h2>","metadata":{}},{"cell_type":"code","source":"fig, ax = plt.subplots(1,2,figsize=(15,5))\nfig.suptitle(\"Training Data\")\n\nax[0].hist(train_df[\"width\"])\nax[0].set_title(\"Width of Images\")\n\nax[1].hist(train_df[\"height\"])\nax[1].set_title(\"Height of Images\")","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots(1,2,figsize=(15,5))\nfig.suptitle(\"Other Data\")\n\nax[0].hist(other_df[\"width\"])\nax[0].set_title(\"Width of Images\")\n\nax[1].hist(other_df[\"height\"])\nax[1].set_title(\"Height of Images\")","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h2 style = \"font-family: 'Lucida Console', 'Courier New', monospace; font-size:25px; text-align:center; color:#FF69B4\">Classwise Image size variation</h2>","metadata":{}},{"cell_type":"code","source":"import matplotlib.gridspec as gridspec\nimport seaborn as sns\nimport numpy as np\n\nclass SeabornFig2Grid():\n\n    def __init__(self, seaborngrid, fig,  subplot_spec, title):\n        self.fig = fig\n        self.sg = seaborngrid\n        self.title = title\n        self.count = 0\n        self.subplot = subplot_spec\n        if isinstance(self.sg, sns.axisgrid.FacetGrid) or \\\n            isinstance(self.sg, sns.axisgrid.PairGrid):\n            self._movegrid()\n        elif isinstance(self.sg, sns.axisgrid.JointGrid):\n            self._movejointgrid()\n        self._finalize()\n\n    def _movegrid(self):\n        \"\"\" Move PairGrid or Facetgrid \"\"\"\n        self._resize()\n        n = self.sg.axes.shape[0]\n        m = self.sg.axes.shape[1]\n        self.subgrid = gridspec.GridSpecFromSubplotSpec(n,m, subplot_spec=self.subplot)\n        for i in range(n):\n            for j in range(m):\n                self._moveaxes(self.sg.axes[i,j], self.subgrid[i,j])\n\n    def _movejointgrid(self):\n        \"\"\" Move Jointgrid \"\"\"\n        h= self.sg.ax_joint.get_position().height\n        h2= self.sg.ax_marg_x.get_position().height\n        r = int(np.round(h/h2))\n        self._resize()\n        self.subgrid = gridspec.GridSpecFromSubplotSpec(r+1,r+1, subplot_spec=self.subplot)\n        \n        self._moveaxes(self.sg.ax_marg_x, self.subgrid[0, :-1])\n        self._moveaxes(self.sg.ax_marg_y, self.subgrid[1:, -1])\n        self._moveaxes(self.sg.ax_joint, self.subgrid[1:, :-1])\n\n    def _moveaxes(self, ax, gs):\n        ax.remove()\n        ax.figure=self.fig\n        self.fig.axes.append(ax)\n        self.fig.add_axes(ax)\n        ax._subplotspec = gs\n        ax.set_position(gs.get_position(self.fig))\n        ax.set_subplotspec(gs)\n        if self.count == 0:\n            ax.set_title(self.title)\n        self.count += 1\n\n    def _finalize(self):\n        plt.close(self.sg.fig)\n        self.fig.canvas.mpl_connect(\"resize_event\", self._resize)\n        self.fig.canvas.draw()\n\n    def _resize(self, evt=None):\n        self.sg.fig.set_size_inches(self.fig.get_size_inches())","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tmp_df = train_df[train_df[\"label\"] == \"CE\"] \ng1 = sns.jointplot(data=tmp_df,x=\"width\", y=\"height\", kind=\"hex\", color=\"#4CB391\")\n\ntmp_df = train_df[train_df[\"label\"] == \"LAA\"] \ng2 = sns.jointplot(data=tmp_df,x=\"width\", y=\"height\", kind=\"hex\", color=\"#4CB391\")\n\nfig = plt.figure(figsize=(13,6))\nfig.suptitle(\"Training Data\")\ngs = gridspec.GridSpec(1, 2)\n\nmg0 = SeabornFig2Grid(g1, fig, gs[0], \"Cardioembolic (CE)\")\nmg1 = SeabornFig2Grid(g2, fig, gs[1], \"Large Artery Atherosclerosis (LAA)\")\n\ngs.tight_layout(fig)\nplt.show()","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tmp_df = other_df[other_df[\"label\"] == \"Unknown\"] \ng1 = sns.jointplot(data=tmp_df,x=\"width\", y=\"height\", kind=\"hex\", color=\"#4CB391\")\n\ntmp_df = other_df[other_df[\"label\"] == \"Other\"] \ng2 = sns.jointplot(data=tmp_df,x=\"width\", y=\"height\", kind=\"hex\", color=\"#4CB391\")\n\nfig = plt.figure(figsize=(13,6))\nfig.suptitle(\"Other Data\")\ngs = gridspec.GridSpec(1, 2)\n\nmg0 = SeabornFig2Grid(g1, fig, gs[0], \"Unknown\")\nmg1 = SeabornFig2Grid(g2, fig, gs[1], \"Other\")\n\ngs.tight_layout(fig)\nplt.show()","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h2 style = \"font-family: 'Lucida Console', 'Courier New', monospace; font-size:25px; text-align:center; color:#FF69B4\">Samples Images</h2>","metadata":{}},{"cell_type":"code","source":"def plot_images(df, label, num_images):\n    tmp_df = df[df[\"label\"] == label]\n    \n    fig, ax = plt.subplots(1,num_images, figsize=(23,6))\n    fig.suptitle(label, weight=\"bold\", size=20)\n    \n    for i in range(num_images):\n        impath = tmp_df.iloc[i][\"image_path\"]\n        im = Image.open(impath)\n        ax[i].imshow(np.array(im))\n        ax[i].axis(\"off\")\n        ax[i].set_title(tmp_df.iloc[i][\"image_id\"])","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_images(train_df, \"CE\", 5)","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_images(train_df, \"LAA\", 5)","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_images(other_df, \"Unknown\", 5)","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_images(other_df, \"Other\", 5)","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h2 style = \"font-family: 'Lucida Console', 'Courier New', monospace; font-size:25px; text-align:center; color:#FF69B4\">Image at Microscopic Level</h2>","metadata":{}},{"cell_type":"code","source":"##-----------------------------------------------------------------------------\n# Ref: https://www.kaggle.com/code/datark1/eda-images-processing-and-exploration\n##------------------------------------------------------------------------------\nfrom openslide import OpenSlide\n\npath = \"../input/mayo-clinic-strip-ai/train/026c97_0.tif\"\nslide = OpenSlide(path)\n\n\nregion = (1000, 400) \nlevel = 0 \nsize = (3000, 3000) \n\nregion = slide.read_region(region, level, size)\n\nplt.figure(figsize=(15, 15))\nplt.imshow(region)\nplt.show()","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<br>\n<h3 style = \"font-family: Consolas; text-align:center; color:#FF0000\">If you come this far, you could've got some insights from this notebook. An upvote would be very helpful :). Kindly comment if there are any doubts or mistakes</h3>\n\n<center><img src = \"https://img.shields.io/badge/Completed-The%20End-brightgreen\" width=200 height = 200></center>","metadata":{}}]}