{"cells":[{"metadata":{},"cell_type":"markdown","source":"#Prostate Cancer Guidelines, by Gerald W Chodak, MD; Chief Editor: Edward David Kim, MD, Tracey L Krupski, MD, MPH\n\nThe guidelines differ in their recommendations regarding whether or not to provide routine prostate-specific antigen (PSA)–based prostate cancer screening, in what age groups and life expectancies, and at what intervals. The guidelines agree that PSA-based prostate cancer screening requires an informed, shared decision-making process, and that the decision should reflect the patient’s understanding of the possible benefits and risks and should respect the patient’s preferences and values. https://emedicine.medscape.com/article/1967731-guidelines"},{"metadata":{},"cell_type":"markdown","source":"#ISUP - International Society of Urological Pathology \n\nGrading system for patients with high-risk prostate cancer, a single-center retrospective study. Authors:\nJiandong Liu, Jinge Zhao, Mengni Zhang, Ni Chen, Guangxi Sun, Yaojing Yang, Xingming Zhang, Junru Chen, Pengfei Shen, Ming Shi, and Hao Zeng\n\n#Gleason Grading System\n\nThe Gleason grading system has been one of the most powerful prognostic factors in prostate cancer since it was first proposed in 1966 by Donald Gleason. In the past several decades, to improve its predictive ability, the Gleason grading system has been revised and updated several times.https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6634264/"},{"metadata":{},"cell_type":"markdown","source":"#Statistical methods\n\nContinuous variables were presented as the median and interquartile range (IQR), while categorical variables were reported as the number and percentage. The chi-square test and the Mann-Whitney U test were used to compare the baseline characteristics between patients with various GS values. Kaplan-Meier curves were used to compare the BRFS according to either the three-tier or five-tier grouping system. Differences in BRFS between each group were compared using the log-rank test. Univariate and multivariate analyses were conducted by Cox regression model as follows. First, the univariate Cox regression was used to evaluate the ability of each variable to predict BRFS. Second, parameters with P<0.05 in the univariate analysis were further analyzed by multivariate Cox regression. The accuracy and discrimination ability of the 2014 ISUP grading criteria according to the three-tier and five-tier grouping systems were evaluated and compared using the concordance index (C-index).\n\nData analyses were performed using SPSS software (version 21.0). All of the tests were two-sided. A p-value below 0.05 was considered to be statistically significant.https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6634264/"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"#codes from Rodrigo Lima  @rodrigolima82\nfrom IPython.display import Image\nImage(url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcRcAo69vF1onCRMd_XyDxUJifE_Yr18s8Zd9WiKDgFdzyzNG-cn&usqp=CAU',width=400,height=400)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"prostate-ca.co-za"},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"_kg_hide-output":true,"_kg_hide-input":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 \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib\nimport matplotlib.pyplot as plt\nimport PIL\nfrom IPython.display import Image, display\nimport plotly.express as px\nimport seaborn\nimport seaborn as sns\n\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\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"#codes from Rodrigo Lima  @rodrigolima82\nfrom IPython.display import Image\nImage(url = 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6634264/bin/CMAR-11-6521-g0001.jpg',width=400,height=400)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Cancer Manag Res. 2019; 11: 6521–6529.\n\nPublished online 2019 Jul 12. doi: 10.2147/CMAR.S196286\n\nPMCID: PMC6634264/ PMID: 31372053/\n\nThe validation of the 2014 International Society of Urological Pathology (ISUP) grading system for patients with high-risk prostate cancer: a single-center retrospective study\n\nJiandong Liu, Jinge Zhao, Mengni Zhang, Ni Chen, Guangxi Sun, Yaojing Yang, Xingming Zhang, Junru Chen, Pengfei Shen, Ming Shi, and Hao Zeng https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6634264/\n\n\nFigure above:\nKaplan-Meier curves of BRFS. (A) BRFS curves according to the three-tier grouping system; (B) BRFS curves according to the five-tier grouping system; (C) BRFS curves with the five-tier grouping system with GG3 patients with the tertiary GS 5 excluded; (D) BRFS curves with the five-tier grouping system with IDC-P excluded; (E) BRFS curves with the five-tier grouping system with TGP5 and IDC-P excluded.\nAbbreviations: BCR, biochemical recurrence; BRFS, biochemical recurrence-free survival; GG, Gleason grade group; GS, Gleason score; IDC-P, intraductal carcinoma of the prostate; TGP5, tertiary Gleason pattern."},{"metadata":{},"cell_type":"markdown","source":"The American Cancer Society (ACS) does not recommend routine screening in any age group. Instead, asymptomatic men with at least a 10-year life expectancy should be given an opportunity to make an informed decision with their health care provider after receiving information on the uncertainties, risks and benefits of screening.\n\nMen should receive the information starting at the following ages:\n\nAge 50 for those at average risk of developing prostate cancer.\n\nAge 45 for those at high risk, including African Americans and men with a first-degree relative (father, brother, son) diagnosed with prostate cancer before age 65.\n\nAge 40 for those at higher risk (more than one first-degree relative diagnosed with prostate cancer at an early age).\nhttps://emedicine.medscape.com/article/1967731-guidelines"},{"metadata":{},"cell_type":"markdown","source":"#PSA test\n\nFor men who are unable to decide whether they wish to be screened, the ACS advises that the patient’s health care provider can make the screening decision, taking into account the patient’s general health preferences and values.\nMen who decide to be screened should be tested with a PSA test. A digital rectal exam (DRE) may also be done as a part of screening.\nIf screening does not detect cancer, the time between subsequent screenings depends on the results of the blood test, as follows:\n\nPSA < 2.5 ng/ml – Retesting may be done every 2 years\n\nPSA ≥2.5 ng/ml – Retesting should be done annually\n\nEven after the decision to screen has been made, the discussion about the risks and benefits of testing should be repeated as new information becomes available.https://emedicine.medscape.com/article/1967731-guidelines"},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"psa = pd.read_csv(\"../input/prostate-cancer-grade-assessment/train.csv\")\npsa.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"fig = px.bar(psa, \n             x='gleason_score', y='isup_grade', color_discrete_sequence=['purple'],\n             title='Prostate Carcinoma Guidelines', text='gleason_score')\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"#Codes from Jorge Robinat https://www.kaggle.com/jorgerobinat/wind-inten-coron-vigo-regression"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"fig = px.scatter(psa.dropna(), x='gleason_score',y='image_id', trendline=\"data_provider\", color_discrete_sequence=['purple'])\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"#NCCN (National Comprehensive Cancer Network) Screening guidelines\n\nThe NCCN recommends performing a baseline evaluation, with a history and physical examination that includes the following:\n\nFamily history;; Medications;; History of prostate disease and screening, including prior PSA and/or isoforms, exams, and biopsies;; \nRace;;Family or personal history of BRC1/2 mutations \n\nThe NCCN notes that men ≥60 years of age with serum PSA < 1.0 ng/mL have a very low risk of metastasis or death from prostate cancer and may not benefit from further testing. The same is true of men age 75 years with a PSA of < 3.0 ng/mL.\n\nEvaluation for biopsy includes the following: Repeat PSA; Perform DRE; if not done performed during initial risk assessment Workup for benign disease.https://emedicine.medscape.com/article/1967731-guidelines"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"fig = px.density_contour(psa, x=\"gleason_score\", y=\"isup_grade\", color_discrete_sequence=['purple'])\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"px.histogram(psa, x='gleason_score', color='isup_grade')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"#AUA (American Urological Association) screening guidelines\n\nThe recommendations of the AUA. The guidelines do not recommend routine screening for the following groups:\n\nAny man with a life expectancy less than 10-15 years; Men under 40 years; Men between ages 40 to 54 years at average risk; Men over age 70 \n\nFor men 55 to 69 years of age, the decision to undergo PSA screening involves weighing the benefits and risks. The guidelines strongly recommend:\n\nShared decision-making for men age 55-69 years who are considering PSA screening, and proceeding based on patients’ values and preferences.\n\nA routine screening interval of two years or more in those men who have participated in shared decision-making and decided on screening.\n\nhttps://emedicine.medscape.com/article/1967731-guidelines"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"seaborn.set(rc={'axes.facecolor':'magenta', 'figure.facecolor':'magenta'})\n# Set the width and height of the figure\nplt.figure(figsize=(10,6))\n\n# Add title\nplt.title(\"Prostate Carcinoma Guidelines\")\n\n# Bar chart showing average arrival delay for Spirit Airlines flights by month\nsns.barplot(x=psa.index, y=psa['gleason_score'])\n\n# Add label for vertical axis\nplt.ylabel(\"Prostate Carcinoma Guidelines\")","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"#Genetic Testing\n\nNational Comprehensive Cancer Network (NCCN) guidelines recommend that at the time of initial diagnosis of prostate cancer, clinicians should inquire about family and personal history of cancer. The NCCN recommends germline genetic testing, with or without pretest genetic counseling, for patients with prostate cancer and any of the following:\n\nA positive family history of cancer (eg, prostate, breast); High-risk, very-high-risk, regional or metastatic prostate cancer, regardless of family history; Ashkenazi Jewish ancestry; Intraductal histology https://emedicine.medscape.com/article/1967731-guidelines#g6"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"fig = px.line(psa, x=\"isup_grade\", y=\"data_provider\",  color_discrete_sequence=['purple'],  \n              title=\"Prostate Carcinoma Guidelines\")\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"#Multiparametric Magnetic Resonance Imaging\n\nThe National Comprehensive Cancer Network (NCCN) advises that although standard MRI techniques can be considered for initial evaluation of high-risk patients, multiparametric magnetic resonance imaging (mpMRI) can be used in the staging and characterization of prostate cancer. mpMRI images are defined as those acquired with at least one more sequence in addition to the anatomic T2-weighted images, such as diffusion-weighted imaging and dynamic contrast images.https://emedicine.medscape.com/article/1967731-guidelines#g2"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"seaborn.set(rc={'axes.facecolor':'#27F1E7', 'figure.facecolor':'#27F1E7'})\nsns.countplot(psa[\"isup_grade\"])\nplt.xticks(rotation=90)\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"#Codes from Wouter Bulten https://www.kaggle.com/wouterbulten/getting-started-with-the-panda-dataset"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import openslide\nimport skimage.io\nimport PIL\nfrom IPython.display import Image, display\nimport plotly.graph_objs as go","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"#Management of Clinically Localized Prostate Cancer (American Urological Association)\n\nRecommendations for high-risk patients the guideline recommendations include the following:\nClinicians should stage high-risk localized prostate cancer patients with cross-sectional imaging (CT or MRI) and bone scan. (Clinical Principle);;Clinicians should recommend radical prostatectomy or radiotherapy plus ADT as standard treatment options for patients with high-risk localized prostate cancer;Clinicians should not recommend active surveillance for patients with high-risk localized prostate cancer. Watchful waiting should be considered only in asymptomatic men with limited life expectancy (≤5 years). (Moderate Recommendation; Cryosurgery, focal therapy, and HIFU treatments are not recommended for men with high-risk localized prostate cancer outside of a clinical trial. ;;Clinicians should not recommend primary ADT for patients with high-risk localized prostate cancer unless the patient has both limited life expectancy and local symptoms.; Clinicians may consider referral for genetic counseling for patients (and their families) with high-risk localized prostate cancer and a strong family history of specific cancers (eg, breast, ovarian, pancreatic, other gastrointestinal tumors, lymphoma). https://emedicine.medscape.com/article/1967731-guidelines#g3"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"# Location of the training images\ndata_dir = '/kaggle/input/prostate-cancer-grade-assessment/train_images'\nmask_dir = '/kaggle/input/prostate-cancer-grade-assessment/train_label_masks'","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"#Bone Scan for Diagnosis of Metastatic Disease\n#Castration-Resistant Prostate Cancer\nhttps://emedicine.medscape.com/article/1967731-guidelines#g5"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"# Open the image (does not yet read the image into memory)\nimage = openslide.OpenSlide(os.path.join(data_dir, '274187a867ebf7834ab44372da776439.tiff'))\n\n# Read a specific region of the image starting at upper left coordinate (x=17800, y=19500) on level 0 and extracting a 256*256 pixel patch.\n# At this point image data is read from the file and loaded into memory.\npatch = image.read_region((17800,19500), 0, (256, 256))\n\n# Display the image\ndisplay(patch)\n\n# Close the opened slide after use\nimage.close()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"I suffered to find a different tiff so that I could visualize not the same that the authors have made."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"biopsy = openslide.OpenSlide(os.path.join(data_dir, '07c52f877d1c531c1da6ea32b3c6bff5.tiff'))\n\nx = 5150\ny = 21000\nlevel = 0\nwidth = 512\nheight = 512\n\nregion = biopsy.read_region((x,y), level, (width, height))\ndisplay(region)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"x = 5140\ny = 21000\nlevel = 1\nwidth = 512\nheight = 512\n\nregion = biopsy.read_region((x,y), level, (width, height))\ndisplay(region)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"def print_mask_details(slide, center='radboud', show_thumbnail=True, max_size=(400,400)):\n    \"\"\"Print some basic information about a slide\"\"\"\n\n    if center not in ['radboud', 'karolinska']:\n        raise Exception(\"Unsupported palette, should be one of [radboud, karolinska].\")\n\n    # Generate a small image thumbnail\n    if show_thumbnail:\n        # Read in the mask data from the highest level\n        # We cannot use thumbnail() here because we need to load the raw label data.\n        mask_data = slide.read_region((0,0), slide.level_count - 1, slide.level_dimensions[-1])\n        # Mask data is present in the R channel\n        mask_data = mask_data.split()[0]\n        # To show the masks we map the raw label values to RGB values\n        preview_palette = np.zeros(shape=768, dtype=int)\n        if center == 'radboud':\n            # Mapping: {0: background, 1: stroma, 2: benign epithelium, 3: Gleason 3, 4: Gleason 4, 5: Gleason 5}\n            preview_palette[0:18] = (np.array([0, 0, 0, 0.5, 0.5, 0.5, 0, 1, 0, 1, 1, 0.7, 1, 0.5, 0, 1, 0, 0]) * 255).astype(int)\n        elif center == 'karolinska':\n            # Mapping: {0: background, 1: benign, 2: cancer}\n            preview_palette[0:9] = (np.array([0, 0, 0, 0.5, 0.5, 0.5, 1, 0, 0]) * 255).astype(int)\n        mask_data.putpalette(data=preview_palette.tolist())\n        mask_data = mask_data.convert(mode='RGB')\n        mask_data.thumbnail(size=max_size, resample=0)\n        display(mask_data)\n        \n            # Compute microns per pixel (openslide gives resolution in centimeters)\n    spacing = 1 / (float(slide.properties['tiff.XResolution']) / 10000)\n    \n    print(f\"File id: {slide}\")\n    print(f\"Dimensions: {slide.dimensions}\")\n    print(f\"Microns per pixel / pixel spacing: {spacing:.3f}\")\n    print(f\"Number of levels in the image: {slide.level_count}\")\n    print(f\"Downsample factor per level: {slide.level_downsamples}\")\n    print(f\"Dimensions of levels: {slide.level_dimensions}\")","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"mask = openslide.OpenSlide(os.path.join(mask_dir, '78bd2af7d449cc2185aaf861f61531aa_mask.tiff'))\nprint_mask_details(mask, center='radboud')\nmask.close()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"mask = openslide.OpenSlide(os.path.join(mask_dir, '878be7ee5bdda3b29e2417f6dc93af64_mask.tiff'))\nprint_mask_details(mask, center='karolinska')\nmask.close()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"from wordcloud import WordCloud\ndef nonan(x):\n    if type(x) == str:\n        return x.replace(\"\\n\", \"\")\n    else:\n        return \"\"\n\ntext = ' '.join([nonan(abstract) for abstract in psa[\"data_provider\"]])\nwordcloud = WordCloud(max_font_size=None,colormap='Set3', background_color='black', collocations=False,\n                      width=1200, height=1000).generate(text)\nfig = px.imshow(wordcloud)\nfig.update_layout(title_text='Prostate Carcinoma Guidelines')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"#codes from Rodrigo Lima  @rodrigolima82\nfrom IPython.display import Image\nImage(url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcQrQRag1f6EWlByk91cVmHzKQQdkxEA-tWH29Za3Ai9C_rCAG8y&usqp=CAU',width=400,height=400)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"prostate-pioneer.eu"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"#codes from Rodrigo Lima  @rodrigolima82\nfrom IPython.display import Image\nImage(url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcTtlFrQsdG2PaVnf3qUQXYec6nfW8PBKlWtTaTgxdQ4VFM47UYB&usqp=CAU',width=400,height=400)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"cancercoreurope.eu"},{"metadata":{},"cell_type":"markdown","source":"Kaggle Notebook Runner: Marília Prata  @mpwolke"}],"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}