资源简介
很不错的matlab代码,针对于做EEG的运动想象的CSP分解算法和特征选取,代码注释很清楚,拿到手就可以用,结合数据集。
代码片段和文件信息
function features = extractCSPFeatures(EEGSignals CSPMatrix nbFilterPairs)
%extract features from an EEG data set using the Common Spatial Patterns (CSP) algorithm
%
%Input:
%EEGSignals: the EEGSignals from which extracting the CSP features. These signals
%are a structure such that:
% EEGSignals.x: the EEG signals as a [Ns * Nc * Nt] Matrix where
% Ns: number of EEG samples per trial
% Nc: number of channels (EEG electrodes)
% nT: number of trials
% EEGSignals.y: a [1 * Nt] vector containing the class labels for each trial
% EEGSignals.s: the sampling frequency (in Hz)
%CSPMatrix: the CSP projection matrix learnt previously (see function learnCSP)
%nbFilterPairs: number of pairs of CSP filters to be used. The number of
% features extracted will be twice the value of this parameter. The
% filters selected are the one corresponding to the lowest and highest
% eigenvalues
%
%Output:
%features: the features extracted from this EEG data set
% as a [Nt * (nbFilterPairs*2 + 1)] matrix with the class labels as the
% last column
%initializations
nbTrials = size(EEGSignals.x3);
features = zeros(nbTrials 2*nbFilterPairs+1);
Filter = CSPMatrix([1:nbFilterPairs (end-nbFilterPairs+1):end]:);
%extracting the CSP features from each trial
for t=1:nbTrials
%projecting the data onto the CSP filters
projectedTrial = Filter * EEGSignals.x(::t)‘;
%generating the features as the log variance of the projected signals
variances = var(projectedTrial02);
for f=1:length(variances)
features(tf) = log(variances(f));
end
features(tend) = EEGSignals.y(t);
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1708 2018-04-04 16:03 extractCSPFeatures.m
文件 2015 2018-03-29 10:30 learnCSP.m
----------- --------- ---------- ----- ----
3723 2
- 上一篇:霍夫变换hough_circle
- 下一篇:波达方向估计MAtLAB
相关资源
- 波达方向估计MAtLAB
- Matlab中求解最小生成树的程序
- 导弹自适应滑模制导律仿真matlab代码
- 单尺度和多尺度retinex的matlab实现程序
- 频谱感知-能量检测法代码
- COMSOL-MATLAB.m
- MATLAB处理向前映射和向后映射
- matlab用ADMM算法解决Group Lasso问题
- MATLAB希尔伯特Hilbert变换求包络谱
- matlab的CT图像重建代码
- k-means聚类matlab代码
- MATLAB16进制转换为2进制
- 高斯差分滤波器 matlab
- 经典功率谱估计和现代谱估计方法
- matlab均值滤波函数
- GPS位置解算MATLAB仿真
- 最终改进版的matlab程序,改正角度和
- 彭曼公式计算作物潜在蒸散量ET0matl
- WVD和stft的matlab程序
- 三种图像增强算法的matlab源代码
- 四元数MATLAB相关计算
- 美式期权执行边界的matlab实现
- 用MATLAB(BPSK仿真+直接扩频
- AR过程功率谱估计MATLAB实现代码带备注
- MPSK信号基于高阶循环谱估计载波频率
- 矩形波导模式以及光纤LP模式的matla
- Matlab将二维图像三维重构
- matlab3次样条插值函数实现
- 已知二维联合概率密度matlab求解
- matlab求二维概率密度二维概率分布
评论
共有 条评论