diff --git a/IMALAB_BraTS_Challenge_MulticlassMasks.ipynb b/IMALAB_BraTS_Challenge_MulticlassMasks.ipynb
new file mode 100644
index 0000000..fcff17e
--- /dev/null
+++ b/IMALAB_BraTS_Challenge_MulticlassMasks.ipynb
@@ -0,0 +1,8269 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ ""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 53
+ },
+ "id": "O62JgC5ee6Fg",
+ "outputId": "0c66aa53-a17a-47ef-b7b9-b3ad219d259a"
+ },
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'\\n- extracting (called \"open\" on the file viewer) all the files with \".nii.gz\" (basically getting all the files)\\n- view an image - look into: can you have multiple windows for MRIcro\\n- also look at the viewer thing in colab\\n\\nthen i can do preprocessing\\n'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 1
+ }
+ ],
+ "source": [
+ "\"\"\"\n",
+ "Training/Validation/Testing\n",
+ "│\n",
+ "└─── 00000\n",
+ "│ │\n",
+ "│ └─── FLAIR\n",
+ "│ │ │ Image.nii.gz\n",
+ "│ │ \n",
+ "│ └─── T1\n",
+ "│ │ │ Image.nii.gz\n",
+ "│ │ \n",
+ "│ └─── T1CE\n",
+ "│ │ │ Image.nii.gz\n",
+ "│ │ \n",
+ "│ └─── T2\n",
+ "│ │ │ Image.nii.gz\n",
+ "| | \n",
+ "| |___ Segmentation\n",
+ "| | | Image.nii.gz\n",
+ "│ \n",
+ "└─── 00001\n",
+ "│\n",
+ "│ ... \n",
+ "│ ... \n",
+ "│ \n",
+ "└─── 00002\n",
+ "\"\"\"\n",
+ "\n",
+ "\"\"\"\n",
+ "- extracting (called \"open\" on the file viewer) all the files with \".nii.gz\" (basically getting all the files)\n",
+ "- view an image - look into: can you have multiple windows for MRIcro\n",
+ "- also look at the viewer thing in colab\n",
+ "\n",
+ "then i can do preprocessing\n",
+ "\"\"\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "ko8JUyqhO7TQ",
+ "outputId": "774720a4-510e-4a9b-e2e7-4cc09a7f3d63"
+ },
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "/usr/local/lib/python3.7/dist-packages/gdown/cli.py:131: FutureWarning: Option `--id` was deprecated in version 4.3.1 and will be removed in 5.0. You don't need to pass it anymore to use a file ID.\n",
+ " category=FutureWarning,\n",
+ "Downloading...\n",
+ "From: https://drive.google.com/uc?id=17_VDkS9f0QA8IIGqdWFgm6d2JASBtILt\n",
+ "To: /content/brats_120_images.zip\n",
+ "100% 235M/235M [00:01<00:00, 150MB/s]\n"
+ ]
+ }
+ ],
+ "source": [
+ "!gdown --id 17_VDkS9f0QA8IIGqdWFgm6d2JASBtILt"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "xo220Y4n91xw",
+ "outputId": "46bb1a2d-1c2c-48d0-9dc6-24f7e8131b4e"
+ },
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Archive: /content/brats_120_images.zip\n",
+ "replace brats_120_images/BraTS2021_00025_seg.nii? [y]es, [n]o, [A]ll, [N]one, [r]ename: N\n"
+ ]
+ }
+ ],
+ "source": [
+ "!unzip /content/brats_120_images.zip"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "uxUhKxsIToTy",
+ "outputId": "fbd71819-0142-408e-8a01-1f0c38b4079e"
+ },
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "['brats_120_images/BraTS2021_00000_flair.nii', 'brats_120_images/BraTS2021_00002_flair.nii', 'brats_120_images/BraTS2021_00003_flair.nii', 'brats_120_images/BraTS2021_00005_flair.nii', 'brats_120_images/BraTS2021_00006_flair.nii', 'brats_120_images/BraTS2021_00008_flair.nii', 'brats_120_images/BraTS2021_00009_flair.nii', 'brats_120_images/BraTS2021_00011_flair.nii', 'brats_120_images/BraTS2021_00012_flair.nii', 'brats_120_images/BraTS2021_00014_flair.nii', 'brats_120_images/BraTS2021_00016_flair.nii', 'brats_120_images/BraTS2021_00017_flair.nii', 'brats_120_images/BraTS2021_00018_flair.nii', 'brats_120_images/BraTS2021_00019_flair.nii', 'brats_120_images/BraTS2021_00020_flair.nii', 'brats_120_images/BraTS2021_00021_flair.nii', 'brats_120_images/BraTS2021_00022_flair.nii', 'brats_120_images/BraTS2021_00024_flair.nii', 'brats_120_images/BraTS2021_00025_flair.nii', 'brats_120_images/BraTS2021_00026_flair.nii', 'brats_120_images/BraTS2021_00028_flair.nii', 'brats_120_images/BraTS2021_00030_flair.nii', 'brats_120_images/BraTS2021_00031_flair.nii', 'brats_120_images/BraTS2021_00032_flair.nii']\n",
+ "24\n",
+ "['brats_120_images/BraTS2021_00000_t1.nii', 'brats_120_images/BraTS2021_00002_t1.nii', 'brats_120_images/BraTS2021_00003_t1.nii', 'brats_120_images/BraTS2021_00005_t1.nii', 'brats_120_images/BraTS2021_00006_t1.nii', 'brats_120_images/BraTS2021_00008_t1.nii', 'brats_120_images/BraTS2021_00009_t1.nii', 'brats_120_images/BraTS2021_00011_t1.nii', 'brats_120_images/BraTS2021_00012_t1.nii', 'brats_120_images/BraTS2021_00014_t1.nii', 'brats_120_images/BraTS2021_00016_t1.nii', 'brats_120_images/BraTS2021_00017_t1.nii', 'brats_120_images/BraTS2021_00018_t1.nii', 'brats_120_images/BraTS2021_00019_t1.nii', 'brats_120_images/BraTS2021_00020_t1.nii', 'brats_120_images/BraTS2021_00021_t1.nii', 'brats_120_images/BraTS2021_00022_t1.nii', 'brats_120_images/BraTS2021_00024_t1.nii', 'brats_120_images/BraTS2021_00025_t1.nii', 'brats_120_images/BraTS2021_00026_t1.nii', 'brats_120_images/BraTS2021_00028_t1.nii', 'brats_120_images/BraTS2021_00030_t1.nii', 'brats_120_images/BraTS2021_00031_t1.nii', 'brats_120_images/BraTS2021_00032_t1.nii']\n",
+ "24\n",
+ "['brats_120_images/BraTS2021_00000_t1ce.nii', 'brats_120_images/BraTS2021_00002_t1ce.nii', 'brats_120_images/BraTS2021_00003_t1ce.nii', 'brats_120_images/BraTS2021_00005_t1ce.nii', 'brats_120_images/BraTS2021_00006_t1ce.nii', 'brats_120_images/BraTS2021_00008_t1ce.nii', 'brats_120_images/BraTS2021_00009_t1ce.nii', 'brats_120_images/BraTS2021_00011_t1ce.nii', 'brats_120_images/BraTS2021_00012_t1ce.nii', 'brats_120_images/BraTS2021_00014_t1ce.nii', 'brats_120_images/BraTS2021_00016_t1ce.nii', 'brats_120_images/BraTS2021_00017_t1ce.nii', 'brats_120_images/BraTS2021_00018_t1ce.nii', 'brats_120_images/BraTS2021_00019_t1ce.nii', 'brats_120_images/BraTS2021_00020_t1ce.nii', 'brats_120_images/BraTS2021_00021_t1ce.nii', 'brats_120_images/BraTS2021_00022_t1ce.nii', 'brats_120_images/BraTS2021_00024_t1ce.nii', 'brats_120_images/BraTS2021_00025_t1ce.nii', 'brats_120_images/BraTS2021_00026_t1ce.nii', 'brats_120_images/BraTS2021_00028_t1ce.nii', 'brats_120_images/BraTS2021_00030_t1ce.nii', 'brats_120_images/BraTS2021_00031_t1ce.nii', 'brats_120_images/BraTS2021_00032_t1ce.nii']\n",
+ "24\n",
+ "['brats_120_images/BraTS2021_00000_t2.nii', 'brats_120_images/BraTS2021_00002_t2.nii', 'brats_120_images/BraTS2021_00003_t2.nii', 'brats_120_images/BraTS2021_00005_t2.nii', 'brats_120_images/BraTS2021_00006_t2.nii', 'brats_120_images/BraTS2021_00008_t2.nii', 'brats_120_images/BraTS2021_00009_t2.nii', 'brats_120_images/BraTS2021_00011_t2.nii', 'brats_120_images/BraTS2021_00012_t2.nii', 'brats_120_images/BraTS2021_00014_t2.nii', 'brats_120_images/BraTS2021_00016_t2.nii', 'brats_120_images/BraTS2021_00017_t2.nii', 'brats_120_images/BraTS2021_00018_t2.nii', 'brats_120_images/BraTS2021_00019_t2.nii', 'brats_120_images/BraTS2021_00020_t2.nii', 'brats_120_images/BraTS2021_00021_t2.nii', 'brats_120_images/BraTS2021_00022_t2.nii', 'brats_120_images/BraTS2021_00024_t2.nii', 'brats_120_images/BraTS2021_00025_t2.nii', 'brats_120_images/BraTS2021_00026_t2.nii', 'brats_120_images/BraTS2021_00028_t2.nii', 'brats_120_images/BraTS2021_00030_t2.nii', 'brats_120_images/BraTS2021_00031_t2.nii', 'brats_120_images/BraTS2021_00032_t2.nii']\n",
+ "24\n",
+ "['brats_120_images/BraTS2021_00000_seg.nii', 'brats_120_images/BraTS2021_00002_seg.nii', 'brats_120_images/BraTS2021_00003_seg.nii', 'brats_120_images/BraTS2021_00005_seg.nii', 'brats_120_images/BraTS2021_00006_seg.nii', 'brats_120_images/BraTS2021_00008_seg.nii', 'brats_120_images/BraTS2021_00009_seg.nii', 'brats_120_images/BraTS2021_00011_seg.nii', 'brats_120_images/BraTS2021_00012_seg.nii', 'brats_120_images/BraTS2021_00014_seg.nii', 'brats_120_images/BraTS2021_00016_seg.nii', 'brats_120_images/BraTS2021_00017_seg.nii', 'brats_120_images/BraTS2021_00018_seg.nii', 'brats_120_images/BraTS2021_00019_seg.nii', 'brats_120_images/BraTS2021_00020_seg.nii', 'brats_120_images/BraTS2021_00021_seg.nii', 'brats_120_images/BraTS2021_00022_seg.nii', 'brats_120_images/BraTS2021_00024_seg.nii', 'brats_120_images/BraTS2021_00025_seg.nii', 'brats_120_images/BraTS2021_00026_seg.nii', 'brats_120_images/BraTS2021_00028_seg.nii', 'brats_120_images/BraTS2021_00030_seg.nii', 'brats_120_images/BraTS2021_00031_seg.nii', 'brats_120_images/BraTS2021_00032_seg.nii']\n",
+ "24\n",
+ "True\n"
+ ]
+ }
+ ],
+ "source": [
+ "import glob\n",
+ "\"\"\"\n",
+ "glob.glob\n",
+ "you can have a function for retrieving the file paths by having a variable for each of the volumes + segmented\n",
+ "e.x. for a segmentation file:\n",
+ "\"/Users/shizacharania/Desktop/brats_data/RSNA_ASNR_MICCAI_BraTS2021_TrainingData_16July2021/BraTS2021_00000_seg.nii\"\n",
+ "then you would look for the \"BraTS2021_\" in the beginning and the \"*/*\" stuff and then the \"_seg.nii\" (the extracted nifti files dont have \".gz\")\n",
+ "\"\"\"\n",
+ "\n",
+ "flair_paths = glob.glob(\"*/*_flair.nii\")\n",
+ "flair_paths = sorted(flair_paths)\n",
+ "print(flair_paths)\n",
+ "print(len(flair_paths))\n",
+ "\n",
+ "t1_paths = glob.glob(\"*/*_t1.nii\")\n",
+ "t1_paths = sorted(t1_paths)\n",
+ "print(t1_paths)\n",
+ "print(len(t1_paths))\n",
+ "\n",
+ "t1ce_paths = glob.glob(\"*/*_t1ce.nii\")\n",
+ "t1ce_paths = sorted(t1ce_paths)\n",
+ "print(t1ce_paths)\n",
+ "print(len(t1ce_paths))\n",
+ "\n",
+ "t2_paths = glob.glob(\"*/*_t2.nii\")\n",
+ "t2_paths = sorted(t2_paths)\n",
+ "print(t2_paths)\n",
+ "print(len(t2_paths))\n",
+ "\n",
+ "seg_paths = glob.glob(\"*/*_seg.nii\")\n",
+ "seg_paths = sorted(seg_paths)\n",
+ "print(seg_paths)\n",
+ "print(len(seg_paths))\n",
+ "\n",
+ "all = glob.glob(\"*/*.nii\")\n",
+ "print(24*5==len(all))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "_K1Kfei6Tsr6",
+ "outputId": "093f686e-17d6-4bfd-e56d-ebe9dffd9b77"
+ },
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "/content/brats_120_images/BraTS2021_00000_flair.nii\n",
+ "/content/brats_120_images/BraTS2021_00000_t1.nii\n",
+ "/content/brats_120_images/BraTS2021_00000_t1ce.nii\n",
+ "/content/brats_120_images/BraTS2021_00000_t2.nii\n",
+ "/content/brats_120_images/BraTS2021_00000_seg.nii\n"
+ ]
+ }
+ ],
+ "source": [
+ "# /content/brats_data_992/BraTS2021_00275_flair.nii\n",
+ "for i in range(len(flair_paths)):\n",
+ " flair_paths[i] = \"/content/\" + flair_paths[i]\n",
+ "\n",
+ "for i in range(len(t1_paths)):\n",
+ " t1_paths[i] = \"/content/\" + t1_paths[i]\n",
+ "\n",
+ "for i in range(len(t1ce_paths)):\n",
+ " t1ce_paths[i] = \"/content/\" + t1ce_paths[i]\n",
+ "\n",
+ "for i in range(len(t2_paths)):\n",
+ " t2_paths[i] = \"/content/\" + t2_paths[i]\n",
+ "\n",
+ "for i in range(len(seg_paths)):\n",
+ " seg_paths[i] = \"/content/\" + seg_paths[i]\n",
+ "\n",
+ "print(flair_paths[0])\n",
+ "print(t1_paths[0])\n",
+ "print(t1ce_paths[0])\n",
+ "print(t2_paths[0])\n",
+ "print(seg_paths[0])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 87
+ },
+ "id": "4JnhkIMBNnKb",
+ "outputId": "5b71aaac-3a8a-48ae-e62f-ef5083038bda"
+ },
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "'\\nmy approach to visualize 3d images:\\n- use simpleitk (sitk)\\n - i need to load the images into sitk format and then convert it into a numpy array\\n\\n- from a numpy array, i need to do 2 tasks\\n 1. i will look at a stack of 2d arrays (that form a 3d image) and visualize the slices for that\\n 2. i will visualize the 3d image entirely and have a scrolling feature that goes through these 2d array slices\\n\\nlook into basics of simpleitk - how to read the file and then convert it into np.array()\\nlook into \"Exploring 3D images with Matplotlib\" - https://www.youtube.com/watch?v=5jQVQE6yfio\\nlook into what fatemeh did: https://youtu.be/rBIetBho0x4\\n'"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 6
+ }
+ ],
+ "source": [
+ "\"\"\"\n",
+ "my approach to visualize 3d images:\n",
+ "- use simpleitk (sitk)\n",
+ " - i need to load the images into sitk format and then convert it into a numpy array\n",
+ "\n",
+ "- from a numpy array, i need to do 2 tasks\n",
+ " 1. i will look at a stack of 2d arrays (that form a 3d image) and visualize the slices for that\n",
+ " 2. i will visualize the 3d image entirely and have a scrolling feature that goes through these 2d array slices\n",
+ "\n",
+ "look into basics of simpleitk - how to read the file and then convert it into np.array()\n",
+ "look into \"Exploring 3D images with Matplotlib\" - https://www.youtube.com/watch?v=5jQVQE6yfio\n",
+ "look into what fatemeh did: https://youtu.be/rBIetBho0x4\n",
+ "\"\"\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "ddvherI7gu54",
+ "outputId": "394f974c-d0d4-4b35-cc27-6fe1ddadb705"
+ },
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
+ "Requirement already satisfied: SimpleITK in /usr/local/lib/python3.7/dist-packages (2.2.0)\n"
+ ]
+ }
+ ],
+ "source": [
+ "!pip install SimpleITK"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "id": "dkPF64fHgqOq"
+ },
+ "outputs": [],
+ "source": [
+ "import SimpleITK as sitk"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "id": "t9ujRnCFWVpi"
+ },
+ "outputs": [],
+ "source": [
+ "# reading a file in simpleitk (sitk)\n",
+ "\n",
+ "flair_nparrays = []\n",
+ "t1_nparrays = []\n",
+ "t1ce_nparrays = []\n",
+ "t2_nparrays = []\n",
+ "seg_nparrays = []\n",
+ "\n",
+ "for flair_imagepath in flair_paths:\n",
+ " img = sitk.ReadImage(flair_imagepath)\n",
+ " img = sitk.GetArrayFromImage(img)\n",
+ " flair_nparrays.append(img)\n",
+ "\n",
+ "for t1_imagepath in t1_paths:\n",
+ " img = sitk.ReadImage(t1_imagepath)\n",
+ " img = sitk.GetArrayFromImage(img)\n",
+ " t1_nparrays.append(img)\n",
+ "\n",
+ "for t1ce_imagepath in t1ce_paths:\n",
+ " img = sitk.ReadImage(t1ce_imagepath)\n",
+ " img = sitk.GetArrayFromImage(img)\n",
+ " t1ce_nparrays.append(img)\n",
+ "\n",
+ "for t2_imagepath in t2_paths:\n",
+ " img = sitk.ReadImage(t2_imagepath)\n",
+ " img = sitk.GetArrayFromImage(img)\n",
+ " t2_nparrays.append(img)\n",
+ "\n",
+ "for seg_imagepath in seg_paths:\n",
+ " img = sitk.ReadImage(seg_imagepath)\n",
+ " img = sitk.GetArrayFromImage(img)\n",
+ " seg_nparrays.append(img)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "FCLSjDeCjuD5",
+ "outputId": "f176d449-2dbb-41c4-f325-b3896c3f5849"
+ },
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "24\n",
+ "24\n",
+ "24\n",
+ "24\n",
+ "24\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(len(flair_nparrays))\n",
+ "print(len(t1_nparrays))\n",
+ "print(len(t1ce_nparrays))\n",
+ "print(len(t2_nparrays))\n",
+ "print(len(seg_nparrays))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "id": "lIEdCmqslIeT"
+ },
+ "outputs": [],
+ "source": [
+ "# i will look at a stack of 2d arrays (that form a 3d image) and visualize the slices for that\n",
+ "\n",
+ "import matplotlib.pyplot as plt\n",
+ "import numpy"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "id": "3mMi6OC51qSu"
+ },
+ "outputs": [],
+ "source": [
+ "from ipywidgets import interact, interactive, IntSlider, ToggleButtons\n",
+ "\n",
+ "# I'll do this part by myself after"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 769
+ },
+ "id": "Y0Dp5OUNHFMa",
+ "outputId": "cac50b6b-bef2-468e-9c9f-5f293a811080"
+ },
+ "outputs": [
+ {
+ "output_type": "display_data",
+ "data": {
+ "text/plain": [
+ "