% clear the memory clear; % close all open files and windows close all; % clear the command console clc; % loop through and load the participants for i = 1:10 % specify a file name fileName = ['Subject ' num2str(i) '.mat']; % load the file load(fileName); % put the data into a variable called fftData fftData(:,:,:,i) = FFT.data(:,1:30,:); end grandFFT = mean(fftData,4); fftChannel = 52; % Pz plot(FFT.frequencies(1:30),grandFFT(fftChannel,:,1)); hold on; plot(FFT.frequencies(1:30),grandFFT(fftChannel,:,2)); % this will get us the power in the delta range (1 to 3) for both % conditions for all participants deltaPower = squeeze(fftData(fftChannel,1:3,:,:)); deltaPower = squeeze(mean(deltaPower,1)); % we will repeat this for theta, alpha, and beta. you will note that the % only difference is in the frequency range being specified. we are also % only analyzing one channel thetaPower = squeeze(fftData(fftChannel,4:7,:,:)); thetaPower = squeeze(mean(thetaPower,1)); alphaPower = squeeze(fftData(fftChannel,8:12,:,:)); alphaPower = squeeze(mean(alphaPower,1)); betaPower = squeeze(fftData(fftChannel,13:30,:,:)); betaPower = squeeze(mean(betaPower,1)); % delta power plot data deltaPowerPlotData = squeeze(fftData(:,1:3,:,:)); % take the mean across participants deltaPowerPlotData = mean(deltaPowerPlotData,4); % and take the mean over 1 to 3 Hz deltaPowerPlotData = squeeze(mean(deltaPowerPlotData,2)); % we will take the difference between conditions for the headplot, but you % do not need to deltaPowerPlotDifference = deltaPowerPlotData(:,1) - deltaPowerPlotData(:,2); % plot the topo doPlot2DTopo(deltaPowerPlotDifference,FFT.chanlocs);