victory的博客

长安一片月,万户捣衣声

0%

Framework of Paper

How to write a paper?
In fact,we need to write as follows:
Problem X is important
Previous works A, B, and C have been done
A, B, and C have their weakness
Your work D
Theoretical analysis
Experimental comparison against A, B, and C
Why D is better
Strength and weakness of D
Future work on D
So there is a framework of paper as folllows!
阅读全文 »

Comparison of Methods of Artifacts Removal

Regression Methods

Regression methods often assume that the scal potential is a linear combination of brain and other potentials(EOG、ECG、EMG).By subtracting propagated EOG/ECG/EMG from EEG recordings,EEG signals can be recovered.

Regression can also be done in frequency domain based on the concept that subtraction in the frequency domain is equivalent to filtering in the time domain.By eliminating spectral estimates of EOG/EMG/ECG from EEG recordings,it is possible to recover the non-contaminated EEG.

Disadvantages: Both types of regression methods are off-line and rely on EOG/ECG/EMG recordings,which are however,not always available.


阅读全文 »

ubuntu下虚拟环境的安装与配置

为什么要搭建虚拟环境?

如果在一台电脑上, 有不同项目, 需要用到同一个包的不同版本, 新版本会覆盖以前的版本, 其它的项目就可能无法正常运行了.。
解决方法:虚拟环境
    作用:虚拟环境可以搭建独立的python运行环境`, 使得单个项目的运行环境与其它项目互不影响。
    所有的虚拟环境都位于/home/用户名下的隐藏目录.virtualenvs下。

如何搭建虚拟环境?

安装虚拟环境的命令:
sudo pip install virtualenvo
sudo pip install virtualenvwrapper

安装完虚拟环境后,如果提示找不到mkvirtualenv命令,须配置环境变量:

# 1、创建目录用来存放虚拟环境
mkdir \$HOME/.virtualenvs
# 2、打开~/.bashrc文件,并添加如下:
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
# 3、运行
source ~/.bashrc

创建虚拟环境的命令 :
在python3中,创建虚拟环境

mkvirtualenv -p python3 虚拟环境名称
例 :
mkvirtualenv -p python3 django_py3

创建成功后会自动工作在这个虚拟环境上,工作在虚拟环境上, 提示符最前面会出现 “虚拟环境名称”。
如何使用虚拟环境?

查看虚拟环境的命令 :

workon 两次tab键 或者 回车

使用虚拟环境的命令:

workon 虚拟环境名称
例 :使用名为django_py3的虚拟环境
workon django_py3

退出虚拟环境的命令 :

deactivate

删除虚拟环境的命令 :

rmvirtualenv 虚拟环境名称
例 :删除虚拟环境django_py3
先退出:deactivate
再删除:rmvirtualenv django_py3

如何在虚拟环境中安装工具包

workon进入虚拟环境后,再使用pip进行包的安装,其安装方法和普通的安装方式一样。

安装指定Django版本示例:

pip install django==1.11.11

python3下的安装路径:

~/.virtualenvs/django_py3/lib/python3.5/site-packages/

Five Major Brain Waves

Five major brain waves can be distinguished by their frequency ranges:

|frequency band|frequency range|
|—–|—-|—-|
|delta|0.5-4Hz|appears for continuous-attention tasks|
|theta|4-8Hz|spikes when repressing(抑制) a response or action|
|alpha|8-13Hz|measures relax or closing eyes|
|beta|13-30Hz|reflects active thinking,focus,high alert or anxiety|
|gamma|30-50Hz|displays during cross-modal sensory processing|

绝对路径和相对路径

绝对路径:相对于磁盘的位置定位文件的地址
相对路径:相对于引用文件本身定位被引用文件的地址

Note:
./ 当前文件所在目录下
../ 当前文件所在目录的上一级目录

Python变量单前下划线与双前下划线的区别

_variable

表面上为私有,实际在外部可以访问

__variable

实际上的私有,只能在内部访问,不能在外部访问(报错)

_ variable _

魔法方法(magic method)/ 特殊方法

Example

class TestPrivacy(object):
    _name = 'hello' 
    __name = 'world'
    
print(TestPrivacy._name) # Output:'hello'
print(TestPrivacy.__name) # Output: AttributeError: type object 'TestPrivacy' has no attribute '__name'

脑电信号采用深度学习方法存在的问题

深度学习是一种构造多层神经网络的机器学习方法,具有发现数据中隐藏的分布式特征表示的能力。

脑电信号特征提取方法:

时域分析方法
频域分析方法
时频域分析犯法
非线性分析方法

脑电信号采用深度学习方法目前存在的问题

(1)深度神经网络层数的最优化,不是越多的网络层数就能得到最好的结果
(2)数据量也是造成深度学习方法无法深入的原因

Web服务器

Web服务器是可以向发出请求的浏览器提供文档的程序。

Code:

# coding:utf-8
import socket
import re

from multiprocessing import Process

# 设置静态文件根目录
HTML_ROOT_DIR = "./html"


def handle_client(client_socket):
    """处理客户端请求"""
    # 获取客户端请求数据
    request_data = client_socket.recv(1024)
    print("request data:",request_data)
    request_lines = request_data.splitlines()
    for line in request_lines:
        print(line)

    # 解析请求报文
    # 'GET / HTTP/1.1'
    request_start_line = request_lines[0]
    #提取用户请求的文件名
    file_name = re.match(r"\w+ +(/[^ ]*) ",request_start_line.decode("utf-8")).group(1)

    if "/" == file_name:
        file_name = "/index.html"
    # 打开文件,读取内容
    try:
        file = open(HTML_ROOT_DIR + file_name,"rb")
    except IOError:
        response_start_line = "HTTP/1.1 404 Not Found\r\n"
        response_headers = "Server: My server\r\n"
        response_body = "the file is not found"
    else:
        file_data = file.read()
        file.close()

        # 构造响应数据
        response_start_line = "HTTP/1.1 200 OK\r\n"
        response_headers = "Server: My server\r\n"
        response_body = file_data.decode("utf-8")

    response = response_start_line + response_headers + "\r\n" + response_body
    print("response:",response)

    # 向客户端返回响应数据
    client_socket.send(bytes(response,"utf-8"))

    #关闭客户端链接
    client_socket.close()

def main():
    server_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    server_socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
    #SOL_SOCKET:设置选项级别为SOCKET
    #SO_REUSEADDR:1
    server_socket.bind(("",7788))
    server_socket.listen(128)

    while True:
        client_socket,client_address= server_socket.accept()
        print("[%s,%s]用户连接上了"%(client_address))
        handle_client_process = Process(target=handle_client,args=(client_socket,))
        handle_client_process.start()
        client_socket.close()

if __name__ == "__main__":
    main()

访问Web服务器

在浏览器地址栏输入 127.0.0.1:7788或127.0.0.1:7788/index.html

项目文件结构

文件结构