{"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":"markdown","source":"## Dataset information\n\nIn this competition, we are **identifying and localizing** COVID-19 abnormalities on chest radiographs. \nThis is an object detection and classification problem. For each test image, you will be predicting \na bounding box and class for all findings. The train dataset comprises 6,334 chest scans. \nAll images were labeled by a panel of experienced radiologists for the presence of opacities as well as overall appearance.\n\nNote that all images are stored in paths with the form **study/series/image**. \nThe study ID here relates directly to the study-level predictions, and the image ID is the ID used for image-level predictions.\n\nThe hidden test dataset is of roughly the same scale as the training dataset.\nFor each test study, you should make a determination within the following labels:\n\n* Negative for Pneumonia \n* Typical Appearance' \n* Indeterminate Appearance \n* Atypical Appearance\n\nPrediction examples: \n\n* \"none 1 0 0 1 1\" - prediction for no findings (\"none\" is the class ID for no finding, and this provides a one-pixel bounding box with a confidence of 1.0)\n* \"atypical 1 0 0 1 1\" - prediction for Atypical Appearance\n\n**Note:** The images are in [DICOM](https://en.wikipedia.org/wiki/DICOM) format, which means they contain additional data that might be useful for visualizing and classifying.","metadata":{}},{"cell_type":"code","source":"# installing additional libs\n! pip install pandas-profiling[notebook]","metadata":{"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nimport pydicom\nimport matplotlib.pyplot as plt\nfrom pathlib import Path\nfrom pandas_profiling import ProfileReport\n\n%matplotlib inline\n\nroot = Path(\"../input/siim-covid19-detection\")","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## train_image_level.csv \n\nthe train image-level metadata, with one row for each image, including both correct labels and any bounding boxes in a dictionary format. Some images in both test and train have multiple bounding boxes.\n\nColumns:\n\n* **id** - unique image identifier\n* **boxes** - bounding boxes in easily-readable dictionary format\n* **label** - the correct prediction label for the provided bounding boxes","metadata":{}},{"cell_type":"code","source":"train_image_level = pd.read_csv(root / \"train_image_level.csv\")\ntrain_image_level_profile = ProfileReport(train_image_level, title=\"train_image_level_report\")\ntrain_image_level_profile","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## train_study_level.csv\n\nthe train study-level metadata, with one row for each study, including correct labels.\n\nColumns:\n\n* **id** - unique study identifier\n* **Negative for Pneumonia** - 1 if the study is negative for pneumonia, 0 otherwise\n* **Typical Appearance** - 1 if the study has this appearance, 0 otherwise\n* **Indeterminate Appearance**  - 1 if the study has this appearance, 0 otherwise\n* **Atypical Appearance**  - 1 if the study has this appearance, 0 otherwise","metadata":{}},{"cell_type":"code","source":"train_study_level = pd.read_csv(root / \"train_study_level.csv\")\ntrain_study_level_profile = ProfileReport(train_study_level, title=\"train_study_level_report\")\ntrain_study_level_profile","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## dicom metadata","metadata":{}},{"cell_type":"code","source":"_id, boxes, label, study = train_image_level.iloc[0]\nstudy_images_filenames = list((root / \"train\" / study).rglob(\"*.dcm\"))\ndicom = pydicom.read_file(study_images_filenames[0])\ndicom","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_np = dicom.pixel_array\nimage_norm = (image_np - image_np.min()) / image_np.max()\nimage_norm = (image_norm * 255).astype(np.uint8)\n\nplt.imshow(image_norm, cmap=\"gray\")\nplt.axis(\"off\")\nplt.show()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}