You are on page 1of 2

Eeg data analysis

MATLAB CODES1.dwt code% convert the NK ASCII file, write matlab file get_nkheader('C:\Users\hp\Desktop\setb\sangam.m00'); convert_nkascii2mat('C:\Users\hp\Desktop\setb\sangam.m00','sangam',10); % load the converted matlab f load sangam.mat; % convert all eeg data values to microvolts nkdata.eeg=nkdata.eeg./nkdata.multiplier; s=nkdata.eeg(16,:); [ca1,cd1] =dwt(s,'db4'); [ca2,cd2]=dwt(ca1,'db4'); [ca3,cd3]=dwt(ca2,'db4'); %[ca4,cd4]=dwt(ca3,'db4');

x1=std(ca1); x2=std(ca2); x3=std(ca3); %x4=std(ca4); x1 x2 x3 %x4

2.psd code% convert the NK ASCII file, write matlab file get_nkheader('C:\Users\hp\Desktop\setb\sangam.m00'); convert_nkascii2mat('C:\Users\hp\Desktop\setb\sangam.m00','sangam',10); % load the converted matlab f load sangam.mat; % convert all eeg data values to microvolts nkdata.eeg=nkdata.eeg./nkdata.multiplier; pwelch(nkdata.eeg(6,:))

3.fft code% convert the NK ASCII file, write matlab file get_nkheader('C:\Users\hp\Desktop\setb\sangam.m00'); convert_nkascii2mat('C:\Users\hp\Desktop\setb\sangam.m00','sangam',10); % load the converted matlab f load sangam.mat; % convert all eeg data values to microvolts nkdata.eeg=nkdata.eeg./nkdata.multiplier; y=fft(nkdata.eeg(14,:),1000) ty=abs(y) plot(ty)

4.code to extract header files-function


[ntpoints,nchannels,bsweep,sampintms,binsuV,start_time,ch_names]=get_nkhead er(fname) % Reads a Nihon Kohden EEG file in ASCII format (fname) and % returns 7 pieces of information from the header % % The function returns the following information: % ntpoints - number of data points per channel % nchannels - number of channels sampled during recording

Eeg data analysis


% % % % % bsweep - begin sweep (ms) sampintms - sampling interval in ms binsuV - number of bins per microvolts start_time - starting time of recording ch_names - char array of channel names

fid=fopen(fname,'r'); %header line 1: acquisition information hline1 = fgets(fid); % get the six different fields in the header, store in cell array hd=textscan(hline1,'%s %s %s %s %s %s'); fprintf('\nNihon Kohden ASCII EEG header fields:'); fprintf('\n-------------------------------------'); % number of timepoints [txt,ntpoints]=strread(char(hd{1}),'%s%d','delimiter','='); fprintf('\n%s is %d',char(txt),ntpoints); % number of channels sampled [txt,nchannels]=strread(char(hd{2}),'%s%d','delimiter','='); fprintf('\nNumber of %s is %d',char(txt),nchannels); % begin sweep in ms [txt,bsweep]=strread(char(hd{3}),'%s%f','delimiter','='); fprintf('\n%s is %2.2f',char(txt),bsweep); % sampling interval in ms [txt,sampintms]=strread(char(hd{4}),'%s%f','delimiter','='); fprintf('\n%s is %1.2f (or %2.1f Hz)',char(txt),sampintms,(1000./sampintms)); [txt,binsuV]=strread(char(hd{5}),'%s%f','delimiter','='); fprintf('\n%s is %1.2f',char(txt),binsuV); % start time tt=char(hd{6}); start_time=tt(end-7:end); fprintf('\nStart Time is %s\n',start_time); % header line 2: names of recording channels hline2 = fgets(fid); % channel names as cell array ch_names=textscan(hline2,'%s'); % convert to char array ch_names=char(ch_names{1}); % close input file fclose(fid);

You might also like