{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":36363,"databundleVersionId":4050810,"sourceType":"competition"}],"dockerImageVersionId":30761,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pydicom","metadata":{"execution":{"iopub.status.busy":"2024-09-12T03:43:20.928341Z","iopub.execute_input":"2024-09-12T03:43:20.928774Z","iopub.status.idle":"2024-09-12T03:43:21.167699Z","shell.execute_reply.started":"2024-09-12T03:43:20.928733Z","shell.execute_reply":"2024-09-12T03:43:21.166486Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# load & check dicom tags\ndata = pydicom.dcmread(\"/kaggle/input/rsna-2022-cervical-spine-fracture-detection/test_images/1.2.826.0.1.3680043.22327/1.dcm\")\nprint(data)","metadata":{"execution":{"iopub.status.busy":"2024-09-12T03:43:48.993733Z","iopub.execute_input":"2024-09-12T03:43:48.994129Z","iopub.status.idle":"2024-09-12T03:43:49.036605Z","shell.execute_reply.started":"2024-09-12T03:43:48.994089Z","shell.execute_reply":"2024-09-12T03:43:49.035348Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Define tags to be deleted (in hexadecimal)\ndelete_tags = [\n    (0x0008, 0x0018),  # SOP Instance UID\n    (0x0008, 0x0023),  # Content Date\n    (0x0008, 0x0033),  # Content Time\n    (0x0010, 0x0010),  # Patient's Name\n    (0x0010, 0x0020)   # Patient ID\n]\n\n# Delte tags\nfor delete_tag in delete_tags:\n    del data[delete_tag]\n    \n# Check the result\nprint(data)\ndata.save_as(\"tags_deleted.dcm\")","metadata":{"execution":{"iopub.status.busy":"2024-09-12T03:48:04.259833Z","iopub.execute_input":"2024-09-12T03:48:04.260259Z","iopub.status.idle":"2024-09-12T03:48:04.267216Z","shell.execute_reply.started":"2024-09-12T03:48:04.260218Z","shell.execute_reply":"2024-09-12T03:48:04.266132Z"},"trusted":true},"execution_count":null,"outputs":[]}]}