{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[],"dockerImageVersionId":28755,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nallfiles =[]\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        allfiles.append(os.path.join(dirname, filename))\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session\n\n# Use the kagglehub client library to attach Kaggle resources like competitions, datasets, and models to your session\n# Learn more about kagglehub: https://github.com/Kaggle/kagglehub/blob/main/README.md\n\nimport kagglehub\n# kagglehub.dataset_download('<owner>/<dataset-slug>')","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2026-07-21T16:43:56.928631Z","iopub.execute_input":"2026-07-21T16:43:56.929144Z","iopub.status.idle":"2026-07-21T16:43:56.941083Z","shell.execute_reply.started":"2026-07-21T16:43:56.929113Z","shell.execute_reply":"2026-07-21T16:43:56.940142Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"type(allfiles[0])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-21T16:43:56.942796Z","iopub.execute_input":"2026-07-21T16:43:56.943123Z","iopub.status.idle":"2026-07-21T16:43:56.953336Z","shell.execute_reply.started":"2026-07-21T16:43:56.943095Z","shell.execute_reply":"2026-07-21T16:43:56.952692Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"record_npyfiles = [file for file in allfiles if (\"record_\" in file) and ('npy' in file)]\nrecord_npyfiles","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-21T16:43:56.954295Z","iopub.execute_input":"2026-07-21T16:43:56.954633Z","iopub.status.idle":"2026-07-21T16:43:56.967274Z","shell.execute_reply.started":"2026-07-21T16:43:56.954597Z","shell.execute_reply":"2026-07-21T16:43:56.966662Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"filename = record_npyfiles[0]\nrec = np.load(filename)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-21T16:43:56.969022Z","iopub.execute_input":"2026-07-21T16:43:56.969318Z","iopub.status.idle":"2026-07-21T16:43:57.096042Z","shell.execute_reply.started":"2026-07-21T16:43:56.969294Z","shell.execute_reply":"2026-07-21T16:43:57.095126Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(type(rec))\nprint(rec.shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-21T16:43:57.097094Z","iopub.execute_input":"2026-07-21T16:43:57.097387Z","iopub.status.idle":"2026-07-21T16:43:57.102024Z","shell.execute_reply.started":"2026-07-21T16:43:57.097338Z","shell.execute_reply":"2026-07-21T16:43:57.101147Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print('1st 10 records and 9 samples for each record (1st col is record number)')\nprint(rec[:10,:10])\ndf_rec = pd.DataFrame(rec)\ndf_rec.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-21T16:43:57.103084Z","iopub.execute_input":"2026-07-21T16:43:57.103443Z","iopub.status.idle":"2026-07-21T16:43:57.132932Z","shell.execute_reply.started":"2026-07-21T16:43:57.103397Z","shell.execute_reply":"2026-07-21T16:43:57.132198Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nplt.plot(rec[0,:7500])\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-21T16:43:57.134014Z","iopub.execute_input":"2026-07-21T16:43:57.134334Z","iopub.status.idle":"2026-07-21T16:43:57.349193Z","shell.execute_reply.started":"2026-07-21T16:43:57.134307Z","shell.execute_reply":"2026-07-21T16:43:57.348512Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# ask AI (i.e. Gemini) to write code for ploting all signals by normalizing them using Z-score normalization\n# prompt:\n# data stored in \"rec\" as Column 1:7501: First EEG (Frontal-occipital) channel sampled at 250Hz\n# Column 7501:15001: Second EEG (Frontal-occipital) channel sampled at 250Hz\n# Column 15001:22501: Third EEG (Frontal-frontal) channel sampled at 250Hz\n# Column 22501:30001: Fourth EEG (Frontal-occipital) channel sampled at 250Hz\n# Column 30001:37501: Fifth EEG (Frontal-occipital) channel sampled at 250Hz\n# Column 37501:39001: X-axis accelerometer channel sampled at 50Hz\n# Column 39001:40501: Y-axis accelerometer channel sampled at 50Hz\n# Column 40501:42001: Z-axis accelerometer channel sampled at 50Hz. gen code to plot them in the same figure normalize them\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-21T16:43:57.350287Z","iopub.execute_input":"2026-07-21T16:43:57.350664Z","iopub.status.idle":"2026-07-21T16:43:57.354526Z","shell.execute_reply.started":"2026-07-21T16:43:57.350636Z","shell.execute_reply":"2026-07-21T16:43:57.353654Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Ask AI to Gen code to show frequency domain\n# Prompt:\n# Gen code for computing frequency domain of these signals and plot them\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Ask AI to gen code for short time Fourier transform to inspect freq components vs time.\n# Prompt:\n# For these 30 second signals, gen code for stft for inspecting frequency components in each second. plot them","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}