{"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":"# Installation boiler plate \n! pip install -U pylibjpeg pylibjpeg-openjpeg pylibjpeg-libjpeg pydicom python-gdcm\n! pip install --upgrade pydicom","metadata":{"execution":{"iopub.status.busy":"2023-02-04T04:17:17.849266Z","iopub.execute_input":"2023-02-04T04:17:17.849597Z","iopub.status.idle":"2023-02-04T04:17:39.473556Z","shell.execute_reply.started":"2023-02-04T04:17:17.849571Z","shell.execute_reply":"2023-02-04T04:17:39.472286Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd \nimport tensorflow as tf \nimport fastai \n\nfrom fastai.vision.all import * \nimport numpy as np \nimport matplotlib.pyplot as plt \n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-02-04T04:05:31.684692Z","iopub.execute_input":"2023-02-04T04:05:31.685437Z","iopub.status.idle":"2023-02-04T04:05:39.46138Z","shell.execute_reply.started":"2023-02-04T04:05:31.685335Z","shell.execute_reply":"2023-02-04T04:05:39.460295Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Loading in the data \ntrain_df = pd.read_csv(\"/kaggle/input/rsna-breast-cancer-detection/train.csv\")\ntest_df = pd.read_csv(\"/kaggle/input/rsna-breast-cancer-detection/test.csv\")\nsample_sub_df = pd.read_csv(\"/kaggle/input/rsna-breast-cancer-detection/sample_submission.csv\")\n\n# Paths\ntrain_path = \"/kaggle/input/rsna-breast-cancer-detection/train_images/\"\ntest_path = \"/kaggle/input/rsna-breast-cancer-detection/test_images/\"\n\n\ntrain_df.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-02-04T04:07:38.737021Z","iopub.execute_input":"2023-02-04T04:07:38.737449Z","iopub.status.idle":"2023-02-04T04:07:38.809175Z","shell.execute_reply.started":"2023-02-04T04:07:38.737415Z","shell.execute_reply":"2023-02-04T04:07:38.808562Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Create the data path \n\n# train_path + patient_id + image_id \ndef make_paths(patientId , imageId):\n    return train_path + str(patientId) + \"/\" + str(imageId) +\".dcm\"\n\ntrain_df['image_full_path'] = train_df.apply(lambda x: make_paths(x.patient_id , x.image_id), axis = 1)\n\ntrain_df.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-02-04T04:15:18.810823Z","iopub.execute_input":"2023-02-04T04:15:18.811178Z","iopub.status.idle":"2023-02-04T04:15:19.974053Z","shell.execute_reply.started":"2023-02-04T04:15:18.81115Z","shell.execute_reply":"2023-02-04T04:15:19.973056Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import random \nimport pydicom\n\n# Reading a random dicom file\nfilePath = random.choice(train_df['image_full_path'])\ndcmImage = pydicom.dcmread(filePath , force = True)\n\n# Visualizing the above image \nimgArray = dcmImage.pixel_array # converting into pixel array \nplt.imshow(imgArray)\n","metadata":{"execution":{"iopub.status.busy":"2023-02-04T04:27:26.537219Z","iopub.execute_input":"2023-02-04T04:27:26.537548Z","iopub.status.idle":"2023-02-04T04:27:28.796503Z","shell.execute_reply.started":"2023-02-04T04:27:26.537521Z","shell.execute_reply":"2023-02-04T04:27:28.795521Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking the labels \ntrain_df['cancer'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-02-04T04:29:02.280596Z","iopub.execute_input":"2023-02-04T04:29:02.28128Z","iopub.status.idle":"2023-02-04T04:29:02.289063Z","shell.execute_reply.started":"2023-02-04T04:29:02.281237Z","shell.execute_reply":"2023-02-04T04:29:02.288282Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}