{"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 # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-08-01T16:14:45.822615Z","iopub.execute_input":"2022-08-01T16:14:45.823668Z","iopub.status.idle":"2022-08-01T16:14:45.827758Z","shell.execute_reply.started":"2022-08-01T16:14:45.823631Z","shell.execute_reply":"2022-08-01T16:14:45.826888Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pwd","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:10:32.100091Z","iopub.execute_input":"2022-08-01T16:10:32.100506Z","iopub.status.idle":"2022-08-01T16:10:32.907822Z","shell.execute_reply.started":"2022-08-01T16:10:32.10042Z","shell.execute_reply":"2022-08-01T16:10:32.90649Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls /kaggle/input/rsna-2022-cervical-spine-fracture-detection","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:12:11.828897Z","iopub.execute_input":"2022-08-01T16:12:11.829436Z","iopub.status.idle":"2022-08-01T16:12:12.621114Z","shell.execute_reply.started":"2022-08-01T16:12:11.829379Z","shell.execute_reply":"2022-08-01T16:12:12.619824Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"INPUT_PATH = r\"/kaggle/input/rsna-2022-cervical-spine-fracture-detection\"","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:14:52.668642Z","iopub.execute_input":"2022-08-01T16:14:52.66924Z","iopub.status.idle":"2022-08-01T16:14:52.674293Z","shell.execute_reply.started":"2022-08-01T16:14:52.669198Z","shell.execute_reply":"2022-08-01T16:14:52.67324Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_csv(f\"{INPUT_PATH}/train.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:14:54.958703Z","iopub.execute_input":"2022-08-01T16:14:54.959559Z","iopub.status.idle":"2022-08-01T16:14:54.982874Z","shell.execute_reply.started":"2022-08-01T16:14:54.959524Z","shell.execute_reply":"2022-08-01T16:14:54.982086Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Viewing 10 rows of train CSV ","metadata":{}},{"cell_type":"code","source":"train_df.head(10)","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:15:16.81637Z","iopub.execute_input":"2022-08-01T16:15:16.817231Z","iopub.status.idle":"2022-08-01T16:15:16.83087Z","shell.execute_reply.started":"2022-08-01T16:15:16.817174Z","shell.execute_reply":"2022-08-01T16:15:16.830048Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_bounding_df = pd.read_csv(f\"{INPUT_PATH}/train_bounding_boxes.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:53:33.186545Z","iopub.execute_input":"2022-08-01T16:53:33.186921Z","iopub.status.idle":"2022-08-01T16:53:33.216111Z","shell.execute_reply.started":"2022-08-01T16:53:33.186891Z","shell.execute_reply":"2022-08-01T16:53:33.215069Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_bounding_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:53:52.200286Z","iopub.execute_input":"2022-08-01T16:53:52.200641Z","iopub.status.idle":"2022-08-01T16:53:52.217215Z","shell.execute_reply.started":"2022-08-01T16:53:52.200613Z","shell.execute_reply":"2022-08-01T16:53:52.216453Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from pydicom import dcmread","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:19:35.023151Z","iopub.execute_input":"2022-08-01T16:19:35.024007Z","iopub.status.idle":"2022-08-01T16:19:35.028755Z","shell.execute_reply.started":"2022-08-01T16:19:35.023966Z","shell.execute_reply":"2022-08-01T16:19:35.027835Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls /kaggle/input/rsna-2022-cervical-spine-fracture-detection/train_images/1.2.826.0.1.3680043.27262","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:19:03.818577Z","iopub.execute_input":"2022-08-01T16:19:03.819523Z","iopub.status.idle":"2022-08-01T16:19:04.662379Z","shell.execute_reply.started":"2022-08-01T16:19:03.819485Z","shell.execute_reply":"2022-08-01T16:19:04.660905Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ds = dcmread(f\"{INPUT_PATH}/train_images/1.2.826.0.1.3680043.27262/1.dcm\")","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:20:26.222267Z","iopub.execute_input":"2022-08-01T16:20:26.22311Z","iopub.status.idle":"2022-08-01T16:20:26.24534Z","shell.execute_reply.started":"2022-08-01T16:20:26.223072Z","shell.execute_reply":"2022-08-01T16:20:26.244592Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ds","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:20:31.308005Z","iopub.execute_input":"2022-08-01T16:20:31.308994Z","iopub.status.idle":"2022-08-01T16:20:31.31683Z","shell.execute_reply.started":"2022-08-01T16:20:31.308944Z","shell.execute_reply":"2022-08-01T16:20:31.31576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# DICOM images","metadata":{}},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n\nplt.imshow(ds.pixel_array, cmap=plt.cm.gray)","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:26:17.004863Z","iopub.execute_input":"2022-08-01T16:26:17.005267Z","iopub.status.idle":"2022-08-01T16:26:17.209304Z","shell.execute_reply.started":"2022-08-01T16:26:17.005234Z","shell.execute_reply":"2022-08-01T16:26:17.208278Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# NIfTI segmentation masks","metadata":{}},{"cell_type":"code","source":"import nibabel as nib\n\nnii_img = nib.load(f\"{INPUT_PATH}/segmentations/1.2.826.0.1.3680043.10633.nii\")","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:36:26.354814Z","iopub.execute_input":"2022-08-01T16:36:26.355934Z","iopub.status.idle":"2022-08-01T16:36:26.365555Z","shell.execute_reply.started":"2022-08-01T16:36:26.355891Z","shell.execute_reply":"2022-08-01T16:36:26.364778Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nii_img.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:36:29.42993Z","iopub.execute_input":"2022-08-01T16:36:29.430302Z","iopub.status.idle":"2022-08-01T16:36:29.436909Z","shell.execute_reply.started":"2022-08-01T16:36:29.43027Z","shell.execute_reply":"2022-08-01T16:36:29.435896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(nii_img.header)","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:36:32.364617Z","iopub.execute_input":"2022-08-01T16:36:32.365212Z","iopub.status.idle":"2022-08-01T16:36:32.372922Z","shell.execute_reply.started":"2022-08-01T16:36:32.365162Z","shell.execute_reply":"2022-08-01T16:36:32.371942Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"imgseg = nii_img.get_data()","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:43:07.717921Z","iopub.execute_input":"2022-08-01T16:43:07.718867Z","iopub.status.idle":"2022-08-01T16:43:07.724028Z","shell.execute_reply.started":"2022-08-01T16:43:07.718829Z","shell.execute_reply":"2022-08-01T16:43:07.722915Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(imgseg[:,:,1])","metadata":{"execution":{"iopub.status.busy":"2022-08-01T16:51:11.269426Z","iopub.execute_input":"2022-08-01T16:51:11.269784Z","iopub.status.idle":"2022-08-01T16:51:11.475296Z","shell.execute_reply.started":"2022-08-01T16:51:11.269756Z","shell.execute_reply":"2022-08-01T16:51:11.47431Z"},"trusted":true},"execution_count":null,"outputs":[]}]}