⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bkropen.m

📁 matlab数字信号处理工具箱
💻 M
字号:
function [BKR,s]=bkropen(arg1,PERMISSION,CHAN,arg4,arg5,arg6)
% BKROPEN opens BKR file
% [BKR,signal] = bkropen(Filename, PERMISSION, ChanList);
% [s,BKR] = eegread(BKR [,NoS [,Startpos]])
% 
% FILENAME 
% PERMISSION is one of the following strings 
%	'r'	read 
% ChanList	(List of) Channel(s) default 0 loads all channels
%
% see also: SOPEN, SREAD, SSEEK, STELL, SCLOSE, SWRITE, SEOF

%	$Revision: 1.20 $
%	$Id: bkropen.m,v 1.20 2004/03/25 18:53:10 schloegl Exp $
%	Copyright (c) 1997-2004 by Alois Schloegl
%	a.schloegl@ieee.org	

% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the  License, or (at your option) any later version.
% 
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
% 
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

if nargin<2, 
        PERMISSION='rb'; 
elseif ~any(PERMISSION=='b');
        PERMISSION = [PERMISSION,'b']; % force binary open. 
end;
if nargin<3, CHAN=0; end;

if isstruct(arg1),
	BKR=arg1;
	FILENAME=BKR.FileName;
	if BKR.FILE.OPEN,
		fseek(BKR.FILE.FID,0,'bof');	
	else
		BKR.FILE.FID = fopen(FILENAME,PERMISSION,'ieee-le');          
	end;
else
	FILENAME=arg1;
	BKR.FILE.FID = fopen(FILENAME,PERMISSION,'ieee-le');          
        BKR.FileName  = FILENAME;
        [pfad,file,FileExt] = fileparts(BKR.FileName);
        BKR.FILE.Name = file;
        BKR.FILE.Path = pfad;
        BKR.FILE.Ext  = FileExt(2:length(FileExt));
end;
if BKR.FILE.FID<0,
        fprintf(2,'Error BKROPEN: file %s not found.\n',FILENAME); 
        return;
end;
if ftell(BKR.FILE.FID)~=0,	% 
        fprintf(2,'Error: Fileposition is not 0\n');        	        
end;

BOOL='int16';
ULONG='uint32'; 
FLOAT='float32';

if any(PERMISSION=='r'),
	BKR.FILE.OPEN = 1;
	fid = BKR.FILE.FID;
%%%%% READ HEADER

%VARIABLE	TYPE			#bytes	OFFSET	COMMENT
	VER=fread(fid,1,'ushort');	%	2 Byte	0	Versionsnummer 
	if ((VER<=200) | (VER>207)) fprintf(2,'LOADBKR: WARNING  Version BKR Format %i',VER); end;
	nch=fread(fid,1,'ushort');	%	2 Byte	2	Anzahl der Kan鋖e
	nhz=fread(fid,1,'ushort');	%	2 Byte	4	Abtastfrequenz	
	ntr=fread(fid,1, 'uint32');	%	4 Byte	6	Anzahl der Trials
	nsp=fread(fid,1, 'uint32');	%	4 Byte	10	Anzahl Samples per Trial
	cvlt=fread(fid,1,'ushort');	%	2 Byte	14	Kalibrierspannung	
	cval=fread(fid,1,'ushort');	%	2 Byte	16	Kalibrierwert
	code=fread(fid,4,'char');	%	4 Byte	18	Elektrodencode
	code=setstr(code)';
	lcf=fread(fid,1, FLOAT);	%	4 Byte	22	untere Eckfrequenz
	ucf=fread(fid,1, FLOAT);	%	4 Byte	26	obere Eckfrequenz
	BKR.BKR.sref=fread(fid,1, ULONG);	%	4 Byte	30	Startzeitpunkt Referenz in Samples
	BKR.BKR.eref=fread(fid,1, ULONG);	%	4 Byte	34	L鋘ge Referenz in Samples	
	BKR.BKR.sact=fread(fid,1, ULONG);	%	4 Byte	38	Startzeitpunkt Aktion in Samples
	BKR.BKR.eact=fread(fid,1, ULONG);	%	4 Byte	42	L鋘ge Aktion in Samples
	trg=fread(fid,1,BOOL);		%	2 Byte	46	flag f黵 Trigger
	BKR.BKR.pre=fread(fid,1, ULONG);	%	4 Byte	48	Anzahl der Sampels vor dem Trigger
	BKR.BKR.pst=fread(fid,1, ULONG);	%	4 Byte	52	Anzahl der Sampels nach dem Trigger
	BKR.BKR.hav=fread(fid,1,BOOL);		%	2 Byte	56	flag f黵 "horizontale" Mittelung
	BKR.BKR.nah=fread(fid,1, ULONG);	%	4 Byte	58	Anzahl der gemittelten Trials
	BKR.BKR.vav=fread(fid,1,BOOL);		%	2 Byte	62	flag f黵 "vertikale" Mittelung	
	BKR.BKR.nav=fread(fid,1,'ushort');	%	2 Byte	64	Anzahl der gemittelten Kan鋖e
	BKR.BKR.cav=fread(fid,1,BOOL);		%	2 Byte	66	flag f黵 Datenkomprimierung
	BKR.BKR.nac=fread(fid,1, ULONG);	%	4 Byte	68	Anzahl der gemittelten Samples
	com=fread(fid,1,BOOL);		%	2 Byte	72	flag: Common Average Reference
	loc=fread(fid,1,BOOL);		%	2 Byte	74	flag: Local Average Reference
	lap=fread(fid,1,BOOL);		%	2 Byte	76	flag: Laplace Berechnung
	wgt=fread(fid,1,BOOL);		%	2 Byte	78	flag: Weighted Average Reference
	BKR.BKR.pwr=fread(fid,1,BOOL);		%	2 Byte	80	flag: Leistung
	BKR.BKR.avr=fread(fid,1,BOOL);		%	2 Byte	82	flag: Mittelwert
	BKR.BKR.std=fread(fid,1,BOOL);		%	2 Byte	84	flag: Streuung
	BKR.BKR.bps=fread(fid,1,BOOL);		%	2 Byte	86	flag: Bandpa

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -