{"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":"import cv2\nimport PIL\nimport matplotlib.pylab as plt\nimport glob","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-07-28T18:54:44.662378Z","iopub.execute_input":"2022-07-28T18:54:44.663449Z","iopub.status.idle":"2022-07-28T18:54:44.722863Z","shell.execute_reply.started":"2022-07-28T18:54:44.66336Z","shell.execute_reply":"2022-07-28T18:54:44.721728Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## **DICOM Data**","metadata":{}},{"cell_type":"code","source":"import pydicom as dicom\n\nimage_file = glob.glob(\"../input/rsna-2022-cervical-spine-fracture-detection/train_images/1.2.826.0.1.3680043.10001/*.dcm\")\nplt.figure(figsize=(20, 20))\n\nfor i in range(28):\n    ax = plt.subplot(7, 7, i + 1)\n    # specify your dcm image path\n    image_path = image_file[i]\n    ds = dicom.dcmread(image_path)\n    plt.axis('off')\n    \n    plt.imshow(ds.pixel_array)","metadata":{"execution":{"iopub.status.busy":"2022-07-28T18:55:19.984903Z","iopub.execute_input":"2022-07-28T18:55:19.985511Z","iopub.status.idle":"2022-07-28T18:55:22.557235Z","shell.execute_reply.started":"2022-07-28T18:55:19.985469Z","shell.execute_reply":"2022-07-28T18:55:22.555434Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## **Segmentation Data**","metadata":{}},{"cell_type":"code","source":"import nibabel as nib\n\nimage_file = glob.glob(\"../input/rsna-2022-cervical-spine-fracture-detection/segmentations/*.nii\")\nplt.figure(figsize=(20, 20))\n\nfor i in range(28):\n    ax = plt.subplot(7, 7, i + 1)\n    # specify your nii image path\n    image_path = image_file[i]\n    nii_img = nib.load(image_path).get_fdata()\n    nib_image = nii_img[:,:,59]\n    plt.axis('off')\n    plt.imshow(nib_image)","metadata":{"execution":{"iopub.status.busy":"2022-07-28T18:54:49.008041Z","iopub.execute_input":"2022-07-28T18:54:49.008811Z","iopub.status.idle":"2022-07-28T18:55:00.523957Z","shell.execute_reply.started":"2022-07-28T18:54:49.00876Z","shell.execute_reply":"2022-07-28T18:55:00.522514Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### **Reference Links**\n* [Plot / Display NIDTI Medical Images](https://rylezhou.medium.com/how-to-plot-display-nifti-nii-medical-images-in-python-1368443fed77https://rylezhou.medium.com/how-to-plot-display-nifti-nii-medical-images-in-python-1368443fed77)\n* [Read DICOM Medical Image Using DICOM Python](https://stackoverflow.com/questions/48185544/read-and-open-dicom-images-using-python)","metadata":{}}]}