From c79822582d23ac2d610956e62a01d6e277592101 Mon Sep 17 00:00:00 2001
From: Shiza Charania <86497160+shizacharania@users.noreply.github.com>
Date: Fri, 4 Feb 2022 00:18:34 -0500
Subject: [PATCH] Delete Brain_Tumour_Segmentation.ipynb
---
Brain_Tumour_Segmentation.ipynb | 1842 -------------------------------
1 file changed, 1842 deletions(-)
delete mode 100644 Brain_Tumour_Segmentation.ipynb
diff --git a/Brain_Tumour_Segmentation.ipynb b/Brain_Tumour_Segmentation.ipynb
deleted file mode 100644
index 73e16e4..0000000
--- a/Brain_Tumour_Segmentation.ipynb
+++ /dev/null
@@ -1,1842 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "id": "view-in-github",
- "colab_type": "text"
- },
- "source": [
- ""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {
- "id": "TUxU1SLKkBQP"
- },
- "outputs": [],
- "source": [
- "# install kaggle\n",
- "!pip install -q kaggle"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {
- "colab": {
- "base_uri": "https://localhost:8080/",
- "height": 90,
- "resources": {
- "http://localhost:8080/nbextensions/google.colab/files.js": {
- "data": "Ly8gQ29weXJpZ2h0IDIwMTcgR29vZ2xlIExMQwovLwovLyBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLy8geW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgovLyBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKLy8KLy8gICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKLy8KLy8gVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbi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WRGaWxlc0NvbnRpbnVlLAp9Owp9KShzZWxmKTsK",
- "headers": [
- [
- "content-type",
- "application/javascript"
- ]
- ],
- "ok": true,
- "status": 200,
- "status_text": ""
- }
- }
- },
- "id": "tLZPeYqJquTb",
- "outputId": "71108633-fc4c-4b03-c92a-cc8857a845c2"
- },
- "outputs": [
- {
- "output_type": "display_data",
- "data": {
- "text/html": [
- "\n",
- " \n",
- " \n",
- " "
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {}
- },
- {
- "output_type": "stream",
- "name": "stdout",
- "text": [
- "Saving kaggle.json to kaggle.json\n"
- ]
- },
- {
- "output_type": "execute_result",
- "data": {
- "text/plain": [
- "{'kaggle.json': b'{\"username\":\"shizacharania\",\"key\":\"f4d4c61a9252e57ae14d3185e707df48\"}'}"
- ]
- },
- "metadata": {},
- "execution_count": 3
- }
- ],
- "source": [
- "# upload the generated api token in .json format from local system\n",
- "from google.colab import files\n",
- "files.upload()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {
- "id": "bQmjPuM3Q3i3"
- },
- "outputs": [],
- "source": [
- "# make a kaggle directory in my files\n",
- "!mkdir ~/.kaggle"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {
- "id": "8TcYfMjrRF4v"
- },
- "outputs": [],
- "source": [
- "# put the kaggle.json file in that directory\n",
- "!cp kaggle.json ~/.kaggle/"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {
- "id": "khvU0fcwrdI5"
- },
- "outputs": [],
- "source": [
- "# grant permission for the .json file to act\n",
- "!chmod 600 ~/.kaggle/kaggle.json"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "metadata": {
- "colab": {
- "base_uri": "https://localhost:8080/"
- },
- "id": "afOog3SBrqXG",
- "outputId": "36027fac-9c80-4244-b3c2-ba187e1b9bcb"
- },
- "outputs": [
- {
- "output_type": "stream",
- "name": "stdout",
- "text": [
- "Warning: Looks like you're using an outdated API Version, please consider updating (server 1.5.12 / client 1.5.4)\n",
- "ref title size lastUpdated downloadCount \n",
- "---------------------------------------------------------- ------------------------------------------------- ----- ------------------- ------------- \n",
- "nkitgupta/jigsaw-regression-based-data Jigsaw Regression Based Data 3GB 2022-01-10 06:29:59 714 \n",
- "prasertk/netflix-subscription-price-in-different-countries Netflix subscription fee in different countries 3KB 2022-01-15 07:06:09 1855 \n",
- "yasserh/wine-quality-dataset Wine Quality Dataset 21KB 2022-01-15 19:15:11 1647 \n",
- "iamsouravbanerjee/analytics-industry-salaries-2022-india Data Professionals Salary - 2022 57KB 2022-02-02 04:35:21 2061 \n",
- "yamqwe/netflix-showse Netflix Shows 11KB 2022-01-23 00:03:01 1093 \n",
- "sanjeetsinghnaik/top-1000-highest-grossing-movies Top 1000 Highest Grossing Movies 106KB 2022-01-15 16:26:14 1165 \n",
- "yasserh/amazon-product-reviews-dataset Amazon Product Reviews Dataset 708KB 2022-01-23 17:21:16 542 \n",
- "yamqwe/omicron-covid19-variant-daily-cases Omicron daily cases by country (COVID-19 variant) 432KB 2022-02-03 19:56:38 12747 \n",
- "vishalmane10/anime-dataset-2022 Anime DataSet 2022 5MB 2022-01-16 13:56:16 849 \n",
- "carlmcbrideellis/gdp-20152019-finland-norway-and-sweden GDP 2015-2019: Finland, Norway, and Sweden 365B 2022-01-05 07:48:49 549 \n",
- "sandipdevre/petrol-prices-in-india Petrol Prices In India 3KB 2022-01-27 09:07:35 375 \n",
- "yamqwe/shark-tank-companiese 📱 Shark Tank Companies 70KB 2022-01-30 21:01:58 314 \n",
- "dansbecker/melbourne-housing-snapshot Melbourne Housing Snapshot 451KB 2018-06-05 12:52:24 79935 \n",
- "yamqwe/men-s-shoe-pricese 🩰 Men's Shoe Prices 6MB 2022-01-24 15:19:48 527 \n",
- "nenamalikah/nft-collections-by-sales-volume Top NFT Collections 47KB 2022-01-17 00:47:41 573 \n",
- "meetnagadia/netflix-stock-price-data-set-20022022 Netflix Stock Price Data set 2002-2022 94KB 2022-01-12 05:28:11 656 \n",
- "datasnaek/youtube-new Trending YouTube Video Statistics 201MB 2019-06-03 00:56:47 164865 \n",
- "zynicide/wine-reviews Wine Reviews 51MB 2017-11-27 17:08:04 153588 \n",
- "fedesoriano/stellar-classification-dataset-sdss17 Stellar Classification Dataset - SDSS17 7MB 2022-01-15 17:11:30 534 \n",
- "rtatman/188-million-us-wildfires 1.88 Million US Wildfires 168MB 2020-05-12 21:03:49 18763 \n"
- ]
- }
- ],
- "source": [
- "# list available datsets to ensure that the API worked and kaggle's linked\n",
- "!kaggle datasets list"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "metadata": {
- "colab": {
- "base_uri": "https://localhost:8080/"
- },
- "id": "nmX1SKJWr0uX",
- "outputId": "b08f49da-3af2-4dd1-f423-042aa70387bb"
- },
- "outputs": [
- {
- "output_type": "stream",
- "name": "stdout",
- "text": [
- "Downloading lgg-mri-segmentation.zip to /content\n",
- " 99% 706M/714M [00:06<00:00, 103MB/s]\n",
- "100% 714M/714M [00:06<00:00, 111MB/s]\n"
- ]
- }
- ],
- "source": [
- "# download the mri segmentation datset with its api command\n",
- "!kaggle datasets download -d mateuszbuda/lgg-mri-segmentation"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "id": "nAAOkz-jsU_4"
- },
- "outputs": [],
- "source": [
- "# unzip the images from the .zip file so we can directly access these images\n",
- "!unzip lgg-mri-segmentation.zip"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "id": "3tW4orEZtPWn"
- },
- "outputs": [],
- "source": [
- "#visualize the amount of masks and non-masks\n",
- "import matplotlib.pyplot as plt\n",
- "import numpy as np\n",
- "import glob\n",
- "import cv2\n",
- "import os\n",
- "import pandas as pd\n",
- "\n",
- "# path of all the images:\n",
- "root_path = '/content/lgg-mri-segmentation/kaggle_3m/'\n",
- "\n",
- "potential_mask_files = glob.glob(root_path + \"*/*_mask*\") # names of all the files with masks\n",
- "\n",
- "mask_files = []\n",
- "add_count = 0\n",
- "for mask in potential_mask_files: # only took the files that have tumours in them to decrease the dataset since RAM keeps running out\n",
- " if np.max(cv2.imread(mask)) > 0:\n",
- " mask_files.append(mask)\n",
- " elif np.max(cv2.imread(mask)) == 0 and add_count % 3 == 0:\n",
- " mask_files.append(mask)\n",
- " \n",
- " add_count += 1\n",
- "\n",
- "image_files = []\n",
- "for mask in mask_files:\n",
- " rmask = mask.replace(\"_mask\", \"\")\n",
- " image_files.append(rmask)\n",
- "\n",
- "print(mask_files) # 3929 items - e.x.: /content/lgg-mri-segmentation/kaggle_3m/TCGA_FG_A60K_20040224/TCGA_FG_A60K_20040224_23_mask.tif\n",
- "print(image_files) # 3929 items - e.x.: /content/lgg-mri-segmentation/kaggle_3m/TCGA_FG_A60K_20040224/TCGA_FG_A60K_20040224_23.tif\n",
- "\n",
- "tumour_count = []\n",
- "\n",
- "def diagnosis(mask_path):\n",
- " if np.max(cv2.imread(mask_path)) > 0: # return np.max(cv2.imread(mask_path)) - returns 255 if there is a tumour, otherwise returns 0\n",
- " tumour_count.append(\"1\")\n",
- " return 1\n",
- " else:\n",
- " tumour_count.append(\"0\")\n",
- " return 0\n",
- "\n",
- "files_df = pd.DataFrame({\"image_path\": image_files, \n",
- " \"mask_path\": mask_files,\n",
- " \"diagnosis\": [diagnosis(x) for x in mask_files]})\n",
- "\n",
- "print(files_df)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "metadata": {
- "colab": {
- "base_uri": "https://localhost:8080/",
- "height": 300
- },
- "id": "RTTzaCsopOTt",
- "outputId": "9f5c1d32-acb5-42e8-eab3-1ec932fe87d0"
- },
- "outputs": [
- {
- "output_type": "stream",
- "name": "stdout",
- "text": [
- "Tumours: 1373 ........... Non-Tumours: 835\n"
- ]
- },
- {
- "output_type": "execute_result",
- "data": {
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "execution_count": 11
- },
- {
- "output_type": "display_data",
- "data": {
- "image/png": "iVBORw0KGgo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