-
Notifications
You must be signed in to change notification settings - Fork 6
/
samplePreprocessingScriptForFrequencyAnalysis.m
46 lines (34 loc) · 1.28 KB
/
samplePreprocessingScriptForFrequencyAnalysis.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
clear all;
close all;
clc;
% load a data set for analysis into EEGLAB format
[EEG] = doLoadBVData('Cognitive_Assessment_01.vhdr');
% not needed but here for demonstration purposes
%[EEG] = doRemoveChannels(EEG,{},EEG.chanlocs);
% not needed but here for demonstration purposes
%[EEG] = doInterpolate(EEG,EEG.chanlocs,'spherical');
% rereference the data
[EEG] = doRereference(EEG,{'TP9','TP10'},EEG.chanlocs);
% filter the data, note the higher top end to get at high gamma range
[EEG] = doFilter(EEG,1,30,60,2,500);
% epoch the data
[EEG] = doEpochData(EEG,{'S202','S203'},[-200 800]);
% implement a baseline correction
[EEG] = doBaseline(EEG,[-200,0]);
% check for gradient artifacts
[EEG] = doArtifactRejection(EEG,'Gradient',30);
% check for difference artifacts
[EEG] = doArtifactRejection(EEG,'Difference',150);
% remove artifact trials
[EEG] = doRemoveEpochs(EEG,EEG.artifactPresent);
% run the FFT transform on each condition
[FFT] = doFFT(EEG,{'S202','S203'});
% plot the first 30 Hz of signal for channel Fz for each condition, NB,
% this is 60 data points given the sampling rate and size of data selected
dataToPlot = squeeze(FFT.data(52,1:30,:));
bar(dataToPlot);
title('FFT Analysis');
xticks([1:1:30]);
xticklabels(FFT.frequencies);
xlabel('Frequency (Hz)');
ylabel('Power (uV^2)');