Professional Documents
Culture Documents
Matlab Codes
Matlab Codes
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');
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)
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);