{"cells":[{"metadata":{},"cell_type":"markdown","source":"This notebook loads GDCM without Internet access.\n\nGDCM is needed to read some DICOM compressed images.\n\nOnce you run a notebook and get the GDCM error, you must restart that Kernel to read the files, even if you load the GDCM software.\n\nNote that you do not \"import GDCM\". You just \"import pydicom\".\n\nThe Dataset (gdcm-conda-install) was provided by Ronaldo S.A. Batista. Definitely deserves an upvote!"},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import numpy as np, pandas as pd, os\nimport matplotlib.pyplot as plt","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"!cp ../input/gdcm-conda-install/gdcm.tar .\n!tar -xvzf gdcm.tar\n!conda install --offline ./gdcm/gdcm-2.8.9-py37h71b2a6d_0.tar.bz2\nprint(\"done\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"mypath = '../input/rsna-str-pulmonary-embolism-detection/train'\n\nimport pydicom\n\nbad_file = '0af5610bf683/6ee796097155/09c3501f2449.dcm'\ndataset = pydicom.read_file(mypath+'/'+ bad_file)\nimg = dataset.pixel_array\nplt.imshow(img,'gray')\nplt.show()\n\n#reads the entire directory tree if you want to do more testing (assumes a single SeriesInstanceUID)\n#\n#dirnames = os.listdir(mypath)\n#for dire in dirnames:\n#    seriesnames = os.listdir(mypath+'/'+dire)\n#    filenames = os.listdir(mypath+'/'+dire+'/'+seriesnames[0])\n#    for filename in filenames:\n#        dataset = pydicom.read_file(mypath+'/'+ dire +'/'+seriesnames[0] + '/' +filename)\n#        print(dire, filename)\n#        img = dataset.pixel_array\n\n","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}