You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
BrainData/预处理.ipynb

97 lines
2.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{
"cells": [
{
"cell_type": "code",
"execution_count": 12,
"id": "initial_id",
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2024-02-29T01:56:53.616177200Z",
"start_time": "2024-02-29T01:56:53.225604200Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Creating RawArray with float64 data, n_channels=30, n_times=440\n",
" Range : 0 ... 439 = 0.000 ... 0.399 secs\n",
"Ready.\n",
"Opening raw-browser...\n"
]
}
],
"source": [
"import numpy as np\n",
"import mne\n",
"import matplotlib.pyplot as plt\n",
"data = np.load(\"ABMD_results3.npy\", allow_pickle=True).item()\n",
"# 获取data字典中的eeg键的第一个元素\n",
"sample = data['data'][0]\n",
"# 创建一个列表其中包含30个eeg1到eeg30的名称\n",
"channels = [f\"eeg{i}\" for i in range(1, 31)]\n",
"# 创建一个列表其中包含30个eeg类型的元素\n",
"channel_types = [\"eeg\"] * 30\n",
"# 使用mne模块创建一个info对象其中包含上面创建的channels和channel_types列表\n",
"info = mne.create_info(ch_names=channels,\n",
" sfreq=1100,\n",
" ch_types=channel_types)\n",
"# 使用mne模块创建一个RawArray对象其中包含sample和info对象\n",
"raw = mne.io.RawArray(sample, info)\n",
"fig = raw.plot(start=0, duration=10, color='b', scalings='auto')\n",
"# plt.show()\n",
"# plt.savefig(\"ABMD_results3.png\")\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-29T01:48:22.905570700Z",
"start_time": "2024-02-29T01:48:22.873578500Z"
}
},
"id": "4805d7e6a7da9fea"
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
},
"id": "242d359be6dc5d61"
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}