📄 viewedf.m
字号:
'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}); endend%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LocalSelectChannels% select channels to be displayed on the screenfunction 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); endelse 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 keystrokesfunction 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 infofunction 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 pagefunction LocalHelp(Par)name = which('viewedf');name = [ 'file://', name(1:max(find(name == 'm'))-1), 'html'];web(name);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LocalPrint% display print dialogfunction LocalPrint()printdlg('-crossplatform', findobj('Tag', 'ViewEDFFigure'));%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LocalWatchOn% display watch pointerfunction LocalWatchOn()set(findobj('Tag', 'ViewEDFFigure'), 'Pointer', 'watch');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LocalWatchOff% display arrow-pointerfunction LocalWatchOff()set(findobj('Tag', 'ViewEDFFigure'), 'Pointer', 'arrow');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LocalGetFontHeight% get Fontheightfunction 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 betterdelete(tempH);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LocalGetFontWidth% get Fontwidthfunction 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) filefunction LocalEDFOpen(Filename)% show EDF header errorsShowHeadErr = 0;% variables to find things in the headerH1idx=[8 80 80 8 8 8 44 8 8 4];H2idx=[16 80 8 8 8 8 8 80 8 32];GDFTYP_BYTE=[1 1 1 2 2 4 4 8 8 4 8 0 0 0 0 0 4 8]';GDFTYPES=[0 1 2 3 4 5 6 7 16 17];
if nargin == 0
% get filename [edfname,edfpath]=uigetfile('*.*','Open EDF File'); Filename = [edfpath,edfname]; if edfname == 0 return; end
end
fid=fopen(Filename, 'r', 'ieee-le'); if (fid < 0) errordlg('Error reading file', 'File Error'); returnend;Data = get(findobj('Tag', 'ViewEDFFigure'), 'UserData');numedf = length(Data.EDF) + 1;% read all dataEDFHead.FILE.FID = fid;EDFHeadFILE.OPEN = 1;EDFHead.FileName = Filename;PPos = min([max(find(Filename == '.')) length(Filename) + 1]);SPos = max([0 find(Filename == filesep)]);EDFHead.FILE.Ext = Filename(PPos+1:length(Filename));EDFHead.FILE.Name = Filename(SPos+1:PPos-1);EDFHead.FILE.Path = edfpath;H1 = setstr(fread(EDFHead.FILE.FID,184,'uchar')'); EDFHead.Version = H1(1:8); % 8 Byte Versionsnummer IsGDF = strcmp(EDFHead.Version(1:3), 'GDF');if (~strcmp(EDFHead.Version, '0 ') & ~IsGDF) errordlg('Unknown file version', 'File error'); return;endEDFHead.PID = deblank(H1(9:88)); % 80 Byte local patient identificationEDFHead.RID = deblank(H1(89:168)); % 80 Byte local recording identificationif IsGDF % handle different file formats EDFHead.TO = [str2num(H1(168 + [1:4])) ... str2num(H1(168 + [5 6])) ... str2num(H1(168 + [7 8])) ... str2num(H1(168 + [9 10])) ... str2num(H1(168 + [11 12])) ... str2num(H1(168 + [13:16]))]; if str2num(EDFHead.Version(4:8)) < 0.12 tmp = setstr(fread(EDFHead.FILE.FID, 8, 'uchar')'); % header-length EDFHead.HeadLen = str2num(tmp); else EDFHead.HeadLen = fread(EDFHead.FILE.FID, 1, 'int64'); end tmp = fread(EDFHead.FILE.FID, 44, 'uchar'); % 44 bytes reser
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -