% clear the memory clear; % close all open files and windows close all; % clear the command console clc; % key file variables we will need pathName = '/Users/krigolson/Desktop/Frequency Tutorial Folder'; fileName = 'Oddball1.vhdr'; % load the data EEG = doLoadBVData(pathName,fileName); % keep track of the original channel locations originalChannels = EEG.chanlocs; % define the filter parameters filterParameters.low = 0.5; filterParameters.high = 30; filterParameters.notch = 60; % filter the data EEG = doFilter(EEG,filterParameters); % do some initial data cleaning EEG = doCleanData(EEG); % rereference the data to the average reference before ICA to improve % results EEG = doICAReference(EEG); % run the ICA EEG = doICA(EEG); % remove ocular ICA components EEG = doRemoveOcularICAComponents(EEG); % interpolate the removed channels EEG = doInterpolate(EEG,originalChannels); % epoch the data into segments epochMarkers = {'S202','S203'}; epochTimes = [-0.2 0.8]; EEG = doEpochData(EEG,epochMarkers,epochTimes); % baseline correct the data baselineWindow = [-0.2 0]; EEG = doBaseline(EEG,baselineWindow); % run the Wavelet analysis. The time specified is the baseline window in % ms. The next three numbers are the minimum frequency, the maximum % frequency, and the number of frequency steps. I used 30 so the resolution % will be 1 Hz. The last number if the mortlet parameter which shapes the % wavelet. the recommended number is 6. WAV = doWAV(EEG,epochMarkers,[-200 0],1,30,30,6); % plot the Wavelets for both conditions side by size for channel 52 condition1WaveletData = squeeze(WAV.data(52,:,:,1)); condition2WaveletData = squeeze(WAV.data(52,:,:,2)); % now the plotting is more complex as we are working with an image with 3D % data subplot(1,2,1); imagesc(condition1WaveletData); title('Channel Pz: Condition One'); xlabel('Samples'); ylabel('Frequency (Hz)'); set(gca,'YDir','normal'); subplot(1,2,2); imagesc(condition2WaveletData); title('Channel Pz: Condition Two'); xlabel('Samples'); set(gca,'YDir','normal'); ylabel('Frequency (Hz)'); % save the data save('Subject Wavelet 1','WAV');