📄 viewedf.m
字号:
LocalRepaint(0);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LocalFileInfo
% display information about current file
function LocalFileInfo(Update)
if nargin == 0
Data=get(findobj('Tag', 'ViewEDFFigure'), 'UserData');
if length(Data.EDF)==0
errordlg('No EDF-File is open!', 'Error');
return;
end
dlgh = dialog(...
'Name', 'EDF-File information', ...
'CloseRequestFcn', 'set(gcf,''UserData'',''Cancel'');uiresume;');
dlgpos = get(dlgh, 'Position');
set(dlgh, 'Position', [dlgpos(1),dlgpos(2),450,250]);
fnthght = LocalGetFontHeight;
Local.EDFNames = {};
% get filenames
for i = 1:length(Data.EDF)
Local.EDFNames = {Local.EDFNames{:}, Data.EDF(i).Head.FileName};
Local.EDFInfo{i,1} = Data.EDF(i).Head.Version;
Local.EDFInfo{i,2} = Data.EDF(i).Head.PID;
Local.EDFInfo{i,3} = Data.EDF(i).Head.RID;
Local.EDFInfo{i,4} = sprintf('%02d/%02d/%02d', Data.EDF(i).Head.TO([3 2 1]));
Local.EDFInfo{i,5} = sprintf('%02d:%02d:%02d', Data.EDF(i).Head.TO([4 5 6]));
Local.EDFInfo{i,6} = sprintf('%d', Data.EDF(i).Head.NS);
Local.EDFInfo{i,7} = sprintf('%d', Data.EDF(i).Head.NRec);
end
Local.poph = uicontrol(dlgh, ...
'Style', 'Popup', ...
'Units', 'Normalized', ...
'String', Local.EDFNames, ...
'Value', 1, ...
'Position', [0.05, 0.9, 0.9, 0.1], ...
'Callback', 'viewedf FileInfo Update');
LocalResizeUI(Local.poph, [NaN 1.1 0 0]);
%HeaderVersion
num = 1;
yinc = (1 - 4*fnthght) / 8;
ystart = 0.9;
uicontrol(dlgh, ...
'Style', 'Text', ...
'HorizontalAlignment', 'left', ...
'Units', 'Normalized', ...
'String', 'HeaderVersion : ', ...
'Position', [0.05, ystart - num*yinc, 0.3, fnthght]);
Local.txth(num) = uicontrol(dlgh, ...
'Style', 'Text', ...
'HorizontalAlignment', 'left', ...
'Units', 'Normalized', ...
'FontWeight', 'bold', ...
'String', '', ...
'Position', [0.45, ystart - num*yinc, 0.5, fnthght]);
%Patient ID
num = num + 1;
uicontrol(dlgh, ...
'Style', 'Text', ...
'HorizontalAlignment', 'left', ...
'Units', 'Normalized', ...
'String', 'Patient ID : ', ...
'Position', [0.05, ystart - num*yinc, 0.3, fnthght]);
Local.txth(num) = uicontrol(dlgh, ...
'Style', 'Text', ...
'HorizontalAlignment', 'left', ...
'Units', 'Normalized', ...
'FontWeight', 'bold', ...
'String', '', ...
'Position', [0.45, ystart - num*yinc, 0.5, fnthght]);
%Recording ID
num = num + 1;
uicontrol(dlgh, ...
'Style', 'Text', ...
'HorizontalAlignment', 'left', ...
'Units', 'Normalized', ...
'String', 'Recording ID : ', ...
'Position', [0.05, ystart - num*yinc, 0.3, fnthght]);
Local.txth(num) = uicontrol(dlgh, ...
'Style', 'Text', ...
'HorizontalAlignment', 'left', ...
'Units', 'Normalized', ...
'FontWeight', 'bold', ...
'String', '', ...
'Position', [0.45, ystart - num*yinc, 0.5, fnthght]);
% startdate
num = num + 1;
uicontrol(dlgh, ...
'Style', 'Text', ...
'HorizontalAlignment', 'left', ...
'Units', 'Normalized', ...
'String', 'Start date : ', ...
'Position', [0.05, ystart - num*yinc, 0.3, fnthght]);
Local.txth(num) = uicontrol(dlgh, ...
'Style', 'Text', ...
'HorizontalAlignment', 'left', ...
'Units', 'Normalized', ...
'FontWeight', 'bold', ...
'String', '', ...
'Position', [0.45, ystart - num*yinc, 0.5, fnthght]);
% start time
num = num + 1;
uicontrol(dlgh, ...
'Style', 'Text', ...
'HorizontalAlignment', 'left', ...
'Units', 'Normalized', ...
'String', 'Start time : ', ...
'Position', [0.05, ystart - num*yinc, 0.3, fnthght]);
Local.txth(num) = uicontrol(dlgh, ...
'Style', 'Text', ...
'HorizontalAlignment', 'left', ...
'Units', 'Normalized', ...
'FontWeight', 'bold', ...
'String', '', ...
'Position', [0.45, ystart - num*yinc, 0.5, fnthght]);
% Num channels
num = num + 1;
uicontrol(dlgh, ...
'Style', 'Text', ...
'HorizontalAlignment', 'left', ...
'Units', 'Normalized', ...
'String', 'Number of channels : ', ...
'Position', [0.05, ystart - num*yinc, 0.3, fnthght]);
Local.txth(num) = uicontrol(dlgh, ...
'Style', 'Text', ...
'HorizontalAlignment', 'left', ...
'Units', 'Normalized', ...
'FontWeight', 'bold', ...
'String', '', ...
'Position', [0.45, ystart - num*yinc, 0.5, fnthght]);
% num records
num = num + 1;
uicontrol(dlgh, ...
'Style', 'Text', ...
'HorizontalAlignment', 'left', ...
'Units', 'Normalized', ...
'String', 'Number of records : ', ...
'Position', [0.05, ystart - num*yinc, 0.3, fnthght]);
Local.txth(num) = uicontrol(dlgh, ...
'Style', 'Text', ...
'HorizontalAlignment', 'left', ...
'Units', 'Normalized', ...
'FontWeight', 'bold', ...
'String', '', ...
'Position', [0.45, ystart - num*yinc, 0.5, fnthght]);
% buttons
uicontrol(dlgh, ...
'Style', 'PushButton', ...
'Units', 'Normalized', ...
'String', 'OK', ...
'Position', [0.3, 0.02, 0.4, 0.1], ...
'Callback', 'uiresume;');
Data=[];
set(dlgh, 'UserData', Local);
LocalFileInfo('Update');
drawnow;
uiwait(dlgh);
delete(dlgh);
else
Data=get(gcf,'UserData');
which = get(Data.poph, 'Value');
for i = 1:7
set(Data.txth(i), 'String', Data.EDFInfo{which,i});
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LocalSelectChannels
% select channels to be displayed on the screen
function LocalSelectChannels(Parameter)
if nargin == 0
Data=get(findobj('Tag', 'ViewEDFFigure'), 'UserData');
if length(Data.EDF)==0
errordlg('No EDF-File is open!', 'Error');
return;
end
dlgh = dialog(...
'Name', 'EDF-File information', ...
'CloseRequestFcn', 'uiresume;');
Local.Names = {};
Local.Selected = {};
Local.Label = {};
% get filenames
for i = 1:length(Data.EDF)
Local.Names = {Local.Names{:}, ['EDF: ', Data.EDF(i).Head.FileName]};
temp = zeros(Data.EDF(i).Head.NS,1);
temp(Data.Display.EDF(i).ShowSignals) = 1;
Local.Selected = {Local.Selected{:}, temp};
Local.Label = {Local.Label{:}, Data.EDF(i).Head.Label};
end
%get plugin names
for i = 1:length(Data.Plugin)
Local.Names = {Local.Names{:}, ['Plugin: ', Data.Plugin(i).Label, ...
' (File ', upper(Data.Plugin(i).Name), ')']};
temp = zeros(Data.Plugin(i).EDF.Head.NS,1);
temp(Data.Display.Plugin(i).ShowSignals) = 1;
Local.Selected = {Local.Selected{:}, temp};
Local.Label = {Local.Label{:}, Data.Plugin(i).EDF.Head.Label};
end
uicontrol(dlgh, ...
'Style', 'Frame', ...
'Units', 'Normalized', ...
'Position', [0.02, 0.12, 0.96, 0.76]);
Local.Poph = uicontrol(dlgh, ...
'Style', 'Popup', ...
'Units', 'Normalized', ...
'String', Local.Names, ...
'Value', 1, ...
'Position', [0.05, 0.9, 0.9, 0.1], ...
'Callback', 'viewedf Channels Update');
LocalResizeUI(Local.Poph, [NaN 1.1 0 0]);
% buttons
uicontrol(dlgh, ...
'Style', 'PushButton', ...
'Units', 'Normalized', ...
'String', 'Select', ...
'Position', [0.1, 0.14, 0.3, 0.08], ...
'Callback', 'viewedf Channels Select');
uicontrol(dlgh, ...
'Style', 'PushButton', ...
'Units', 'Normalized', ...
'String', 'Unselect', ...
'Position', [0.6, 0.14, 0.3, 0.08], ...
'Callback', 'viewedf Channels Unselect');
uicontrol(dlgh, ...
'Style', 'PushButton', ...
'Units', 'Normalized', ...
'String', 'OK', ...
'Position', [0.1, 0.02, 0.3, 0.08], ...
'Callback', 'set(gco,''UserData'',''OK'');uiresume;');
uicontrol(dlgh, ...
'Style', 'PushButton', ...
'Units', 'Normalized', ...
'String', 'Cancel', ...
'Position', [0.6, 0.02, 0.3, 0.08], ...
'Callback', 'set(gco,''UserData'',''Cancel'');uiresume;');
Local.Checkh = [];
set(dlgh, 'UserData', Local);
LocalSelectChannels('Update'); % draw information
drawnow;
uiwait(dlgh);
changed = 0;
Local = get(dlgh, 'UserData');
temp = get(Local.Checkh, 'Value');
Local.Selected{Local.OldWhich} = cat(1,temp{:});
if strcmp(get(gco,'UserData'),'OK')
changed = 1;
for i = 1:length(Data.EDF)
Data.Display.EDF(i).ShowSignals = find(Local.Selected{i});
end
for i = 1:length(Data.Plugin)
Data.Display.Plugin(i).ShowSignals = find(Local.Selected{i+length(Data.EDF)});
end
end
delete(dlgh);
if changed
set(findobj('Tag', 'ViewEDFFigure'), 'UserData', Data);
LocalRepaint(0);
end
else
Data=get(gcf,'UserData');
which = get(Data.Poph, 'Value');
switch (Parameter)
case 'Update'
if ~isempty(Data.Checkh)
temp = get(Data.Checkh, 'Value');
if iscell(temp)
Data.Selected{Data.OldWhich} = cat(1,temp{:});
else
Data.Selected{Data.OldWhich} = temp;
end
delete(Data.Checkh);
Data.Checkh = [];
end
Data.OldWhich = which;
cbx = 0.1;
cby = 0.82;
cbxspace = 0.4;
cbyspace = 0.6 / ceil(length(Data.Selected{which}) / 2) + 0.005;
cbwidth = 0.35;
cbheight = LocalGetFontHeight;
for i = 1:length(Data.Selected{which})
Data.Checkh(i) = uicontrol(gcf, ...
'Style', 'CheckBox', ...
'Units', 'Normalized', ...
'String', Data.Label{which}(i, :), ...
'Value', Data.Selected{which}(i), ...
'Position', [cbx + rem(i-1,2)*cbxspace, cby - floor((i-1)/2)*cbyspace, ...
cbwidth, cbheight]);
end
case 'Select'
Data.Selected{which}(:) = 1;
set(Data.Checkh(:), 'Value', 1);
case 'Unselect'
Data.Selected{which}(:) = 0;
set(Data.Checkh(:), 'Value', 0);
end
set(gcf, 'UserData', Data);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LocalKeyPress
% handle keystrokes
function LocalKeyPress()
switch upper(get(gcf, 'CurrentCharacter'))
case '+'
feval('viewedf', 'Next');
case '-'
feval('viewedf', 'Prev');
case 'U'
LocalRescaleAll('up');
case 'D'
LocalRescaleAll('down');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LocalAbout
% display program info
function LocalAbout()
helpdlg(sprintf([ 'EDF (European-Data-Format) file-viewer.\n', ...
'Version 3.04Alpha\n\n' ...
'(c) 1998-2001 Herbert Ramoser\n', ...
' herbert.ramoser@arcs.ac.at\n\n' ...
'Comments or suggestions may be sent to the author.\n\n', ...
'This Software is subject to the GNU public license.']), ...
'About VIEWEDF');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LocalHelp
% display help page
function LocalHelp(Par)
name = which('viewedf');
name = [ 'file://', name(1:max(find(name == 'm'))-1), 'html'];
web(name);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LocalPrint
% display print dialog
function LocalPrint()
printdlg('-crossplatform', findobj('Tag', 'ViewEDFFigure'));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LocalWatchOn
% display watch pointer
function LocalWatchOn()
set(findobj('Tag', 'ViewEDFFigure'), 'Pointer', 'watch');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LocalWatchOff
% display arrow-pointer
function LocalWatchOff()
set(findobj('Tag', 'ViewEDFFigure'), 'Pointer', 'arrow');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LocalGetFontHeight
% get Fontheight
function hght=LocalGetFontHeight()
tempH = uicontrol(...
'Style', 'Text', ...
'String', 'Gg', ...
'Units', 'Normalized', ...
'FontUnits', 'Normalized', ...
'Position', [0, 0, 1, 1], ...
'Visible', 'off');
hght = get(tempH, 'FontSize') * 1.25; % 1.25 makes things look better
delete(tempH);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LocalGetFontWidth
% get Fontwidth
function width=LocalGetFontWidth()
tempH = uicontrol(...
'Style', 'Text', ...
'String', 'X', ...
'Units', 'Normalized', ...
'FontUnits', 'Normalized', ...
'Position', [0, 0, 1, 1], ...
'Visible', 'off');
width = get(tempH, 'Extent');
width = width(3);
delete(tempH);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LocalEDFOpen
% open a EDF (or GDF) file
function LocalE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -