153 linhas
3.3 KiB
Plaintext
153 linhas
3.3 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 43,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"from scipy import signal, stats\n",
|
|
"import numpy as np\n",
|
|
"import pandas as pd\n",
|
|
"from time import time, strftime, gmtime\n",
|
|
"from pylsl import StreamInlet, resolve_byprop\n",
|
|
"from matplotlib.pyplot import *\n",
|
|
"\n",
|
|
"from collect_tools import collect_eeg\n",
|
|
"\n",
|
|
"%matplotlib inline"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 44,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"looking for an EEG stream...\n",
|
|
"Found stream!\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(\"looking for an EEG stream...\")\n",
|
|
"streams = resolve_byprop('type', 'EEG', timeout=2)\n",
|
|
"\n",
|
|
"if len(streams) == 0:\n",
|
|
" print('No streams found! Are you streaming data?')\n",
|
|
"else:\n",
|
|
" print('Found stream!')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 45,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"inlet = StreamInlet(streams[0], max_chunklen=24)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 46,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"baseline: just stay still and don't smell too much\n",
|
|
"\n",
|
|
"Start recording at time t=1491953530.525\n",
|
|
"Finished recording at time 1491953540.611 (10.086 seconds)\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(\"baseline: just stay still and don't smell too much\\n\")\n",
|
|
"baseline = collect_eeg(inlet,duration=10, tag='baseline')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 47,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"smell: try to smell the object as much as possible\n",
|
|
"\n",
|
|
"Start recording at time t=1491953540.627\n",
|
|
"Finished recording at time 1491953550.697 (10.069 seconds)\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(\"smell: try to smell the object as much as possible\\n\")\n",
|
|
"smell = collect_eeg(inlet,duration=10, tag='smell')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 48,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"data saved in:\n",
|
|
"data/smell_1491953550.csv\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"data = pd.concat([baseline, smell])\n",
|
|
"last = np.array(data.timestamps)[-1]\n",
|
|
"last = int(float(last))\n",
|
|
"fname = 'data/smell_{}.csv'.format(last)\n",
|
|
"data.to_csv(fname, index=False)\n",
|
|
"print('data saved in:\\n{}'.format(fname))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"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.6.0"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 1
|
|
}
|