{"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\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-09-11T06:29:41.940853Z","iopub.execute_input":"2022-09-11T06:29:41.941292Z","iopub.status.idle":"2022-09-11T06:29:41.980472Z","shell.execute_reply.started":"2022-09-11T06:29:41.941203Z","shell.execute_reply":"2022-09-11T06:29:41.97948Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import torch\nimport torch.nn as nn\nimport torchvision.transforms as transforms\nfrom torch.autograd import Variable\nimport pandas as pd\nfrom sklearn.model_selection import train_test_split\nfrom glob import glob\nimport pydicom\nimport nibabel as nib","metadata":{"execution":{"iopub.status.busy":"2022-09-11T07:22:00.932497Z","iopub.execute_input":"2022-09-11T07:22:00.932875Z","iopub.status.idle":"2022-09-11T07:22:01.030636Z","shell.execute_reply.started":"2022-09-11T07:22:00.932846Z","shell.execute_reply":"2022-09-11T07:22:01.029567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def generate_dataset(patient_seg_paths):\n    images = []\n    features = []\n    result = []\n    for i in patient_seg_paths:\n        patient_id = i.split(\"/\")\n        patient_id = patient_id[-1].replace(\".nii\",\"\")\n        patient_dcom_path = train_dir + patient_id + \"/*\"\n        patient_dcom_files_path = glob(patient_dcom_path)\n        for j in patient_dcom_files_path:\n            patient_id = i.split(\"/\")\n            patient_id = patient_id[-1].replace(\".nii\",\"\")\n\n\n    \n    \n    \n        \n    ","metadata":{"execution":{"iopub.status.busy":"2022-09-11T07:31:46.882292Z","iopub.execute_input":"2022-09-11T07:31:46.883085Z","iopub.status.idle":"2022-09-11T07:31:46.889481Z","shell.execute_reply.started":"2022-09-11T07:31:46.883041Z","shell.execute_reply":"2022-09-11T07:31:46.888471Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"patient_seg_paths = glob('../input/rsna-2022-cervical-spine-fracture-detection/segmentations/*')\ntrain_dir = \"../input/rsna-2022-cervical-spine-fracture-detection/train_images/\"","metadata":{"execution":{"iopub.status.busy":"2022-09-11T07:31:48.10227Z","iopub.execute_input":"2022-09-11T07:31:48.103072Z","iopub.status.idle":"2022-09-11T07:31:48.110648Z","shell.execute_reply.started":"2022-09-11T07:31:48.103031Z","shell.execute_reply":"2022-09-11T07:31:48.109553Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"generate_dataset(patient_seg_paths)","metadata":{"execution":{"iopub.status.busy":"2022-09-11T07:31:48.942281Z","iopub.execute_input":"2022-09-11T07:31:48.943142Z","iopub.status.idle":"2022-09-11T07:31:54.648977Z","shell.execute_reply.started":"2022-09-11T07:31:48.9431Z","shell.execute_reply":"2022-09-11T07:31:54.647723Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ex_path = patient_files[0]\nexample = nib.load(ex_path)\nheader = example.header\nprint(header)","metadata":{"execution":{"iopub.status.busy":"2022-09-11T07:23:01.091165Z","iopub.execute_input":"2022-09-11T07:23:01.091697Z","iopub.status.idle":"2022-09-11T07:23:01.10567Z","shell.execute_reply.started":"2022-09-11T07:23:01.09165Z","shell.execute_reply":"2022-09-11T07:23:01.104367Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"images_file = glob(patient_files[0] + \"/*\")","metadata":{"execution":{"iopub.status.busy":"2022-09-11T07:05:08.036348Z","iopub.execute_input":"2022-09-11T07:05:08.036839Z","iopub.status.idle":"2022-09-11T07:05:08.069303Z","shell.execute_reply.started":"2022-09-11T07:05:08.036801Z","shell.execute_reply":"2022-09-11T07:05:08.068472Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img = pydicom.dcmread(images_file[0])\nimg","metadata":{"execution":{"iopub.status.busy":"2022-09-11T07:06:32.446542Z","iopub.execute_input":"2022-09-11T07:06:32.446968Z","iopub.status.idle":"2022-09-11T07:06:32.458208Z","shell.execute_reply.started":"2022-09-11T07:06:32.446936Z","shell.execute_reply":"2022-09-11T07:06:32.457023Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"generate_dataset(patient_files)","metadata":{"execution":{"iopub.status.busy":"2022-09-11T07:09:00.966346Z","iopub.execute_input":"2022-09-11T07:09:00.967315Z","iopub.status.idle":"2022-09-11T07:09:00.996256Z","shell.execute_reply.started":"2022-09-11T07:09:00.967265Z","shell.execute_reply":"2022-09-11T07:09:00.995467Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}