{"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":"# 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\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom sklearn import feature_extraction, linear_model, model_selection, preprocessing\nimport plotly.graph_objs as go\nimport plotly.offline as py\nimport plotly.express as px\n\n#Ignore warnings\nimport warnings\nwarnings.filterwarnings('ignore')\n\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-input":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-07-08T13:31:27.839183Z","iopub.execute_input":"2022-07-08T13:31:27.83968Z","iopub.status.idle":"2022-07-08T13:31:31.03894Z","shell.execute_reply.started":"2022-07-08T13:31:27.83957Z","shell.execute_reply":"2022-07-08T13:31:31.037667Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Torch Me https://www.kaggle.com/code/kartushovdanil/baseline-amex-catboost-blending-wandb\n\nfrom IPython.core.display import display, HTML, Javascript\n\n# ----- Notebook Theme -----\ncolor_map = ['#f4a261', '#e8f6f3', '#d0ece7', '#a2d9ce', '#73c6b6', '#45b39d', \n                        '#16a085', '#138d75', '#117a65', '#0e6655', '#e76f51']\n\nprompt = color_map[-1]\nmain_color = color_map[0]\nstrong_main_color = color_map[1]\ncustom_colors = [strong_main_color, main_color]\n\ncss_file = ''' \n\ndiv #notebook {\nbackground-color: white;\nline-height: 20px;\n}\n\n#notebook-container {\n%s\nmargin-top: 2em;\npadding-top: 2em;\nborder-top: 4px solid %s; /* Crimson */\n-webkit-box-shadow: 0px 0px 8px 2px rgba(224, 212, 226, 0.5); /* pink */\n    box-shadow: 0px 0px 8px 2px rgba(224, 212, 226, 0.5); /* pink */\n}\n\ndiv .input {\nmargin-bottom: 1em;\n}\n\n.rendered_html h1, .rendered_html h2, .rendered_html h3, .rendered_html h4, .rendered_html h5, .rendered_html h6 {\ncolor: %s; /* Crimson */\nfont-weight: 600;\n}\n\ndiv.input_area {\nborder: none;\n    background-color: %s; /* rgba(229, 143, 101, 0.1); Crimson [exactly #DC143C] */\n    border-top: 2px solid %s; /* Crimson */\n}\n\ndiv.input_prompt {\ncolor: %s; /* light blue */\n}\n\ndiv.output_prompt {\ncolor: %s; /* Crimson */\n}\n\ndiv.cell.selected:before, div.cell.selected.jupyter-soft-selected:before {\nbackground: %s; /* Crimson */\n}\n\ndiv.cell.selected, div.cell.selected.jupyter-soft-selected {\n    border-color: %s; /* Crimson */\n}\n\n.edit_mode div.cell.selected:before {\nbackground: %s; /* Crimson */\n}\n\n.edit_mode div.cell.selected {\nborder-color: %s; /* Crimson */\n\n}\n'''\ndef to_rgb(h): \n    return tuple(int(h[i:i+2], 16) for i in [0, 2, 4])\n\nmain_color_rgba = 'rgba(%s, %s, %s, 0.1)' % (to_rgb(main_color[1:]))\nopen('notebook.css', 'w').write(css_file % ('width: 95%;', main_color, main_color, main_color_rgba, main_color,  main_color, prompt, main_color, main_color, main_color, main_color))\n\ndef nb(): \n    return HTML(\"<style>\" + open(\"notebook.css\", \"r\").read() + \"</style>\")\nnb()","metadata":{"execution":{"iopub.status.busy":"2022-07-08T15:18:23.641768Z","iopub.execute_input":"2022-07-08T15:18:23.642265Z","iopub.status.idle":"2022-07-08T15:18:23.663424Z","shell.execute_reply.started":"2022-07-08T15:18:23.642228Z","shell.execute_reply":"2022-07-08T15:18:23.661972Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Torch Me https://www.kaggle.com/code/kartushovdanil/baseline-amex-catboost-blending-wandb\n\nc1,c2,f1,f2,fs1,fs2=\\\n'#e76f51','#eb3446','Montserrat','Smokum',55,10\ndef dhtml(string:str='sometext', fontcolor='#DC143C', font='Montserrat',fontsize=45):\n    display(HTML(f\"\"\"<style>@import 'https://fonts.googleapis.com/css2?family=Montserrat:wght@900&display=swap'</style><h4 style='font-family: {font}; color: {fontcolor}; font-size: {fontsize}px; text-shadow: 3px 3px #e76f51;'>{string}</h4>\"\"\"))\n    \n    \ndhtml('Ischemic Stroke(AIS) Etiology')","metadata":{"execution":{"iopub.status.busy":"2022-07-08T15:19:33.082994Z","iopub.execute_input":"2022-07-08T15:19:33.083918Z","iopub.status.idle":"2022-07-08T15:19:33.093774Z","shell.execute_reply.started":"2022-07-08T15:19:33.083868Z","shell.execute_reply":"2022-07-08T15:19:33.092597Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"\"A stroke is a medical emergency, and prompt treatment is crucial. Early action can reduce brain damage and other complications.\"\n\n\"Symptoms: Trouble speaking and understanding what others are saying. Paralysis or numbness of the face, arm or leg. Headache. Trouble walking. Problems seeing in one or both eyes.\"\n\nhttps://www.mayoclinic.org/diseases-conditions/stroke/symptoms-causes/syc-20350113#:~:text=Ischemic%20stroke%20occurs%20when%20a,most%20common%20type%20of%20stroke.\n\n\nBy the way, above is just HTML font effect. Not diplopia caused by a stroke. ","metadata":{}},{"cell_type":"code","source":"from openslide import OpenSlide\n\nimport math\nimport time\nimport datetime\nimport glob\n\nimport cv2\nimport matplotlib.pyplot as plt\nimport seaborn as sn\nimport json\n\nimport tifffile as tiff\nfrom matplotlib import colors\nfrom matplotlib import pyplot as plt\nfrom matplotlib.lines import Line2D\nfrom matplotlib_venn import venn2_unweighted","metadata":{"execution":{"iopub.status.busy":"2022-07-08T14:32:57.756136Z","iopub.execute_input":"2022-07-08T14:32:57.757625Z","iopub.status.idle":"2022-07-08T14:32:57.897642Z","shell.execute_reply.started":"2022-07-08T14:32:57.757581Z","shell.execute_reply":"2022-07-08T14:32:57.896161Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Get the unified BCG Strain spreadsheet\ndata = pd.read_csv('/kaggle/input/mayo-clinic-strip-ai/other.csv', delimiter=',')\npd.set_option('display.max_columns', None)\ndata.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-08T13:39:11.136932Z","iopub.execute_input":"2022-07-08T13:39:11.137462Z","iopub.status.idle":"2022-07-08T13:39:11.169444Z","shell.execute_reply.started":"2022-07-08T13:39:11.137421Z","shell.execute_reply":"2022-07-08T13:39:11.168592Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Get the unified BCG Strain spreadsheet\ndata1 = pd.read_csv('/kaggle/input/mayo-clinic-strip-ai/train.csv', delimiter=',')\npd.set_option('display.max_columns', None)\ndata1.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-08T13:47:21.291238Z","iopub.execute_input":"2022-07-08T13:47:21.291831Z","iopub.status.idle":"2022-07-08T13:47:21.315144Z","shell.execute_reply.started":"2022-07-08T13:47:21.29178Z","shell.execute_reply":"2022-07-08T13:47:21.313943Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Etiology = other_specified","metadata":{}},{"cell_type":"markdown","source":"\"The etiology of ischemic stroke is due to either a thrombotic or embolic event that causes a decrease in blood flow to the brain. In a thrombotic event, the blood flow to the brain is obstructed within the blood vessel due to dysfunction within the vessel itself, usually secondary to atherosclerotic disease, arterial dissection, fibromuscular dysplasia, or inflammatory condition. In an embolic event, debris from elsewhere in the body blocks blood flow through the affected vessel. The etiology of stroke affects both prognosis and outcomes.\"\n\nhttps://www.ncbi.nlm.nih.gov/books/NBK499997/","metadata":{}},{"cell_type":"code","source":"data[\"other_specified\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-08T13:48:37.47136Z","iopub.execute_input":"2022-07-08T13:48:37.471799Z","iopub.status.idle":"2022-07-08T13:48:37.48179Z","shell.execute_reply.started":"2022-07-08T13:48:37.471763Z","shell.execute_reply":"2022-07-08T13:48:37.480509Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Patent foramen ovale (PFO) and ischemic stroke\n\nAuthors: V Larrue , P Massabuau - Minerva Med . 2012 Jun;103(3):199-207. - PMID: 22653100\n\n\"Patent foramen ovale (PFO) is a common finding in healthy subjects and has not been associated with increased risk of ischemic stroke in population-based cohort studies. Nevertheless, case-control studies have consistently shown an increased prevalence of PFO in cryptogenic stroke, suggesting that PFO might be a cause of stroke.\"\n\n\"The risk of stroke recurrence in patients with cryptogenic stroke and PFO is low under aspirin therapy but may be substantially higher in patients with an associated atrial septal aneurysm (ASA). The mechanisms of stroke associated with PFO or ASA are uncertain. Paradoxical embolism through the PFO is rarely documented. The optimal treatment for secondary prevention in patients with cryptogenic stroke and PFO is still uncertain and debated. A randomized controlled trial failed to demonstrate the superiority of transcatheter PFO closure over medical therapy. Whether anticoagulation is superior to aspirin should be tested in a randomized controlled trial.\"\n\nhttps://pubmed.ncbi.nlm.nih.gov/22653100/","metadata":{}},{"cell_type":"code","source":"!pip install biokit","metadata":{"execution":{"iopub.status.busy":"2022-07-08T13:51:34.607751Z","iopub.execute_input":"2022-07-08T13:51:34.608256Z","iopub.status.idle":"2022-07-08T13:52:02.788747Z","shell.execute_reply.started":"2022-07-08T13:51:34.608217Z","shell.execute_reply":"2022-07-08T13:52:02.786828Z"},"_kg_hide-output":true,"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Automatic Adaptative Mixture Fitting","metadata":{}},{"cell_type":"code","source":"#Code by https://biokit.readthedocs.io/en/latest/references.html#biokit.viz.hist2d.Hist2D\n\nfrom biokit.stats.mixture import AdaptativeMixtureFitting, GaussianMixture\nm = GaussianMixture(mu=[-1,1], sigma=[0.5,0.5], mixture=[0.2,0.8])\namf = AdaptativeMixtureFitting(m.data)\namf.run(kmin=1, kmax=6)\namf.diagnostic(k=amf.best_k);","metadata":{"execution":{"iopub.status.busy":"2022-07-08T14:59:51.753188Z","iopub.execute_input":"2022-07-08T14:59:51.753815Z","iopub.status.idle":"2022-07-08T15:00:05.165332Z","shell.execute_reply.started":"2022-07-08T14:59:51.753768Z","shell.execute_reply":"2022-07-08T15:00:05.164039Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Stent Thrombosis\n\nAuthors: Kalgi Modi; Michael P. Soos; Kunal Mahajan\n\nStatPearls - Internet.\n\n\"Stent thrombosis is defined as a thrombotic occlusion of a coronary stent. Stent thrombosis is a major complication associated with stent placement in percutaneous coronary intervention (PCI). Stent thrombosis has been associated with high rates of morbidity and mortality, often leading to events of cardiac death or nonfatal myocardial infarction (MI). Often compared to in-stent restenosis, which leads to anginal type symptoms, stent thrombosis is typically an acute process resulting in acute coronary syndrome (ACS).\"\n\n\"Various risk factors have been associated with stent thrombosis, including a history of diabetes mellitus (DM), ACS, and reduced left ventricular ejection fraction (LVEF). In 2008, the Academic Research Consortium (ARC) guidelines were published regarding the classifications of stent thrombosis. Classifications were divided based on the type of underlying stent, clinical scenario, and timing after initial stent placement.\"\n\nhttps://www.ncbi.nlm.nih.gov/books/NBK441908/","metadata":{}},{"cell_type":"markdown","source":"#Expectation minimization class to estimate parameters of GMM","metadata":{}},{"cell_type":"code","source":"#Code by https://biokit.readthedocs.io/en/latest/references.html#biokit.viz.hist2d.Hist2D\n\nfrom biokit.stats.mixture import GaussianMixture, EM\nm = GaussianMixture(mu=[-1,1], sigma=[0.5,0.5], mixture=[0.2,0.8])\nem = EM(m.data)\nem.estimate(k=2)\nem.plot()","metadata":{"execution":{"iopub.status.busy":"2022-07-08T15:00:52.24511Z","iopub.execute_input":"2022-07-08T15:00:52.245612Z","iopub.status.idle":"2022-07-08T15:00:53.065662Z","shell.execute_reply.started":"2022-07-08T15:00:52.245574Z","shell.execute_reply":"2022-07-08T15:00:53.064571Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Takayasu arteritis\n\nIschemic stroke as the first manifestation of Takayasu arteritis: high resolution magnetic resonance imaging\n\nCitation: Kang, Z., Xu, Z., Wu, X. et al. Ischemic stroke as the first manifestation of Takayasu arteritis: high resolution magnetic resonance imaging. Neurol Sci 42, 4821–4824 (2021). https://doi.org/10.1007/s10072-021-05552-0\n\n\"Takayasu arteritis (TA) is a chronic non-specific inflammatory arteritis that primarily affects the aorta and its main branches. Ischemic stroke, a less common complication of the disease, can sometimes be the first manifestation of TA. The authors reported a case that was first diagnosed with Takayasu arteritis for ischemic stroke, which is rarely reported before. When assessing the disease activity, they tested serological inflammatory biomarkers including erythrocyte sedimentation rate (ESR) and C-reactive protein (CRP), which were within normal reference range. Thus, the patient underwent a diagnostic evaluation with high-resolution magnetic resonance imaging (HR-MRI), which suggested active TA. Then, the patient received immunosuppression therapy. She recovered well from stroke and did not have a recurrence of ischemic events.\"\n\nhttps://link.springer.com/article/10.1007/s10072-021-05552-0","metadata":{}},{"cell_type":"markdown","source":"#Creates a mix of Gaussian distribution","metadata":{}},{"cell_type":"code","source":"#Code by https://biokit.readthedocs.io/en/latest/references.html#biokit.viz.hist2d.Hist2D\n\nfrom biokit.stats.mixture import GaussianMixture\nm = GaussianMixture(mu=[-1,1], sigma=[0.5, 0.5], mixture=[.2, .8], N=1000)\nm.plot()","metadata":{"execution":{"iopub.status.busy":"2022-07-08T15:01:55.801887Z","iopub.execute_input":"2022-07-08T15:01:55.802344Z","iopub.status.idle":"2022-07-08T15:01:56.045137Z","shell.execute_reply.started":"2022-07-08T15:01:55.802307Z","shell.execute_reply":"2022-07-08T15:01:56.044118Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Tumor embolization\n\nCancer and Embolic Stroke of Undetermined Source\n\nAuthors: Babak B. Navi, Scott E. Kasner, Mitchell S.V. Elkind, Mary Cushman, Oh Young Bang and Lisa M. DeAngelis\n\nhttps://doi.org/10.1161/STROKEAHA.120.032002Stroke.   Stroke 2021;52:1121–1130\n\n\"In addition to left atrial cardiopathy, nonstenosing large artery atherosclerosis, and patent foramen ovale (PFO), cancer is an important and common subgroup of ESUS (Embolic stroke of undetermined source). Claims-based data from the National Inpatient Sample suggest that about 10% of patients with ischemic stroke of all causes have known cancer.\"\n\n\"The estimated proportion of ESUS (Embolic stroke of undetermined source)patients with cancer similarly approaches 10%, although it may be as high as 20% in some Asian populations. However, the attributable fraction of ischemic stroke due to cancer is likely less than this because some of the association may be coincidental. The coprevalence for cancer and ischemic stroke is expected to increase further as patients with cancer survive longer.\"\n\n\"Cancer registry data have demonstrated falling mortality rates for several cancer types, including lung, breast, and prostate cancers, the 3 most common types in the United States.11 For example, the 2-year survival among men diagnosed with nonsmall cell lung cancer, which is often widespread at presentation, improved from 26% in 2001 to 35% in 2014. These improved mortality rates reflect improved cancer treatments, particularly targeted and immunologic therapies, and reduced smoking.\"\n\nhttps://www.ahajournals.org/doi/10.1161/STROKEAHA.120.032002","metadata":{}},{"cell_type":"code","source":"!pip install pywaffle","metadata":{"execution":{"iopub.status.busy":"2022-07-08T15:03:56.703819Z","iopub.execute_input":"2022-07-08T15:03:56.704997Z","iopub.status.idle":"2022-07-08T15:04:14.697884Z","shell.execute_reply.started":"2022-07-08T15:03:56.704946Z","shell.execute_reply":"2022-07-08T15:04:14.69651Z"},"_kg_hide-output":true,"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Endocarditis\n\nAcute Ischemic Stroke Treatment in Infective Endocarditis: Systematic Review\n\nAuthors: Sofia Bettencourt , José M Ferro - PMID: 32024600 DOI: 10.1016/j.jstrokecerebrovasdis.2019.104598\n\nJ Stroke Cerebrovasc Dis . 2020 Apr;29(4):104598. doi: 10.1016/j.jstrokecerebrovasdis.2019.104598. Epub 2020 Feb 3.\n\n\"Ischemic stroke is a frequent neurologic complication of infective endocarditis. This systematic review aims to evaluate the efficacy and safety of thrombectomy in comparison to thrombolysis and to combined treatment in patients with infective endocarditis associated acute ischemic stroke.\"\n\n\"With the limitation of the low quality of the available evidence, thrombectomy in infective endocarditis associated stroke appears to be safer than thrombolysis, or combined treatment. These results may be useful to guide clinical decisions, in selected patients.\"\n\nhttps://pubmed.ncbi.nlm.nih.gov/32024600/","metadata":{}},{"cell_type":"code","source":"#Codes by ask9 https://www.kaggle.com/arbazkhan971/indians-vs-world/notebook\n\ndef random_colors(number_of_colors):\n    color = [\"#\"+''.join([random.choice('0123456789ABCDEF') for j in range(6)])\n                 for i in range(number_of_colors)]\n    return color","metadata":{"execution":{"iopub.status.busy":"2022-07-08T15:04:50.854947Z","iopub.execute_input":"2022-07-08T15:04:50.855464Z","iopub.status.idle":"2022-07-08T15:04:50.863098Z","shell.execute_reply.started":"2022-07-08T15:04:50.855425Z","shell.execute_reply":"2022-07-08T15:04:50.861776Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set(style=\"ticks\", context=\"talk\", font_scale=1.5)\nplt.style.use(\"dark_background\")","metadata":{"execution":{"iopub.status.busy":"2022-07-08T15:14:04.544382Z","iopub.execute_input":"2022-07-08T15:14:04.544865Z","iopub.status.idle":"2022-07-08T15:14:04.553168Z","shell.execute_reply.started":"2022-07-08T15:14:04.54483Z","shell.execute_reply":"2022-07-08T15:14:04.552288Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from pywaffle import Waffle\nimport random\n\netiology = data[\"other_specified\"].value_counts()\n\nplt.figure(\n    FigureClass=Waffle,\n    rows=5,\n    columns=10,\n    values= etiology,\n    title={'label': 'Etiology Distribution', 'loc': 'left'},\n    labels=[\"{}({})\".format(a, b) for a, b in zip(etiology.index, etiology) ],\n    # Set the position of the legend\n    legend={'loc': 'upper left', 'bbox_to_anchor': (1, 1)},\n    dpi=100\n)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-08T15:14:09.009566Z","iopub.execute_input":"2022-07-08T15:14:09.010756Z","iopub.status.idle":"2022-07-08T15:14:09.322211Z","shell.execute_reply.started":"2022-07-08T15:14:09.010707Z","shell.execute_reply":"2022-07-08T15:14:09.321341Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from PIL import Image\nimport numpy as np\n\nImage.MAX_IMAGE_PIXELS = None\nmat = Image.open(r\"../input/mayo-clinic-strip-ai/train/01adc5_0.tif\")\nimg = np.array(mat)\nprint(img.shape)","metadata":{"execution":{"iopub.status.busy":"2022-07-08T14:21:40.396362Z","iopub.execute_input":"2022-07-08T14:21:40.397466Z","iopub.status.idle":"2022-07-08T14:22:17.890784Z","shell.execute_reply.started":"2022-07-08T14:21:40.397416Z","shell.execute_reply":"2022-07-08T14:22:17.889352Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Due to the large size of the Pixels/Images, \"my scripts\" with cv2 didn't work. Even trying to fix them.","metadata":{}},{"cell_type":"code","source":"import os\nos.environ[\"OPENCV_IO_MAX_IMAGE_PIXELS\"] = pow(2,40).__str__()\n#출처: https://biology-statistics-programming.tistory.com/194 [히비스서커스의 블로그:티스토리]","metadata":{"execution":{"iopub.status.busy":"2022-07-08T14:24:22.5608Z","iopub.execute_input":"2022-07-08T14:24:22.561333Z","iopub.status.idle":"2022-07-08T14:24:23.026296Z","shell.execute_reply.started":"2022-07-08T14:24:22.561291Z","shell.execute_reply":"2022-07-08T14:24:23.023858Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"DATA_PATH = \"../input/mayo-clinic-strip-ai/\"","metadata":{"execution":{"iopub.status.busy":"2022-07-08T14:27:43.552592Z","iopub.execute_input":"2022-07-08T14:27:43.553049Z","iopub.status.idle":"2022-07-08T14:27:43.557778Z","shell.execute_reply.started":"2022-07-08T14:27:43.553015Z","shell.execute_reply":"2022-07-08T14:27:43.556961Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_paths = sorted(glob.glob(os.path.join(DATA_PATH, 'train/*.tif')))","metadata":{"execution":{"iopub.status.busy":"2022-07-08T14:28:08.53909Z","iopub.execute_input":"2022-07-08T14:28:08.539533Z","iopub.status.idle":"2022-07-08T14:28:08.550109Z","shell.execute_reply.started":"2022-07-08T14:28:08.539464Z","shell.execute_reply":"2022-07-08T14:28:08.548762Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"Number of images: {len(image_paths)}\")","metadata":{"execution":{"iopub.status.busy":"2022-07-08T14:28:27.644352Z","iopub.execute_input":"2022-07-08T14:28:27.644841Z","iopub.status.idle":"2022-07-08T14:28:27.652873Z","shell.execute_reply.started":"2022-07-08T14:28:27.644806Z","shell.execute_reply":"2022-07-08T14:28:27.651255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nimport pandas as pd\nfrom glob import glob\nfrom openslide import OpenSlide\nfrom pprint import pprint\nimport matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2022-07-08T14:34:16.59381Z","iopub.execute_input":"2022-07-08T14:34:16.594228Z","iopub.status.idle":"2022-07-08T14:34:16.599622Z","shell.execute_reply.started":"2022-07-08T14:34:16.594196Z","shell.execute_reply":"2022-07-08T14:34:16.598451Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_images = glob(\"/kaggle/input/mayo-clinic-strip-ai/train/*\")\nlen(train_images)","metadata":{"execution":{"iopub.status.busy":"2022-07-08T14:34:36.777952Z","iopub.execute_input":"2022-07-08T14:34:36.778444Z","iopub.status.idle":"2022-07-08T14:34:36.790195Z","shell.execute_reply.started":"2022-07-08T14:34:36.778403Z","shell.execute_reply":"2022-07-08T14:34:36.789161Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Correlation of imaging and histopathology of thrombi in acute ischemic stroke with etiology and outcome: a systematic review \n\nAuthors: Waleed Brinjikji, Sharon Duffy, Anthony Burrows, Werner Hacke, David Liebeskind, Charles B L M Majoie, W J Dippel, Adnan H Siddiqui, Pooja Khatri, Blaise Baxter, Raul Nogeuira, Matt Gounis, Tudor Jovin, David F Kallmes  \n\nhttp://orcid.org/0000-0002-9234-3515Diederik\n\n\"Studying the imaging and histopathologic characteristics of thrombi in ischemic stroke could provide insights into stroke etiology and ideal treatment strategies. The authors conducted a systematic review of imaging and histologic characteristics of thrombi in acute ischemic stroke.\"\n\n\"Conclusions The hyperdense artery sign is associated with RBC-rich thrombi and improved recanalization rates. However, there was no association between the histopathological characteristics of thrombi and stroke etiology and angiographic outcomes.\"\n\nhttps://jnis.bmj.com/content/9/6/529","metadata":{}},{"cell_type":"code","source":"#Code by Naoto Usuyama https://www.kaggle.com/code/naotous/mayo-eda-whole-slide-images/notebook\n\nimg_path = train_images[2]\n\nprint(img_path)\nslide = OpenSlide(img_path)\n\nprint(slide.dimensions)\nprint(slide.level_count)\nprint(slide.level_dimensions)\npprint(dict(slide.properties))\nprint(f\"file size: {round(os.path.getsize(img_path) / 1024 ** 2, 2)} MB\")","metadata":{"execution":{"iopub.status.busy":"2022-07-08T14:34:55.484786Z","iopub.execute_input":"2022-07-08T14:34:55.485235Z","iopub.status.idle":"2022-07-08T14:34:55.519333Z","shell.execute_reply.started":"2022-07-08T14:34:55.485199Z","shell.execute_reply":"2022-07-08T14:34:55.518469Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Naoto Usuyama https://www.kaggle.com/code/naotous/mayo-eda-whole-slide-images/notebook\n\nregion = (4, 4)#numbers can be changed\nlevel = 0#different from zero doesn't plot anything\nsize = (5000, 1000)#Numbers change totally the image Like a microscope slide\nregion = slide.read_region(region, level, size)\nplt.figure(figsize=(8, 8))\nplt.imshow(region);","metadata":{"execution":{"iopub.status.busy":"2022-07-08T14:53:41.579395Z","iopub.execute_input":"2022-07-08T14:53:41.579818Z","iopub.status.idle":"2022-07-08T14:53:42.630415Z","shell.execute_reply.started":"2022-07-08T14:53:41.579787Z","shell.execute_reply":"2022-07-08T14:53:42.629229Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Naoto Usuyama https://www.kaggle.com/code/naotous/mayo-eda-whole-slide-images/notebook\n\nregion = (3, 3)\nlevel = 0#other level doesn't plot anything\nsize = (5000, 5000)\nregion = slide.read_region(region, level, size)\nplt.figure(figsize=(10, 10))\nplt.imshow(region);","metadata":{"execution":{"iopub.status.busy":"2022-07-08T14:43:06.476983Z","iopub.execute_input":"2022-07-08T14:43:06.477441Z","iopub.status.idle":"2022-07-08T14:43:11.546335Z","shell.execute_reply.started":"2022-07-08T14:43:06.477404Z","shell.execute_reply":"2022-07-08T14:43:11.54456Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Naoto Usuyama https://www.kaggle.com/code/naotous/mayo-eda-whole-slide-images/notebook\n\nregion = (2, 4)\nlevel = 0#other level doesn't plot anything\nsize = (6000, 6000)\nregion = slide.read_region(region, level, size)\nplt.figure(figsize=(10, 10))\nplt.imshow(region);","metadata":{"execution":{"iopub.status.busy":"2022-07-08T14:47:54.223333Z","iopub.execute_input":"2022-07-08T14:47:54.223758Z","iopub.status.idle":"2022-07-08T14:48:02.346558Z","shell.execute_reply.started":"2022-07-08T14:47:54.223724Z","shell.execute_reply":"2022-07-08T14:48:02.345292Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Stroke Prognosis\n\nBy Sally Robertson, B.Sc. - Reviewed by Sophia Coveney\n\n\"The patient prognosis after an ischemic stroke is much more positive than after a hemorrhagic stroke. In addition to killing off brain cells, hemorrhagic stroke increases the risk of dangerous complications such as increased intracranial pressure or spasms in the brain vasculature.\"\n\n\"Many people who survive a stroke recover their independence, although around one quarter are left living with minor disabilities and around 40% have more severe disabilities. Stroke outcome can be calculated using the National Institutes of Health stroke scale, which includes 11 factors ranging from facial movement through to consciousness level, to predict and assess how favorable the patient’s outlook is. If patients score less than 10, the outlook is generally favorable after one year, while a score of more than 20 suggests a less positive prognosis.\"\n\nhttps://www.news-medical.net/health/Stroke-Prognosis.aspx","metadata":{}},{"cell_type":"markdown","source":"#Acknowledgements:\n\nNaoto Usuyama https://www.kaggle.com/code/naotous/mayo-eda-whole-slide-images/notebook\n\nBiokit https://biokit.readthedocs.io/en/latest/references.html#biokit.viz.hist2d.Hist2D\n\nTorch Me https://www.kaggle.com/code/kartushovdanil/baseline-amex-catboost-blending-wandb\n\nask9 https://www.kaggle.com/arbazkhan971/indians-vs-world/notebook","metadata":{}}]}