{"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":"%matplotlib inline\n\nimport os, cv2\nimport glob\n\nfrom pathlib import Path\n\nimport pandas as pd\nimport numpy as np\n\nfrom matplotlib import pyplot as plt","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-01-14T04:23:16.111952Z","iopub.execute_input":"2023-01-14T04:23:16.112476Z","iopub.status.idle":"2023-01-14T04:23:16.393024Z","shell.execute_reply.started":"2023-01-14T04:23:16.112363Z","shell.execute_reply":"2023-01-14T04:23:16.392004Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_csv = pd.read_csv('../input/rsna-breast-cancer-detection/train.csv')\ntrain_csv.head()","metadata":{"execution":{"iopub.status.busy":"2023-01-14T04:23:16.395162Z","iopub.execute_input":"2023-01-14T04:23:16.395801Z","iopub.status.idle":"2023-01-14T04:23:16.571769Z","shell.execute_reply.started":"2023-01-14T04:23:16.395758Z","shell.execute_reply":"2023-01-14T04:23:16.570403Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_csv = pd.read_csv('../input/rsna-breast-cancer-detection/test.csv')\ntest_csv","metadata":{"execution":{"iopub.status.busy":"2023-01-14T04:23:16.572967Z","iopub.execute_input":"2023-01-14T04:23:16.573451Z","iopub.status.idle":"2023-01-14T04:23:16.597365Z","shell.execute_reply.started":"2023-01-14T04:23:16.573412Z","shell.execute_reply":"2023-01-14T04:23:16.596345Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **What does cancer look like?**","metadata":{}},{"cell_type":"code","source":"def display_image(file_path):\n    f, axarr = plt.subplots(2,2, figsize=(8,8))\n    f.suptitle(file_path.split('/')[-1])\n    \n    img = []\n\n    for img_path in os.listdir(file_path):\n        img.append(cv2.imread(file_path + '/' + img_path, cv2.IMREAD_COLOR))\n    \n    axarr[0,0].imshow(img[0])\n    axarr[0,1].imshow(img[1])\n    axarr[1,0].imshow(img[2])\n    axarr[1,1].imshow(img[3])","metadata":{"execution":{"iopub.status.busy":"2023-01-14T04:23:16.599893Z","iopub.execute_input":"2023-01-14T04:23:16.60022Z","iopub.status.idle":"2023-01-14T04:23:16.607985Z","shell.execute_reply.started":"2023-01-14T04:23:16.600191Z","shell.execute_reply":"2023-01-14T04:23:16.606614Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"patients_without_cancer = np.unique(train_csv[(train_csv['cancer']==0)]['patient_id'])\npatients_with_cancer = np.unique(train_csv[(train_csv['cancer']==1)]['patient_id'])","metadata":{"execution":{"iopub.status.busy":"2023-01-14T04:23:16.609679Z","iopub.execute_input":"2023-01-14T04:23:16.609992Z","iopub.status.idle":"2023-01-14T04:23:16.636327Z","shell.execute_reply.started":"2023-01-14T04:23:16.609965Z","shell.execute_reply":"2023-01-14T04:23:16.635186Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def display_patients(patients, number_patients_to_display=10, resolution=1024):\n    np.random.seed(7)\n    for patient_id in np.random.choice(patients, size=number_patients_to_display):\n        file_path = f'../input/rsna-mammography-images-as-pngs/images_as_pngs_{resolution}/train_images_processed_{resolution}/{patient_id}'\n        display_image(file_path)","metadata":{"execution":{"iopub.status.busy":"2023-01-14T04:23:16.637792Z","iopub.execute_input":"2023-01-14T04:23:16.638264Z","iopub.status.idle":"2023-01-14T04:23:16.644759Z","shell.execute_reply.started":"2023-01-14T04:23:16.638221Z","shell.execute_reply":"2023-01-14T04:23:16.64361Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display_patients(patients_with_cancer)","metadata":{"execution":{"iopub.status.busy":"2023-01-14T04:23:16.646346Z","iopub.execute_input":"2023-01-14T04:23:16.64737Z","iopub.status.idle":"2023-01-14T04:23:31.924419Z","shell.execute_reply.started":"2023-01-14T04:23:16.647333Z","shell.execute_reply":"2023-01-14T04:23:31.92312Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display_patients(patients_without_cancer)","metadata":{"execution":{"iopub.status.busy":"2023-01-14T04:23:31.925738Z","iopub.execute_input":"2023-01-14T04:23:31.92605Z","iopub.status.idle":"2023-01-14T04:23:46.475582Z","shell.execute_reply.started":"2023-01-14T04:23:31.92602Z","shell.execute_reply":"2023-01-14T04:23:46.474349Z"},"trusted":true},"execution_count":null,"outputs":[]}]}