{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":13451,"databundleVersionId":1188070,"sourceType":"competition"},{"sourceId":13309422,"sourceType":"datasetVersion","datasetId":8436674}],"dockerImageVersionId":31153,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import os, json, shutil\n\njsonl_path = \"/kaggle/input/jsonlsdf/annotion_file_info.jsonl\"\nsrc_dir = \"/kaggle/input/rsna-intracranial-hemorrhage-detection/rsna-intracranial-hemorrhage-detection/stage_2_test\"\ndst_dir = \"/kaggle/working/selected_dcm\"\n\nos.makedirs(dst_dir, exist_ok=True)\n\ndicom_ids = set()\n\nwith open(jsonl_path, \"r\") as f:\n    for line in f:\n        d = json.loads(line)\n        for s in d[\"slice_list\"]:\n            dicom_ids.add(f\"ID_{s}.dcm\")\n\nfor dcm in dicom_ids:\n    src = os.path.join(src_dir, dcm)\n    if os.path.exists(src):\n        shutil.copy(src, dst_dir)\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-10-09T10:58:03.685294Z","iopub.execute_input":"2025-10-09T10:58:03.68705Z","iopub.status.idle":"2025-10-09T10:58:13.540707Z","shell.execute_reply.started":"2025-10-09T10:58:03.687001Z","shell.execute_reply":"2025-10-09T10:58:13.539732Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os, json, shutil\nshutil.make_archive(\"/kaggle/working/selected_dcm\", \"zip\", dst_dir)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-09T11:01:42.785574Z","iopub.execute_input":"2025-10-09T11:01:42.786692Z","iopub.status.idle":"2025-10-09T11:07:02.826596Z","shell.execute_reply.started":"2025-10-09T11:01:42.786654Z","shell.execute_reply":"2025-10-09T11:07:02.825694Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from google.colab import drive\ndrive.mount('/content/drive')\n\n!cp /kaggle/working/selected_dcm.zip /content/drive/MyDrive/","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}