{"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":"# 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\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../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","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-05-24T08:12:44.987674Z","iopub.execute_input":"2021-05-24T08:12:44.988036Z","iopub.status.idle":"2021-05-24T08:12:44.993592Z","shell.execute_reply.started":"2021-05-24T08:12:44.988008Z","shell.execute_reply":"2021-05-24T08:12:44.992036Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_image_level = pd.read_csv(\"../input/siim-covid19-detection/train_image_level.csv\")\ntrain_study_level = pd.read_csv(\"../input/siim-covid19-detection/train_study_level.csv\")\nsample_sub = pd.read_csv(\"../input/siim-covid19-detection/train_study_level.csv\")","metadata":{"execution":{"iopub.status.busy":"2021-05-24T08:13:51.354010Z","iopub.execute_input":"2021-05-24T08:13:51.354437Z","iopub.status.idle":"2021-05-24T08:13:51.438011Z","shell.execute_reply.started":"2021-05-24T08:13:51.354409Z","shell.execute_reply":"2021-05-24T08:13:51.437069Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_image_level.head()","metadata":{"execution":{"iopub.status.busy":"2021-05-24T08:14:01.267648Z","iopub.execute_input":"2021-05-24T08:14:01.268006Z","iopub.status.idle":"2021-05-24T08:14:01.302988Z","shell.execute_reply.started":"2021-05-24T08:14:01.267977Z","shell.execute_reply":"2021-05-24T08:14:01.302066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_study_level.head()","metadata":{"execution":{"iopub.status.busy":"2021-05-24T08:14:09.013673Z","iopub.execute_input":"2021-05-24T08:14:09.014045Z","iopub.status.idle":"2021-05-24T08:14:09.023063Z","shell.execute_reply.started":"2021-05-24T08:14:09.014023Z","shell.execute_reply":"2021-05-24T08:14:09.021958Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_sub.head()","metadata":{"execution":{"iopub.status.busy":"2021-05-24T08:14:16.565308Z","iopub.execute_input":"2021-05-24T08:14:16.565654Z","iopub.status.idle":"2021-05-24T08:14:16.577980Z","shell.execute_reply.started":"2021-05-24T08:14:16.565631Z","shell.execute_reply":"2021-05-24T08:14:16.577132Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip3 install pydicom","metadata":{"execution":{"iopub.status.busy":"2021-05-24T08:16:04.023809Z","iopub.execute_input":"2021-05-24T08:16:04.024138Z","iopub.status.idle":"2021-05-24T08:16:11.885868Z","shell.execute_reply.started":"2021-05-24T08:16:04.024109Z","shell.execute_reply":"2021-05-24T08:16:11.884547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pydicom as dicom\nimport matplotlib.pylab as plt\n\nds = dicom.dcmread(\"../input/siim-covid19-detection/train/00086460a852/9e8302230c91/65761e66de9f.dcm\")\n\nplt.imshow(ds.pixel_array)","metadata":{"execution":{"iopub.status.busy":"2021-05-24T08:28:37.036030Z","iopub.execute_input":"2021-05-24T08:28:37.036297Z","iopub.status.idle":"2021-05-24T08:28:37.676527Z","shell.execute_reply.started":"2021-05-24T08:28:37.036274Z","shell.execute_reply":"2021-05-24T08:28:37.675474Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import cv2   \n\ndef dicom2jpg(input_path, output_path):\n    ds = dicom.dcmread(input_path)\n    pixel_array_numpy = ds.pixel_array\n    cv2.imwrite(output_path, pixel_array_numpy)\n#Testing function\ndicom2jpg(\"../input/siim-covid19-detection/train/00086460a852/9e8302230c91/65761e66de9f.dcm\", \"./65761e66de9f.png\")\n#Showing function output\n%pylab inline\nimport matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\nimg = mpimg.imread('./65761e66de9f.png')\nimgplot = plt.imshow(img)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-05-24T08:29:38.458686Z","iopub.execute_input":"2021-05-24T08:29:38.458956Z","iopub.status.idle":"2021-05-24T08:29:39.524191Z","shell.execute_reply.started":"2021-05-24T08:29:38.458934Z","shell.execute_reply":"2021-05-24T08:29:39.523098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_sub_1 = [x[0] for x in os.walk('../input/siim-covid19-detection/train')]\nprint(train_sub_1[:10])","metadata":{"execution":{"iopub.status.busy":"2021-05-24T08:33:56.862040Z","iopub.execute_input":"2021-05-24T08:33:56.862395Z","iopub.status.idle":"2021-05-24T08:34:11.049530Z","shell.execute_reply.started":"2021-05-24T08:33:56.862372Z","shell.execute_reply":"2021-05-24T08:34:11.048635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2021-05-24T08:31:09.045062Z","iopub.execute_input":"2021-05-24T08:31:09.045421Z","iopub.status.idle":"2021-05-24T08:31:09.056105Z","shell.execute_reply.started":"2021-05-24T08:31:09.045398Z","shell.execute_reply":"2021-05-24T08:31:09.055383Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}