{"cells":[{"metadata":{},"cell_type":"markdown","source":"# Extreme Exploratory Data Analysis"},{"metadata":{},"cell_type":"markdown","source":"![](https://raw.githubusercontent.com/elbanan/RSNA2020/master/eda_1.png)"},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"_kg_hide-output":true,"collapsed":true},"cell_type":"code","source":"!pip3 install git+https://download.radtorch.com/ -q","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true,"_kg_hide-output":true},"cell_type":"code","source":"from radtorch import pipeline, core\nfrom radtorch.settings import *","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"data_dir = '/kaggle/input/rsna-str-pulmonary-embolism-detection/train/'\ndata_csv = '/kaggle/input/rsna-str-pulmonary-embolism-detection/train.csv'","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df = pd.read_csv(data_csv)\ndf.head()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"print ('EXTREME EXPLORATORY DATA ANALYSIS')\nprint('===================================')\nprint ('Number of Studies =', len(df.StudyInstanceUID.unique()))\nprint ('Number of Series =', len(df.SeriesInstanceUID.unique()))\nprint ('Number of Images =', len(df.SOPInstanceUID.unique()))\nprint ('Number of Studies with Positive PE =', len((df[df['negative_exam_for_pe']==0]).SeriesInstanceUID.unique()))  \nprint ('Number of Studies with Negative PE =', len((df[df['negative_exam_for_pe']==1]).SeriesInstanceUID.unique()))  \nprint ('Number of Images with positive PE within Positive Studies =', len(df.loc[(df['pe_present_on_image'] == 1) & (df['negative_exam_for_pe'] == 0)]))\nprint ('Number of Images with negative PE within Positive Studies =', len(df.loc[(df['pe_present_on_image'] == 0) & (df['negative_exam_for_pe'] == 0)]))\nprint ('Number of Images with positive PE within Negative Studies =', len(df.loc[(df['pe_present_on_image'] == 1) & (df['negative_exam_for_pe'] == 1)]))\nprint ('Number of Images with negative PE within Negative Studies =', len(df.loc[(df['pe_present_on_image'] == 0) & (df['negative_exam_for_pe'] == 1)]))\nprint ('')\nprint ('Number of Images with Right sided PE ONLY =', len(df.loc[(df['pe_present_on_image'] == 1) & (df['negative_exam_for_pe'] == 0)& (df['rightsided_pe'] == 1)& (df['leftsided_pe'] ==0)& (df['central_pe'] == 0)]))\nprint ('Number of Images with Left sided PE ONLY =', len(df.loc[(df['pe_present_on_image'] == 1) & (df['negative_exam_for_pe'] == 0)& (df['leftsided_pe'] == 1)& (df['rightsided_pe'] == 0)&(df['central_pe'] == 0)]))\nprint ('Number of Images with Central PE ONLY =', len(df.loc[(df['pe_present_on_image'] == 1) & (df['negative_exam_for_pe'] == 0)& (df['central_pe'] == 1)&(df['rightsided_pe'] == 0)& (df['leftsided_pe'] == 0)]))\nprint ('')\nprint ('Number of Images with Right & Left PE =', len(df.loc[(df['pe_present_on_image'] == 1) & (df['negative_exam_for_pe'] == 0)& (df['rightsided_pe'] == 1)& (df['leftsided_pe'] == 1)]))\nprint ('Number of Images with Right & Central PE =', len(df.loc[(df['pe_present_on_image'] == 1) & (df['negative_exam_for_pe'] == 0)& (df['rightsided_pe'] == 1)& (df['central_pe'] == 1)]))\nprint ('Number of Images with Left & Central PE =', len(df.loc[(df['pe_present_on_image'] == 1) & (df['negative_exam_for_pe'] == 0)& (df['leftsided_pe'] == 1)& (df['central_pe'] == 1)]))\nprint ('Number of Images with Right/Left/Central PE =', len(df.loc[(df['pe_present_on_image'] == 1) & (df['negative_exam_for_pe'] == 0)& (df['rightsided_pe'] == 1)& (df['leftsided_pe'] == 1)& (df['central_pe'] == 1)]))\nprint ('')\nprint ('Number of Studies which are indeterminate for PE =', len(df[df['indeterminate']==1]))\nprint ('Number of Studies which are indeterminate b/c contrast issues ONLY =', len(df.loc[(df['indeterminate'] == 1) & (df['qa_contrast'] == 1)& (df['qa_motion'] == 0)]))\nprint ('Number of Studies which are indeterminate b/c motion issues ONLY =', len(df.loc[(df['indeterminate'] == 1) & (df['qa_motion'] == 1)& (df['qa_contrast'] == 0)]))\nprint ('Number of Studies which are indeterminate b/c contrast and motion issues =', len(df.loc[(df['indeterminate'] == 1) & (df['qa_motion'] == 1)& (df['qa_contrast'] == 1)]))\nprint ('')\nchronic = len(df.loc[(df['pe_present_on_image'] == 1) & (df['chronic_pe'] == 1)])\nacute_chronic = len(df.loc[(df['pe_present_on_image'] == 1) & (df['acute_and_chronic_pe'] == 1)])\nacute = len(df.loc[(df['pe_present_on_image'] == 1) & (df['negative_exam_for_pe'] == 0)])-(chronic+acute_chronic)\nprint ('Number of Images with positive PE and Acute =', acute)\nprint ('Number of Images with positive PE and Chronic =', chronic)\nprint ('Number of Images with positive PE and Acute/Chronic =', acute_chronic)\nprint ('')\nprint ('Number of Images with positive PE with flow artifact =', len(df.loc[(df['pe_present_on_image'] == 1) & (df['flow_artifact'] == 1)]))\nprint ('Number of Images with positive PE without flow artifact =', len(df.loc[(df['pe_present_on_image'] == 1) & (df['flow_artifact'] == 0)]))\nprint ('Number of Images with negative PE with flow artifact =', len(df.loc[(df['pe_present_on_image'] == 0) & (df['flow_artifact'] == 1)]))\nprint ('Number of Images with negative PE without flow artifact =', len(df.loc[(df['pe_present_on_image'] == 0) & (df['flow_artifact'] == 0)]))\nprint ('')\nprint ('Number of Images with positive PE with true_filling_defect_not_pe =', len(df.loc[(df['pe_present_on_image'] == 1) & (df['true_filling_defect_not_pe'] == 1)]))\nprint ('Number of Images with positive PE without true_filling_defect_not_pe =', len(df.loc[(df['pe_present_on_image'] == 1) & (df['true_filling_defect_not_pe'] == 0)]))\nprint ('Number of Images with negative PE with true_filling_defect_not_pe =', len(df.loc[(df['pe_present_on_image'] == 0) & (df['true_filling_defect_not_pe'] == 1)&(df['indeterminate'] == 0)]))\nprint ('Number of Images with negative PE without true_filling_defect_not_pe =', len(df.loc[(df['pe_present_on_image'] == 0) & (df['true_filling_defect_not_pe'] == 0)&(df['indeterminate'] == 0)]))\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### I will be updating the post regularly. Keep Checking :) "},{"metadata":{},"cell_type":"markdown","source":"![](http://)"}],"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}