{"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":97984,"databundleVersionId":14096757,"sourceType":"competition"}],"dockerImageVersionId":31153,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# **ECG Data View**","metadata":{"execution":{"iopub.status.busy":"2025-10-24T07:57:44.77938Z","iopub.execute_input":"2025-10-24T07:57:44.780774Z","iopub.status.idle":"2025-10-24T07:58:28.039094Z","shell.execute_reply.started":"2025-10-24T07:57:44.780736Z","shell.execute_reply":"2025-10-24T07:58:28.038265Z"}}},{"cell_type":"code","source":"import os, glob, cv2, math, warnings\nwarnings.filterwarnings(\"ignore\")\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport gc\nfrom PIL import Image \nfrom IPython.display import display\n\nTRAIN_DIR    = '/kaggle/input/physionet-ecg-image-digitization/train'\nTRAIN_CSV    = '/kaggle/input/physionet-ecg-image-digitization/train.csv'","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-27T10:24:57.932432Z","iopub.execute_input":"2025-10-27T10:24:57.933469Z","iopub.status.idle":"2025-10-27T10:24:57.938678Z","shell.execute_reply.started":"2025-10-27T10:24:57.933436Z","shell.execute_reply":"2025-10-27T10:24:57.937696Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train=pd.read_csv(TRAIN_CSV)\ndisplay(train)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-27T10:24:57.940714Z","iopub.execute_input":"2025-10-27T10:24:57.941187Z","iopub.status.idle":"2025-10-27T10:24:57.973335Z","shell.execute_reply.started":"2025-10-27T10:24:57.941157Z","shell.execute_reply":"2025-10-27T10:24:57.972357Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"paths=[]\nfor dirname, _, filenames in os.walk(f'{TRAIN_DIR}/7663343/'):\n    for filename in filenames:\n        paths+=[(os.path.join(dirname, filename))]\nprint(paths)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-27T10:24:57.974292Z","iopub.execute_input":"2025-10-27T10:24:57.974518Z","iopub.status.idle":"2025-10-27T10:24:57.982494Z","shell.execute_reply.started":"2025-10-27T10:24:57.974500Z","shell.execute_reply":"2025-10-27T10:24:57.981144Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df=pd.read_csv(f'{TRAIN_DIR}/7663343/7663343.csv')\ndisplay(df)\ndisplay(df.info())\ncols=df.columns.tolist()\n\ngc.collect()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-27T10:24:57.983622Z","iopub.execute_input":"2025-10-27T10:24:57.984013Z","iopub.status.idle":"2025-10-27T10:24:58.030031Z","shell.execute_reply.started":"2025-10-27T10:24:57.983982Z","shell.execute_reply":"2025-10-27T10:24:58.029121Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for col in cols:\n    plt.plot(df.index, df[col], marker='o')\n    plt.xlabel(\"Index\")\n    plt.ylabel(col)\n    plt.title(f\"{col}\")\n    plt.grid(True)\n    plt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-27T10:24:58.032410Z","iopub.execute_input":"2025-10-27T10:24:58.032934Z","iopub.status.idle":"2025-10-27T10:25:00.264256Z","shell.execute_reply.started":"2025-10-27T10:24:58.032901Z","shell.execute_reply":"2025-10-27T10:25:00.263066Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for path in paths:\n    if path.endswith('.png'):\n        print(path.split('/')[-1])\n        img = Image.open(path)\n        w, h = img.size\n        img_resized = img.resize((w // 2, h // 2))\n        display(img_resized)\n        print()\n\ngc.collect()","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df2=pd.read_csv('/kaggle/input/physionet-ecg-image-digitization/test.csv')\ndisplay(df2)\ndisplay(df2.info())\nprint(sum(df2['number_of_rows']))#=number_rows of submission file\n\ngc.collect()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-27T10:31:49.597856Z","iopub.execute_input":"2025-10-27T10:31:49.598214Z","iopub.status.idle":"2025-10-27T10:31:49.622165Z","shell.execute_reply.started":"2025-10-27T10:31:49.598191Z","shell.execute_reply":"2025-10-27T10:31:49.621259Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submit=pd.read_parquet('/kaggle/input/physionet-ecg-image-digitization/sample_submission.parquet')\ndisplay(submit)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-27T10:27:46.053106Z","iopub.execute_input":"2025-10-27T10:27:46.053418Z","iopub.status.idle":"2025-10-27T10:27:46.319213Z","shell.execute_reply.started":"2025-10-27T10:27:46.053396Z","shell.execute_reply":"2025-10-27T10:27:46.318135Z"}},"outputs":[],"execution_count":null}]}