[Eeglablist] Question for Nicolet BMSI 6000 EEG machine
Sarang S. Dalal
sarang at hurricane.ucsf.edu
Tue Sep 14 16:38:37 PDT 2004
Nicolet provided me with the attached script to read BMSI6000 data into
matlab some time ago. It would be a good starting point for writing a
script to import into eeglab.
-Sarang
On Tue, 2004-09-14 at 02:35, Xiaoli Li wrote:
> Dear all,
> I am working on EEG analysis, of course ICA is a powerful tool for it.
> The EEG data is from Nicolet BMSI 6000 EEG machine, however I do not how
> to transfer the data into text format,
> so that ICAEEG can read it. I believe someone has also encounter this
> problem. Could you please let me know how to solve this problem.
>
> Thanks, Xiaoli
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\ Sarang S. Dalal /
/ UCSF Biomagnetic Imaging Laboratory \
\ UCSF/UCB Bioengineering Graduate Group /
/ sarang at hurricane.ucsf.edu \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-------------- next part --------------
%
%%
%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% NicoletEEG2MAT.m
%%
%% The code is made freely available for non-commercial use only, specifically for research
%% and teaching purposes, provided that the copyright headers at the head of each file are
%% not removed, and suitable citation is made in published work using the routine(s).
%% No responsibility is taken for any errors in the code.
%%Copyright (c) 2002-2003 by Moshe Yuchtman, Nicolet Biomedical Inc.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Script to import Nicolet Alliance or Bravo (version 3.6) EEG file into MATLAB.
% It will work with a directory containing ONE EEG file (or saved clipped EEG). The program obtains
% sample rate and number of channels information from the BNI file, if one is present, or from the
% trailer information at o the end of the data file.
%(typically, file name is data.eeg)
% The EEG is stored as binary Short Integer (2 bytes) with channels interleaved
%Patient and protocol information are stored in a variable size trailer following
% the data block. The last Long Word stores the offset, in bytes, of the trailer re
% The script opens the file and loads seconde_to_read worth of data points per channel,
% (default is 60 seconds) and saves the data (stored as variable EEG) in a
% sequentially numbered mat file and xls file
seconds_to_read=60;
%
%
eegfile=input('Enter EEG file name \n','s');
[a1,eegname,ext,a4]=fileparts(eegfile);
if isempty(ext) == 1
ext='.eeg';
eegfile=[eegname ext];
end
if exist(eegfile,'file') == 0
disp('File not found')
break
end
bnifile=[eegname,'.bni'];
if exist(bnifile,'file') ~= 0
fid=fopen(bnifile);
H=fread(fid);
header=setstr(H');
fclose(fid);
fid=fopen(eegfile);
fseek(fid,0,1);
total_bytes=ftell(fid);
samples=total_bytes/2;
frewind(fid);
else
%Embedded BNI case
fid=fopen(eegfile);
fseek(fid,-4,1);
offset_bytes=fread(fid,1,'int32');
samples=offset_bytes/2;
frewind(fid);
% Header information
fseek(fid,offset_bytes,0);
H=fread(fid);
header=setstr(H');
end
% Find sample rate
l=findstr(header,'Rate =');
sample_rate=str2num(header(l+6:l+9));
% Find Number of channels
l=findstr(header,'NchanFile =');
nchan=str2num(header(l+11:l+14));
samples_per_chan=samples/nchan;
load_size=seconds_to_read*sample_rate;
if load_size < samples_per_chan
nloads=floor(samples_per_chan/load_size);
nlast=mod(samples_per_chan,load_size);
else
nloads=1;
nlast=0;
load_size=samples_per_chan;
end
disp([eegfile,' is processed, ', num2str(nchan),' Channels, ',num2str(samples_per_chan), ' samples per channel, '...
'sample rate: ', num2str(sample_rate),' Hz' ])
for nr=1:nloads
EEG=fread(fid,[nchan,load_size],'int16');
matfile=[eegname,num2str(nr)];
save(matfile,'EEG');
disp(['Saved ',num2str(load_size),' samples in MATLAB file: ', matfile])
end
%Read last record if a minute or more is left
if nlast > 0
EEG=zeros(nchan,nlast);
EEG=fread(fid,[nchan,nlast],'int16');
nleft=load_size-nlast;
matfile=[eegname,num2str(nr+1)];
save(matfile,'EEG');
disp(['Saved ',num2str(nlast),' samples in MATLAB file: ', matfile])
end
fclose(fid);
More information about the Eeglablist
mailing list