{"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":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom tqdm import tqdm\nfrom pathlib import Path\nimport pydicom\nfrom pydicom.pixel_data_handlers.util import apply_voi_lut","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-01-07T16:31:09.271987Z","iopub.execute_input":"2023-01-07T16:31:09.272457Z","iopub.status.idle":"2023-01-07T16:31:10.066885Z","shell.execute_reply.started":"2023-01-07T16:31:09.272418Z","shell.execute_reply":"2023-01-07T16:31:10.065587Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ex_path = \"/kaggle/input/rsna-breast-cancer-detection/train_images/10006/1459541791.dcm\"\ndcm_example = pydicom.dcmread(ex_path)\nprint(type(dcm_example))\ndcm_example","metadata":{"execution":{"iopub.status.busy":"2023-01-07T16:31:10.809609Z","iopub.execute_input":"2023-01-07T16:31:10.810048Z","iopub.status.idle":"2023-01-07T16:31:10.902931Z","shell.execute_reply.started":"2023-01-07T16:31:10.810013Z","shell.execute_reply":"2023-01-07T16:31:10.90161Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dcm_example.Rows #width","metadata":{"execution":{"iopub.status.busy":"2023-01-07T16:31:13.354629Z","iopub.execute_input":"2023-01-07T16:31:13.355038Z","iopub.status.idle":"2023-01-07T16:31:13.363101Z","shell.execute_reply.started":"2023-01-07T16:31:13.355006Z","shell.execute_reply":"2023-01-07T16:31:13.361889Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dirs = list(Path('/kaggle/input/rsna-breast-cancer-detection/train_images').glob('*'))\ntraining_images = []\nfor d in tqdm(dirs):\n    training_images += list((d.glob('*')))\nlen(training_images)","metadata":{"execution":{"iopub.status.busy":"2023-01-07T16:32:10.863171Z","iopub.execute_input":"2023-01-07T16:32:10.863561Z","iopub.status.idle":"2023-01-07T16:32:33.881602Z","shell.execute_reply.started":"2023-01-07T16:32:10.863531Z","shell.execute_reply":"2023-01-07T16:32:33.880636Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_csv('/kaggle/input/rsna-breast-cancer-detection/train.csv')\n\ntrain_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-01-07T16:32:38.88192Z","iopub.execute_input":"2023-01-07T16:32:38.882349Z","iopub.status.idle":"2023-01-07T16:32:39.0275Z","shell.execute_reply.started":"2023-01-07T16:32:38.882317Z","shell.execute_reply":"2023-01-07T16:32:39.026613Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.image_id.nunique()","metadata":{"execution":{"iopub.status.busy":"2023-01-07T16:32:40.707649Z","iopub.execute_input":"2023-01-07T16:32:40.708049Z","iopub.status.idle":"2023-01-07T16:32:40.727059Z","shell.execute_reply.started":"2023-01-07T16:32:40.708018Z","shell.execute_reply":"2023-01-07T16:32:40.725853Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"width, height = [], []\nfor image_path in tqdm(training_images):\n    dcm_image = pydicom.dcmread(image_path)\n    width.append(dcm_image.Rows) #width\n    height.append(dcm_image.Columns)","metadata":{"execution":{"iopub.status.busy":"2023-01-07T16:36:14.126233Z","iopub.execute_input":"2023-01-07T16:36:14.126676Z","iopub.status.idle":"2023-01-07T17:24:11.209667Z","shell.execute_reply.started":"2023-01-07T16:36:14.126628Z","shell.execute_reply":"2023-01-07T17:24:11.207595Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(10, 10))\nplt.subplot(2, 1, 1)\nsns.countplot(x=width)\nplt.title('Width of all training images')\n\nplt.subplot(2, 1, 2)\nsns.countplot(x=height)\nplt.title('Height of all training images');","metadata":{"execution":{"iopub.status.busy":"2023-01-07T17:29:24.684348Z","iopub.execute_input":"2023-01-07T17:29:24.684776Z","iopub.status.idle":"2023-01-07T17:29:25.459851Z","shell.execute_reply.started":"2023-01-07T17:29:24.684742Z","shell.execute_reply":"2023-01-07T17:29:25.458594Z"},"trusted":true},"execution_count":null,"outputs":[]}]}