101 lines
3.2 KiB
Plaintext
101 lines
3.2 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 40,
|
|
"id": "b7a45b11",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"The autoreload extension is already loaded. To reload it, use:\n",
|
|
" %reload_ext autoreload\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"%load_ext autoreload\n",
|
|
"%autoreload 2"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 41,
|
|
"id": "d5051d3d",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from compute_vector_feature import *\n",
|
|
"import numpy as np\n",
|
|
"import pandas as pd"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 43,
|
|
"id": "56752746",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"(75768, 5)\n",
|
|
"131072\n"
|
|
]
|
|
},
|
|
{
|
|
"ename": "TypeError",
|
|
"evalue": "slice indices must be integers or None or have an __index__ method",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
|
|
"\u001b[31mTypeError\u001b[39m Traceback (most recent call last)",
|
|
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[43]\u001b[39m\u001b[32m, line 12\u001b[39m\n\u001b[32m 9\u001b[39m eegdata = df.to_numpy()\n\u001b[32m 10\u001b[39m \u001b[38;5;28mprint\u001b[39m(eegdata.shape)\n\u001b[32m---> \u001b[39m\u001b[32m12\u001b[39m ret = \u001b[43mcompute_feature_vector\u001b[49m\u001b[43m(\u001b[49m\u001b[43meegdata\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mFs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 13\u001b[39m ret\n",
|
|
"\u001b[36mFile \u001b[39m\u001b[32m~/workspaces/git.anishalle.me/musi/compute_vector_feature.py:20\u001b[39m, in \u001b[36mcompute_feature_vector\u001b[39m\u001b[34m(eegdata, Fs)\u001b[39m\n\u001b[32m 17\u001b[39m # 1. Compute the PSD\n\u001b[32m 18\u001b[39m winSampleLength, nbCh = eegdata.shape\n\u001b[32m---> \u001b[39m\u001b[32m20\u001b[39m # Apply Hamming window\n\u001b[32m 21\u001b[39m w = np.hamming(winSampleLength)\n\u001b[32m 22\u001b[39m dataWinCentered = eegdata - np.mean(eegdata, axis=0) # Remove offset\n",
|
|
"\u001b[31mTypeError\u001b[39m: slice indices must be integers or None or have an __index__ method"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# sampling rate\n",
|
|
"Fs = 256\n",
|
|
"temp_file = \"data/hasini/brain_1761337390.csv\"\n",
|
|
"\n",
|
|
"df = pd.read_csv(temp_file)\n",
|
|
"\n",
|
|
"df.drop(columns = 'timestamps',inplace=True)\n",
|
|
"\n",
|
|
"eegdata = df.to_numpy()\n",
|
|
"print(eegdata.shape)\n",
|
|
"\n",
|
|
"ret = compute_feature_vector(eegdata, Fs)\n",
|
|
"ret\n"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": ".venv",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.12.11"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|