{"cells":[{"metadata":{},"cell_type":"markdown","source":"# RANZCR CLiP - Catheter and Line Position Challenge"},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport os\nimport json\nimport cv2\nimport matplotlib.pyplot as plt\n\nplt.rcParams[\"figure.figsize\"] = (30,10)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"base_folder='../input/ranzcr-clip-catheter-line-classification'\nimage_folder='../input/ranzcr-clip-catheter-line-classification/train'","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_train=pd.read_csv(os.path.join(base_folder, 'train.csv'))\ndf_mask=pd.read_csv(os.path.join(base_folder, 'train_annotations.csv'))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_mask.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_ETT_ab=df_mask[df_mask['label']=='ETT - Abnormal'].reset_index(drop=True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_ETT_ab","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"def showing_img(index):\n    print (df_ETT_ab.iloc[index].StudyInstanceUID)\n    data=df_ETT_ab.iloc[index]['data']\n    coors=json.loads(data)\n    images=cv2.imread(os.path.join(image_folder, df_ETT_ab.iloc[index]['StudyInstanceUID']+'.jpg'),0)\n    images=cv2.cvtColor(clahe.apply(images),cv2.COLOR_GRAY2RGB)\n\n    images_ori=images.copy()\n    h,w=images.shape[0:2]\n    blue = (0, 0, 255)\n    for n, j in enumerate(coors):\n        if n != len(coors)-1:\n            print (coors[n])\n            cv2.line(images, tuple(coors[n]), tuple(coors[n+1]), blue, 3)\n    \n    plt.subplot(121)\n    plt.imshow(images_ori)\n    plt.subplot(122)\n    plt.imshow(images)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Before we start, please check out domain knowledge from dr. Konya's great article (https://www.kaggle.com/c/ranzcr-clip-catheter-line-classification/discussion/204790)"},{"metadata":{},"cell_type":"markdown","source":"# The abnormal tip position of endotracheal tube\n    1. TOO deep\n    2. TOO shallow"},{"metadata":{},"cell_type":"markdown","source":"# 1. TOO deep example"},{"metadata":{"trusted":true},"cell_type":"code","source":"showing_img(2)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"the tip of endotracheal tube enters into right main bronchus"},{"metadata":{},"cell_type":"markdown","source":"# 2. TOO shallow example"},{"metadata":{"trusted":true},"cell_type":"code","source":"showing_img(3)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"No visualization of the tip of endotracheal tube near tracheal bifurcation"},{"metadata":{},"cell_type":"markdown","source":"There are only 29 ETT-abnormal cases. (Total is 30 but one case is not abnormal ETT case).\n\nIt is small datasets to learn abnormal ETT position.\n\nSo I think that models have to find relationship between the tip or all of the endotracheal tube and tracheal bifurcation."},{"metadata":{},"cell_type":"markdown","source":"# ** NOT ETT abnormal **\n# 1.2.826.0.1.3680043.8.498.93345761486297843389996628528592497280\n"},{"metadata":{},"cell_type":"markdown","source":"# ** No visualization of tracheostomy tube in abnormal cases **\nPlease check discussions about this. (https://www.kaggle.com/c/ranzcr-clip-catheter-line-classification/discussion/220872) "}],"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":4,"nbformat_minor":4}