{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import pandas as pd\nimport os\nimport json\nfrom matplotlib import pyplot as plt\nfrom PIL import Image\nimport numpy as np\n\n\ndf = pd.read_csv('/kaggle/input/ranzcr-clip-catheter-line-classification/train.csv', index_col=0)\ndf2 = pd.read_csv('/kaggle/input/ranzcr-clip-catheter-line-classification/train_annotations.csv', index_col=0)\nimages = os.listdir('/kaggle/input/ranzcr-clip-catheter-line-classification/train')\n\n# check that length of study uids in training dataframe matches length in image bucket\nassert len(set(images) - set([i+'.jpg' for i in df.index])) == 0","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"annotation = df2.iloc[1000]\nim = np.array(Image.open(f'/kaggle/input/ranzcr-clip-catheter-line-classification/train/{annotation.name}.jpg'))\nprint (annotation['label'])\nseg_im = np.zeros_like(im)\ndata = json.loads(annotation['data'])\nfor i, (x1,y1) in enumerate(data[:-1]):\n    x2,y2 = data[i+1]\n    rr, cc, val = line_aa(y1,x1,y2,x2)\n    seg_im[rr, cc] = val * 255\n\nplt.figure(figsize=(8,8))\nplt.imshow(im, cmap='gray')\nplt.imshow(seg_im, alpha=0.5)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"merged_df = pd.merge(df,df2, left_index=True, right_index=True)\ny = [len(f) for f in merged_df.data]\nx = merged_df.sum(axis=1)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"%matplotlib inline\nfrom matplotlib import pyplot as plt\nplt.scatter(x,y)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"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}