classdef ECoGAnalysisApp < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
GridLayout matlab.ui.container.GridLayout
% 左侧控制面板元素
ControlPanel matlab.ui.container.Panel
LoadECoGButton matlab.ui.control.Button
ECoGFilePathLabel matlab.ui.control.Label
LoadEMGButton matlab.ui.control.Button
EMGFilePathLabel matlab.ui.control.Label
ChannelListBoxLabel matlab.ui.control.Label
ChannelListBox matlab.ui.control.ListBox % 将支持多选
AnalyzeChannelButton matlab.ui.control.Button
% 新增:处理操作面板 (未来用于滤波和参考)
ProcessingPanel matlab.ui.container.Panel
FilterTypeDropDownLabel matlab.ui.control.Label
FilterTypeDropDown matlab.ui.control.DropDown
CutoffFreq1Label matlab.ui.control.Label
CutoffFreq1EditField matlab.ui.control.NumericEditField
CutoffFreq2Label matlab.ui.control.Label
CutoffFreq2EditField matlab.ui.control.NumericEditField
FilterOrderLabel matlab.ui.control.Label
FilterOrderEditField matlab.ui.control.NumericEditField
ApplyFilterButton matlab.ui.control.Button
ApplyCARButton matlab.ui.control.Button
ResetProcessingButton matlab.ui.control.Button
ProcessingStatusLabel matlab.ui.control.Label
% 右侧显示面板元素 (使用 TabGroup)
DisplayTabGroup matlab.ui.container.TabGroup
TimeDomainTab matlab.ui.container.Tab
TimeDomainGridLayout matlab.ui.container.GridLayout
ECoGAxes matlab.ui.control.UIAxes
EMGAxes matlab.ui.control.UIAxes
TimeFrequencyTab matlab.ui.container.Tab
SpectrogramGridContainer matlab.ui.container.GridLayout % 新属性:可滚动的父grid
PowerSpectrumTab matlab.ui.container.Tab
PSDGridContainer matlab.ui.container.GridLayout % 新属性:可滚动的父grid
end
% Properties to store data
properties (Access = private)
ecog_data_raw % 存储原始加载的ECoG数据
ecog_data_filtered % 存储滤波后的ECoG数据
ecog_data % 当前用于显示和分析的ECoG数据 (可能是原始、滤波后或参考后)
ecog_srate
ecog_chanlocs % Cell array of channel labels
emg_data
emg_srate
emg_chanlocs % Cell array of channel labels
isFilterApplied matlab.lang.OnOffSwitchState = 'off'
isCARApplied matlab.lang.OnOffSwitchState = 'off'
lastFilterParams struct % 存储上次应用的滤波器参数
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: LoadECoGButton
function LoadECoGButtonPushed(app, event)
[filename, filepath] = uigetfile({'*.edf;*.EDF', 'EDF Files (*.edf, *.EDF)'; '*.*', 'All Files (*.*)'}, ...
'Select ECoG EDF File');
if isequal(filename, 0) || isequal(filepath, 0)
uialert(app.UIFigure, 'User cancelled ECoG file selection.', 'Info');
return;
end
fullpathname = fullfile(filepath, filename);
app.ECoGFilePathLabel.Text = ['ECoG: ', filename];
try
[data_temp, Hdr] = sload(fullpathname);
if isempty(data_temp) || isempty(Hdr)
error('sload did not return data or header.');
end
if size(data_temp,1) == Hdr.NS
raw_data = data_temp;
elseif size(data_temp,2) == Hdr.NS
raw_data = data_temp';
else
error('Mismatch between data dimensions and number of channels in header from sload.');
end
app.ecog_data_raw = raw_data; % Store raw data
app.ecog_data_filtered = app.ecog_data_raw; % Initially filtered is same as raw
app.ecog_data = app.ecog_data_raw; % Active data is initially raw
if isfield(Hdr, 'SampleRate') && ~isempty(Hdr.SampleRate)
if length(Hdr.SampleRate) == Hdr.NS
app.ecog_srate = Hdr.SampleRate(1);
if ~all(Hdr.SampleRate == app.ecog_srate)
uialert(app.UIFigure, 'ECoG channels have different sampling rates. Using the first one. Processing might be incorrect.', 'Warning', 'Interpreter', 'none');
end
elseif length(Hdr.SampleRate) == 1
app.ecog_srate = Hdr.SampleRate;
else
error('Cannot determine ECoG sampling rate from sload header (Hdr.SampleRate format unknown).');
end
elseif isfield(Hdr, 'SPR')
if isfield(Hdr, 'Dur') && Hdr.Dur(1) ~= 0
app.ecog_srate = Hdr.SPR(1) / Hdr.Dur(1);
if ~all( (Hdr.SPR ./ Hdr.Dur) == app.ecog_srate)
uialert(app.UIFigure, 'ECoG channels have different sampling rates calculated from SPR/Dur. Using the first one.', 'Warning', 'Interpreter', 'none');
end
else
app.ecog_srate = Hdr.SPR(1);
uialert(app.UIFigure, 'ECoG sampling rate determined from SPR without Duration. May be inaccurate if record duration is not 1s.', 'Warning', 'Interpreter', 'none');
end
else
error('Cannot determine ECoG sampling rate from sload header (SampleRate or SPR not found).');
end
if isfield(Hdr, 'Label') && ~isempty(Hdr.Label)
app.ecog_chanlocs = cellstr(Hdr.Label);
else
app.ecog_chanlocs = arrayfun(@(x) sprintf('Ch %d', x), 1:size(app.ecog_data,1), 'UniformOutput', false);
end
app.ecog_chanlocs = strtrim(app.ecog_chanlocs);
emptyLabels = cellfun('isempty', app.ecog_chanlocs);
for k_idx = find(emptyLabels)'
app.ecog_chanlocs{k_idx} = sprintf('Ch %d', k_idx);
end
app.isFilterApplied = 'off'; % Reset states
app.isCARApplied = 'off';
app.updateProcessingStatusLabel();
app.updateChannelListBox();
app.plotTimeDomainECoG();
uialert(app.UIFigure, 'ECoG data loaded successfully using sload!', 'Success', 'Interpreter', 'none');
catch ME
uialert(app.UIFigure, ['Error loading ECoG with sload: ', ME.message], 'Error', 'Interpreter', 'none');
fprintf('Error loading ECoG with sload. Details:\n%s\n', ME.getReport('extended', 'hyperlinks','off'));
app.ECoGFilePathLabel.Text = 'ECoG: Failed to load';
app.ecog_data_raw = []; app.ecog_data_filtered = []; app.ecog_data = [];
app.ecog_chanlocs = {};
app.updateChannelListBox();
cla(app.ECoGAxes); title(app.ECoGAxes, 'ECoG Signals');
end
end
% Button pushed function: LoadEMGButton (similar logic, not detailed for brevity now)
function LoadEMGButtonPushed(app, event)
[filename, filepath] = uigetfile({'*.edf;*.EDF', 'EDF Files (*.edf, *.EDF)'; '*.*', 'All Files (*.*)'}, ...
'Select EMG EDF File');
if isequal(filename, 0) || isequal(filepath, 0)
uialert(app.UIFigure, 'User cancelled EMG file selection.', 'I
没有合适的资源?快使用搜索试试~ 我知道了~
基于MATLAB的edf脑电信号阅读器,仅支持edf格式信号;可以生成时域图,时频图及频谱图;可以进行简单的信号预处理,

共1个文件
m:1个

0 下载量 187 浏览量
2025-08-22
15:26:58
上传
评论
收藏 8KB ZIP 举报
温馨提示
基于MATLAB的edf脑电信号阅读器,仅支持edf格式信号;可以生成时域图,时频图及频谱图;可以进行简单的信号预处理,包括滤波和平均参考;可以同时读取EMG信号以进行比对。.zip
资源推荐
资源详情
资源评论
























收起资源包目录



共 1 条
- 1
资源评论


metutoo9072
- 粉丝: 0
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- PLC皮带运输监控系统设计方案.doc
- 网络传播视阈下的地区形象改善策略研究.docx
- 初学者必看!PLC与常见设备连接方式.doc
- plc原理设计的自动售货机.doc
- 汽车零部件行业MRP信息化平台技术.ppt
- 基于PLC实现的彩灯广告牌方案设计书.doc
- 区块链基础:非技术性25步指南
- 北京市通信公司综合业务楼工程大体积砼施工组织设计方案.doc
- 大数据时代互联网广告的营销模式分析.docx
- 浙江省传统村落调研资料数据库的建立与应用研究.docx
- 【精品ppt】互联网+电子商务创新创业融资竞赛-(1).pptx
- 基于PLC交通灯控制系统大学本科方案设计书[1]177.doc
- 通信部队信息化建设存在的问题及解决措施.docx
- 大数据背景下企业人力资源绩效管理创新探讨.docx
- 适用于预测性维护与健康管理的故障诊断及剩余使用寿命预测大型语言模型
- 软件工程期末考试题3.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
