%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Program Name: EEG_Signal_V0_R0 % %Version: 0 % %Revision: 0 % %Author: Matt Waldersen % %Date Created: 10/5/2012 % %Last Updated: % %Description: Breaking up a raw EEG Signal from the NeuroSky Mindwave EEG % % and plotting each frequency as a function of magnitude. % %References: A vast majority of this program is based off of MathWorks % % "FFT for Spectral Analysis" example. The contents of this % % example can be found on the MathWorks website at % % http://www.mathworks.com/products/matlab/examples.ht ---> % % ---> ml?file=/products/demos/shipping/matlab/fftdemo.html % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear clc %%%%%%%%%%%%%%%%%%%%%%% loading csv values %%%%%%%%%%%%%%%%%%%%%%% csv = load('baseline_raw_0.csv'); size = size(csv,1); time = csv(:,1); Raw_EEG = csv(:,2); ideal_out = csv(:,3); %%%%%%%%%%%%%%%%%%%%%%% removing duplicate times %%%%%%%%%%%%%%%%%%%%%%% for i=1:(size-1) if(time(i) == time(i+1)) count = 1; while(time(i)==time(i+count)) count = count + 1; end for j=1:(count-1) time(i+j) = time(i+j) + ((1/count) * (1e-4)); end end end Sample_Rate = 512; Sample_Size = size; Raw_EEG2 = Raw_EEG; Y = fft(Raw_EEG2,Sample_Size); Pyy = Y.*conj(Y)/Sample_Size; f = Sample_Rate/Sample_Size*(0:(floor(Sample_Size/2)-1)); plot(f,Pyy(1:floor(Sample_Size/2))) title('Power spectral density') xlabel('Frequency (Hz)')