{"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 pandas as pd \nimport numpy as np\nlabel_csv=pd.read_csv('../input/siim-covid19-detection/train_image_level.csv')\nprint(label_csv.shape)\nlabel_csv.head()\n","metadata":{"execution":{"iopub.status.busy":"2021-06-12T02:40:37.61457Z","iopub.execute_input":"2021-06-12T02:40:37.614893Z","iopub.status.idle":"2021-06-12T02:40:37.656026Z","shell.execute_reply.started":"2021-06-12T02:40:37.614865Z","shell.execute_reply":"2021-06-12T02:40:37.655016Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cls_csv=pd.read_csv('../input/siim-covid19-detection/train_study_level.csv')\nprint(cls_csv.shape)\ncls_csv.head(50)","metadata":{"execution":{"iopub.status.busy":"2021-06-12T02:53:52.048484Z","iopub.execute_input":"2021-06-12T02:53:52.049077Z","iopub.status.idle":"2021-06-12T02:53:52.080964Z","shell.execute_reply.started":"2021-06-12T02:53:52.049015Z","shell.execute_reply":"2021-06-12T02:53:52.079926Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import GroupKFold\ngkf=GroupKFold(n_splits=5)\nlabel_csv['fold']=-1\nfor fold,(train_idx,val_idx) in enumerate(gkf.split(label_csv,groups=label_csv.StudyInstanceUID.tolist())):\n    label_csv.loc[val_idx,'fold']=fold\nlabel_csv.head(100)\nlabel_csv.to_csv('lavel_fold.csv')\n","metadata":{"execution":{"iopub.status.busy":"2021-06-12T03:01:06.523531Z","iopub.execute_input":"2021-06-12T03:01:06.523868Z","iopub.status.idle":"2021-06-12T03:01:06.637879Z","shell.execute_reply.started":"2021-06-12T03:01:06.523825Z","shell.execute_reply":"2021-06-12T03:01:06.637088Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cls_csv[\"study_id\"] = cls_csv[\"id\"].apply(lambda x: x.split(\"_\")[0])\nlabel_csv[\"image_id\"]=label_csv[\"id\"].apply(lambda x:x.split(\"_\")[0])","metadata":{"execution":{"iopub.status.busy":"2021-06-12T02:52:16.878682Z","iopub.execute_input":"2021-06-12T02:52:16.879014Z","iopub.status.idle":"2021-06-12T02:52:16.89559Z","shell.execute_reply.started":"2021-06-12T02:52:16.87897Z","shell.execute_reply":"2021-06-12T02:52:16.894173Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"train_image analysis","metadata":{}},{"cell_type":"code","source":"total = pd.merge(label_csv, cls_csv, \n                 left_on=\"StudyInstanceUID\", right_on=\"study_id\")\ntotal.drop([\"id_x\", \"StudyInstanceUID\", \"id_y\"], axis=1, inplace=True)\ntotal.head()","metadata":{"execution":{"iopub.status.busy":"2021-06-12T02:52:34.301497Z","iopub.execute_input":"2021-06-12T02:52:34.301864Z","iopub.status.idle":"2021-06-12T02:52:34.329137Z","shell.execute_reply.started":"2021-06-12T02:52:34.301835Z","shell.execute_reply":"2021-06-12T02:52:34.328108Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"total[total[\"study_id\"] == \"0fd2db233deb\"]\ntotal.to_csv(\"total.csv\")\n","metadata":{"execution":{"iopub.status.busy":"2021-06-12T02:59:58.848411Z","iopub.execute_input":"2021-06-12T02:59:58.84888Z","iopub.status.idle":"2021-06-12T02:59:58.930065Z","shell.execute_reply.started":"2021-06-12T02:59:58.848851Z","shell.execute_reply":"2021-06-12T02:59:58.929233Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pwd","metadata":{"execution":{"iopub.status.busy":"2021-06-12T02:58:21.551682Z","iopub.execute_input":"2021-06-12T02:58:21.552073Z","iopub.status.idle":"2021-06-12T02:58:21.557221Z","shell.execute_reply.started":"2021-06-12T02:58:21.552019Z","shell.execute_reply":"2021-06-12T02:58:21.556203Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"from above ,we can see that the one study have many images  ","metadata":{}},{"cell_type":"markdown","source":"import pydicm\nfrom pydicom.pixel_data_handlers.util import apply_voi_lut\n","metadata":{}},{"cell_type":"markdown","source":"reference : https://www.kaggle.com/andradaolteanu/siim-covid-19-box-detect-dcm-metadata\n","metadata":{}}]}