{"cells":[{"metadata":{"trusted":true},"cell_type":"code","source":"import os\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport pydicom\n\nimport warnings\nwarnings.filterwarnings('ignore')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"> ## 1. Dicom to Numpy Array:"},{"metadata":{"trusted":true},"cell_type":"code","source":"def dcm_to_arr(root_dir, no_of_imgs=10):\n    dcm_files = []\n    dcm_to_arr = []\n    for dirs, sub_dirs, files in os.walk(root_dir):\n        for file in files:\n            if '.dicom' in file.lower():\n                dcm_files.append(os.path.join(dirs,file))\n\n    for dcm_file in dcm_files[:no_of_imgs]:\n        # Get ref file\n        dcm_to_arr.append(pydicom.read_file(dcm_file).pixel_array)\n    return dcm_files, dcm_to_arr","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"dcm_files, images = dcm_to_arr(root_dir='/kaggle/input')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"len(dcm_files), len(images)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.figure(figsize = (5,5))\nplt.imshow(images[8], cmap=plt.cm.bone)","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}